Repository navigation
Conversation
…acket refs ZoneMinder#4242 When a camera's clock steps back (NTP sync, clock reset) by more than the recording's reorder queue can sort out, VideoStore::write_packet patches each dts to last_dts + duration. The source stays behind, so every following packet of the event logs "non increasing dts, fixing." until the event ends. Treat such a step on the video stream (more than 1 s back, below the existing 10 s "jumped back in time too far" handling) as a short break in capture: FfmpegCamera marks the packet, analysis closes the event there and the next one starts on that packet, with its own timeline. The capture is not re-primed. get_event_start_packet_it() does not reach back past a marked packet for pre-event frames or a keyframe, so the new event does not hold the step again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
Details: reproduction, change, behaviour changes, checks
Before
Upstream master
25dba3267, clean build. An Ffmpeg monitor reads a local FLV file (loop=1,realtime=1, Recording=Always, passthrough, section length 60 s) whose clock steps back 8.933 s every 12 s of video, under the 10 s "jumped back in time too far" cut-off.VideoStore::write_packet(src/zm_videostore.cpp:1614-1617) replaces each such dts withlast_dts + last_duration. The camera's clock stays behind that value, so every later packet in the event warns again, until a new event starts its timestamps over. The reorder queue only absorbs short-lived jitter. On the input side,FfmpegCamera::Capture(src/zm_ffmpeg_camera.cpp:364) only handles steps of more than 10 s.Change
src/zm_ffmpeg_camera.cpp/.h:IsDtsCaptureBreak()is true for a step back of more than 1 s (kCaptureBreakDtsStep), checked on the video stream only, after the existing 10 s check. On a break, capture logs one Info line ("Stream dts jumped back N seconds, treating it as a break in capture") and setsZMPacket::capture_break. The capture is not re-primed.src/zm_packet.h/.cpp: thecapture_breakflag, initialised and copied.src/zm_monitor.cpp(Analyse): a flagged packet with an open event logs Info "Closing event N, capture break" and callscloseEvent(), next to the signal-loss close. The existingif (!event)path then opens the next event on that packet (at once for Recording=Always, at the next alarm otherwise). Cause and notes unchanged.src/zm_packetqueue.cpp(get_event_start_packet_it): looking back for pre-event frames or a keyframe stops at a flagged packet, as it already stops atreleased_before_; otherwise a continuous event reaches back to the keyframe before the step and records the step again. When the flagged packet isn't a keyframe,start_on_keyframemoves forward to the next keyframe; its "no keyframe" message is Debug, not Warning, in that case.tests/zm_ffmpeg_camera.cppcovers the threshold (equal dts, 100 ms and exactly 1 s are not a break; 1.048 s, the report's 94320 ticks at 90 kHz, and 8.933 s are).tests/zm_packetqueue.cppcovers "an event never starts before a capture break" for passthrough continuous, passthrough with pre-event frames, encode with pre-event frames, and no break. They pass on this branch; not run against unpatched master.The equal-dts case (the packet after a keyframe carrying the keyframe's dts) is unchanged: still Debug, dts + 1.
Behaviour changes
last_eventwhile the monitor is in ALARM/ALERT, so a step during an alarm gives a second notificationmin_section_length, or limit how often events splitNo client (pyzmNg, zm-py/ha-zoneminder, zmNinjaNg, zmeventnotificationNg) matches these log texts. API and schema unchanged. Side fixes: none.
After
Branch at
4d13aa63d(base25dba3267), build head4d13aa63d7c9, dirty false:(The probe source reads faster than real time after a step, so a split event holds more video than its wall-clock length; that is the probe, not the fix.)
Not run: audio (the probe has no audio track); a step during an alarm on OnMotion/Mocord; RTSP cameras (the probe goes through the same FfmpegCamera path from a file); the zmeventnotificationNg e2e; clients and contract (no API change). release-1.38 has the same 10 s handling and per-packet warning, but its packet queue has no
released_before_stop, so the start-packet part would need rework; not attempted.Open questions
min_section_lengthor be rate-limited, so a camera that keeps stepping back doesn't fill the event list instead of the log?refs #4242
🤖 Generated with Claude Code