fix: VFR frame extraction - use select=eq(n) instead of -ss frame/fps
- tkg.rs key_frame: select=eq(n\,best_frame) instead of -ss frame/fps - tkg.rs retry: same fix for need_retry block - tools.rs agent frame: select=eq(n\,frame_number) - media_api.rs segment video: select=between(n\,sf\,ef-1) for frame mode VFR videos (r_frame_rate != actual fps) now get correct frames. CFR videos unaffected: select=eq(n) produces same result as -ss frame/fps. Fixes: face card / face-detail thumbnail mismatch for VFR files.
This commit is contained in:
@@ -1267,19 +1267,20 @@ async fn build_face_track_nodes_from_qdrant(
|
||||
);
|
||||
|
||||
// Extract key_frame JPEG bytes via ffmpeg pipe
|
||||
// Use select=eq(n\,frame) for VFR compatibility (decoded index, not time-based)
|
||||
let key_frame_jpeg: Option<Vec<u8>> = video_path.as_ref().and_then(|vp| {
|
||||
let timestamp = agg.best_frame as f64 / actual_fps;
|
||||
let select = format!("select=eq(n\\,{})", agg.best_frame);
|
||||
let output = std::process::Command::new("ffmpeg")
|
||||
.args([
|
||||
"-y",
|
||||
"-v",
|
||||
"quiet",
|
||||
"-ss",
|
||||
&format!("{:.3}", timestamp),
|
||||
"-i",
|
||||
])
|
||||
.arg(vp)
|
||||
.args([
|
||||
"-vf",
|
||||
&select,
|
||||
"-frames:v",
|
||||
"1",
|
||||
"-q:v",
|
||||
@@ -1404,7 +1405,7 @@ async fn build_face_track_nodes_from_qdrant(
|
||||
|
||||
if need_retry {
|
||||
if let Some(ref vp) = video_path {
|
||||
let timestamp = agg.best_frame as f64 / actual_fps;
|
||||
let select = format!("select=eq(n\\,{})", agg.best_frame);
|
||||
// Retry key_frame extraction
|
||||
if !kf_path.exists() {
|
||||
if let Ok(output) = std::process::Command::new("ffmpeg")
|
||||
@@ -1412,12 +1413,12 @@ async fn build_face_track_nodes_from_qdrant(
|
||||
"-y",
|
||||
"-v",
|
||||
"quiet",
|
||||
"-ss",
|
||||
&format!("{:.3}", timestamp),
|
||||
"-i",
|
||||
vp,
|
||||
])
|
||||
.args([
|
||||
"-vf",
|
||||
&select,
|
||||
"-frames:v",
|
||||
"1",
|
||||
"-q:v",
|
||||
|
||||
Reference in New Issue
Block a user