Release v1.0.0 candidate
This commit is contained in:
@@ -282,16 +282,44 @@ async fn trace_video(
|
||||
let duration = (last_frame - first_frame) as f64 / fps + padding * 2.0;
|
||||
let seek = (start_sec - padding).max(0.0);
|
||||
|
||||
// Build filters: per-frame bbox + text
|
||||
// Build filters: bbox+text holding at last detection until next one
|
||||
let mut parts: Vec<String> = Vec::new();
|
||||
for (frame, x, y, w, h) in &rows {
|
||||
let offset = frame - first_frame + (padding * fps) as i32;
|
||||
for (i, (frame, x, y, w, h)) in rows.iter().enumerate() {
|
||||
// Hold this detection until the next one (or end)
|
||||
let next_frame = if i + 1 < rows.len() {
|
||||
rows[i + 1].0
|
||||
} else {
|
||||
// For last detection, extend to duration end
|
||||
last_frame + (padding * fps) as i32
|
||||
};
|
||||
let start_offset = frame - first_frame + (padding * fps) as i32;
|
||||
let end_offset = next_frame - first_frame + (padding * fps) as i32;
|
||||
|
||||
// Bbox: visible from this frame until next detection
|
||||
parts.push(format!(
|
||||
"drawbox=x={}:y={}:w={}:h={}:color=red@0.8:thickness=8:enable='eq(n,{})'",
|
||||
x, y, w, h, offset
|
||||
"drawbox=x={}:y={}:w={}:h={}:color=red@0.8:thickness=8:enable='between(n,{},{})'",
|
||||
x, y, w, h, start_offset, end_offset - 1
|
||||
));
|
||||
// Text: same hold behavior
|
||||
let label = format!("t{}", trace_id);
|
||||
render_text(&mut parts, &label, *x + 6, *y + 6, Some(offset));
|
||||
let mut tx = *x + 6;
|
||||
let mut ty = *y + 6;
|
||||
for ch in label.chars() {
|
||||
let bm = bitmap_char(ch);
|
||||
for (row, bits) in bm.iter().enumerate() {
|
||||
for col in 0..5 {
|
||||
if bits & (1 << (4 - col)) != 0 {
|
||||
let dx = tx + col as i32 * 3;
|
||||
let dy = ty + row as i32 * 3;
|
||||
parts.push(format!(
|
||||
"drawbox=x={}:y={}:w=3:h=3:color=white@1.0:t=fill:enable='between(n,{},{})'",
|
||||
dx, dy, start_offset, end_offset - 1
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
tx += CHAR_ADVANCE;
|
||||
}
|
||||
}
|
||||
|
||||
let vf = if parts.is_empty() {
|
||||
|
||||
Reference in New Issue
Block a user