feat: add TraceArtifacts phase + VLM waits for all key_frame.jpg
- Add TraceArtifacts phase to TkgPhase enum (phase 18) - Report progress as key_frame.jpg/key_face.jpg are created - VLM trigger now polls until ALL key_frame.jpg files exist (was: started after TKG build, before artifacts were ready) - Add iron rule to AGENTS.md: ask before removing data Tested: Gamma 8 (27 traces) → 27/27 VLM summaries completed
This commit is contained in:
@@ -41,7 +41,10 @@ async fn main() -> Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
println!("\nDone! Total updated: {}, Errors: {}", total_updated, total_errors);
|
||||
println!(
|
||||
"\nDone! Total updated: {}, Errors: {}",
|
||||
total_updated, total_errors
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -69,10 +69,7 @@ async fn main() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn rebuild_file_thumbs(
|
||||
qdrant: &QdrantDb,
|
||||
file_uuid: &str,
|
||||
) -> Result<(usize, usize)> {
|
||||
async fn rebuild_file_thumbs(qdrant: &QdrantDb, file_uuid: &str) -> Result<(usize, usize)> {
|
||||
// Get all face points for this file
|
||||
let filter = json!({
|
||||
"must": [
|
||||
@@ -88,13 +85,12 @@ async fn rebuild_file_thumbs(
|
||||
|
||||
// Get video path from DB
|
||||
let db = PostgresDb::new(&config::DATABASE_URL).await?;
|
||||
let video_path: Option<String> = sqlx::query_scalar(
|
||||
"SELECT file_path FROM videos WHERE file_uuid = $1",
|
||||
)
|
||||
.bind(file_uuid)
|
||||
.fetch_optional(db.pool())
|
||||
.await?
|
||||
.flatten();
|
||||
let video_path: Option<String> =
|
||||
sqlx::query_scalar("SELECT file_path FROM videos WHERE file_uuid = $1")
|
||||
.bind(file_uuid)
|
||||
.fetch_optional(db.pool())
|
||||
.await?
|
||||
.flatten();
|
||||
|
||||
let video_path = match video_path {
|
||||
Some(p) => p,
|
||||
@@ -116,7 +112,9 @@ async fn rebuild_file_thumbs(
|
||||
let w = bbox["width"].as_f64().unwrap_or(0.0);
|
||||
let h = bbox["height"].as_f64().unwrap_or(0.0);
|
||||
|
||||
let entry = best_faces.entry(tid as i32).or_insert((0.0, 0, 0.0, 0.0, 0.0, 0.0));
|
||||
let entry = best_faces
|
||||
.entry(tid as i32)
|
||||
.or_insert((0.0, 0, 0.0, 0.0, 0.0, 0.0));
|
||||
if conf > entry.0 {
|
||||
*entry = (conf, frame, x, y, w, h);
|
||||
}
|
||||
@@ -161,11 +159,20 @@ async fn rebuild_file_thumbs(
|
||||
|
||||
let output = Command::new("ffmpeg")
|
||||
.args([
|
||||
"-y", "-v", "quiet",
|
||||
"-i", &video_path,
|
||||
"-vf", &format!("select=eq(n\\,{}),crop={}:{}:{}:{}", frame_num, size, size, crop_x, crop_y),
|
||||
"-frames:v", "1",
|
||||
"-q:v", "2",
|
||||
"-y",
|
||||
"-v",
|
||||
"quiet",
|
||||
"-i",
|
||||
&video_path,
|
||||
"-vf",
|
||||
&format!(
|
||||
"select=eq(n\\,{}),crop={}:{}:{}:{}",
|
||||
frame_num, size, size, crop_x, crop_y
|
||||
),
|
||||
"-frames:v",
|
||||
"1",
|
||||
"-q:v",
|
||||
"2",
|
||||
key_face_path.to_str().unwrap(),
|
||||
])
|
||||
.output();
|
||||
@@ -179,11 +186,17 @@ async fn rebuild_file_thumbs(
|
||||
let tmp_frame = trace_dir.join("tmp_frame.jpg");
|
||||
let _ = Command::new("ffmpeg")
|
||||
.args([
|
||||
"-y", "-v", "quiet",
|
||||
"-i", &video_path,
|
||||
"-vf", &select_filter,
|
||||
"-frames:v", "1",
|
||||
"-q:v", "2",
|
||||
"-y",
|
||||
"-v",
|
||||
"quiet",
|
||||
"-i",
|
||||
&video_path,
|
||||
"-vf",
|
||||
&select_filter,
|
||||
"-frames:v",
|
||||
"1",
|
||||
"-q:v",
|
||||
"2",
|
||||
tmp_frame.to_str().unwrap(),
|
||||
])
|
||||
.output();
|
||||
@@ -191,10 +204,15 @@ async fn rebuild_file_thumbs(
|
||||
if tmp_frame.exists() {
|
||||
let _ = Command::new("ffmpeg")
|
||||
.args([
|
||||
"-y", "-v", "quiet",
|
||||
"-i", tmp_frame.to_str().unwrap(),
|
||||
"-vf", &format!("crop={}:{}:{}:{}", size, size, crop_x, crop_y),
|
||||
"-q:v", "2",
|
||||
"-y",
|
||||
"-v",
|
||||
"quiet",
|
||||
"-i",
|
||||
tmp_frame.to_str().unwrap(),
|
||||
"-vf",
|
||||
&format!("crop={}:{}:{}:{}", size, size, crop_x, crop_y),
|
||||
"-q:v",
|
||||
"2",
|
||||
key_face_path.to_str().unwrap(),
|
||||
])
|
||||
.output();
|
||||
|
||||
Reference in New Issue
Block a user