From 765db8ae9f1216423571bd80123461356b8693fc Mon Sep 17 00:00:00 2001 From: Accusys Date: Mon, 6 Jul 2026 16:08:32 +0800 Subject: [PATCH] fix: TKG FPS calculation for ASRX fallback segments When ASRX falls back to ASR segments, end_frame may be 0. The FPS calculation now handles this case correctly by checking both end_frame > 0 and end_time > 0 before dividing. This prevents division by zero and incorrect FPS values when processing videos with ASRX fallback segments. --- src/core/processor/tkg.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/core/processor/tkg.rs b/src/core/processor/tkg.rs index 9c225f1..0c5fb82 100644 --- a/src/core/processor/tkg.rs +++ b/src/core/processor/tkg.rs @@ -1401,8 +1401,11 @@ async fn build_speaker_face_edges_from_pg( .collect(); let last = asrx.segments.last().unwrap(); - let fps = if last.end_time > 0.0 { + let fps = if last.end_frame > 0 && last.end_time > 0.0 { last.end_frame as f64 / last.end_time + } else if last.end_time > 0.0 { + // Fallback: estimate FPS from probe or use 30 + 30.0 } else { 30.0 };