Skip to content

4.5.4

Choose a tag to compare

@superuser404notfound superuser404notfound released this 26 Jun 21:16

One bug fix for the native loopback-HLS VOD path. No public API change; recommended patch upgrade for anyone on 4.5.1–4.5.3 playing wide-interleave progressive MP4s.

Fixed

Resuming or seeking into a wide-interleave progressive MP4 desynced audio ~1 s ahead of video (#74 follow-up)

The 4.5.1 fix buffered pre-video-gate audio at head-of-stream, so first-frame playback of a wide-interleave source (one that muxes audio ahead of video in file order) is in sync. But a mid-file seek or resume on the same file still drifted ~1 s, with audio ahead of picture.

Same root cause, different trigger. On a restart the demuxer seeks to the video keyframe but lands before it and scans forward to find it (the keyframe gate waits for isKey && dts >= restartTargetVideoDts). The audio that matches that keyframe is muxed ~1 s earlier in the file, so it is read during the scan-forward, while the audio gate is still closed — and the restart path dropped it. The post-gate restart-target filter then accepted the next available audio, which is ~1 s of content later, and snapped it onto the keyframe's tfdt. Reporter trace:

video gate open: actual=2751250 anchorPts=2751375 target=2751250 shift=0
audio gate open: actual=44112896 target=44064064 desired=44064064 shift=48832 gapMs=1017.3
WARNING: audio gate opened 1017.3 ms after video gate … expect A/V drift audible.

The producer now buffers pre-gate audio on a VOD restart as well, not just head-of-stream. The buffered packets replay in DTS order once the video gate opens and flow through the existing restart-target filter, which drops everything below the seek target and keeps the [target, …] window — so it now selects the matching packet and the gate opens at gapMs ≈ 0. Live restart deliberately keeps the original drop (its program-boundary re-anchor handles audio separately). The buffer stays bounded by the existing 8 MB cap (over the cap the original drop resumes), and normal-interleave seeks are unaffected because their pre-gate audio is all below target and dropped by the filter exactly as before.

Thanks to reckloon for confirming the 4.5.1 head-of-stream fix, then catching the seek/resume residual and root-causing the scan-forward drop with a frame-exact trace.


Full diff: 4.5.3...4.5.4