one behind duplicated, and the correct

This commit is contained in:
2026-04-03 11:54:22 -03:00
parent 101ed10ca1
commit 074925c360
2 changed files with 16 additions and 1 deletions

View File

@@ -98,7 +98,15 @@ def receive_record_relay_and_detect(stream_url, output_path, relay_url,
# Scene detection: CUDA decode (GPU) → select filter (CPU, lightweight)
# → showinfo → MJPEG piped to stdout
select_expr = f"gt(scene,{scene_threshold})"
#
# Flush trick: select the scene-change frame AND the next 2 frames.
# The pipeline has 2 levels of buffering (encoder + muxer), so we
# need 2 flush frames to push the real scene-change frame out.
# mod(selected_n,3) prevents chaining: after 2 flushes, selected_n
# hits a multiple of 3 and the chain stops.
scene_expr = f"gt(scene,{scene_threshold})"
flush_expr = "eq(n,prev_selected_n+1)*mod(selected_n,3)"
select_expr = f"{scene_expr}+{flush_expr}"
scene_stream = stream.filter("select", select_expr).filter("showinfo")
scene_out = ffmpeg.output(
scene_stream, "pipe:1",