mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-08-03 08:46:44 -04:00
Add a "realtime=1" (alias "re=1") ffmpeg input option, modeled on the existing "loop" option and equivalent to ffmpeg's -re flag. When set on a file source, FfmpegCamera throttles packet delivery to the rate implied by the stream timestamps instead of reading the file as fast as possible. The option is parsed out of the ffmpeg Options string in OpenFfmpeg and consumed so it is not passed to the demuxer or decoder. Capture() anchors wall-clock time to the first delivered packet and sleeps before each subsequent packet so it is not delivered ahead of schedule. Pacing uses dts (monotonic in read order) with a pts fallback, runs after the existing drop/jump filters, and re-anchors on backward jumps or gaps beyond a 10s cap to avoid stalling on a discontinuity. Works alongside loop, whose offset-adjusted timestamps stay monotonic across restarts. The pacing decision is factored into a pure ComputeRealtimePace() function and unit-tested in tests/zm_ffmpeg_camera.cpp (8 cases covering full/partial interval waits, behind-schedule, on-schedule, backward jump, over-cap, and the cap boundary). Ported from the ai_server branch onto master's OpenFfmpeg structure. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
3.8 KiB
3.8 KiB