Skip to content

fix(hls): frames reordered deeper than the opening frames show keep their presentation times - #37

Merged
gravity-zero merged 12 commits into
masterfrom
fix/composition-shift-reorder-depth
Nov 21, 2026
Merged

gravity-zero merged 12 commits into
masterfrom
fix/composition-shift-reorder-depth

Conversation

@gravity-zero

Copy link
Copy Markdown
Owner

HLS/DASH from a video with B-frames lost frames whenever the stream reordered deeper than its opening frames showed: frames shared a presentation time and players dropped them (25 to 40 % of a segment's frames on the files measured).

Fixed

  • The composition shift covers the reordering depth the parameter sets declare (max_num_reorder_frames, sps_max_num_reorder_pics), and is measured past a first GOP of a frame or two.
  • A frame reordered deeper than the stream announces keeps its presentation time through a negative composition offset (trun version 1) instead of being clamped onto its neighbour's.
  • A stray timestamp (a frame presenting before more than 16 frames decoded ahead of it) presents at its decode time and moves no other frame's decode time; full pass and on demand agree on it.
  • A segment opens on its keyframe when a frame shares the keyframe's timestamp; a window served cold no longer loses the frames stored after such a frame.

Changed

  • The HLS/DASH init segment no longer carries the cover art (a large cover made it megabytes a player fetches before its first frame). RemuxToMP4 still carries it.

Integration

For the sources concerned, the init segment's edit list and the segments' composition offsets change together: cached inits and segments of one source must be dropped at once.

Checks

  • scripts/e2e.sh gains a source that reorders only after its opening frames; presentation times are compared with the prober's, full pass and on demand, from Matroska and MP4.
  • New workflow Apple timestamps: on a macOS runner, AVFoundation decodes the init and segments and every frame must present where the source has it, for a positive shift with an edit list and for negative offsets.

Known limit

A reader that ignores the video edit list presents a B-frame video later than its audio by the composition shift. This is not new; the shift grows (for instance 42 to 84 ms) on the sources fixed here. Follow-up: signed offsets with no shift and no edit list.

…megabytes a player fetches before its first frame
…eter sets declare, frames reordered after the opening ones shared a presentation time
… every presentation time through HLS, full pass and on demand
…s presentation time through a negative composition offset, it was clamped onto its neighbour's
… shares its keyframe's timestamp, as the full pass does
…frame's timestamp, full pass and on demand agree on its decode times
…offset 0, a stray timestamp wrote a negative offset of seconds
…oss, not by a duration, and moves no other frame's decode time on either path
@gravity-zero
gravity-zero merged commit 8d24281 into master Nov 21, 2026
14 checks passed
@gravity-zero
gravity-zero deleted the fix/composition-shift-reorder-depth branch November 21, 2026 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant