feat(moq-mux): carry B-frame reorder depth as catalog jitter (exact DTS reserve)#1857
Open
kixelated wants to merge 1 commit into
Open
feat(moq-mux): carry B-frame reorder depth as catalog jitter (exact DTS reserve)#1857kixelated wants to merge 1 commit into
kixelated wants to merge 1 commit into
Conversation
…S reserve from it
The TS exporter authors a decode timeline (DTS) for reordered video, but with only
a fixed fallback reserve it could not guarantee DTS <= PTS for deep reorders. The
source TS already states the reorder depth (PTS - DTS per PES); carry it through the
catalog so the exporter reserves exactly enough.
- The TS importer now reads the PES DTS (previously discarded), computes the reorder
delay (max PTS - DTS), and folds it into the catalog `jitter` for the video
rendition. `jitter` already documents this case ("3 b-frames in a row -> 3 *
1000/fps"); this finally populates it. Generalize the jitter estimator to report
max(min frame duration, max reorder), and seed a freshly created rendition from it
so a dirty start (frames before the first SPS) doesn't lose the value.
- The TS exporter sizes its decode-clock reserve from the catalog `jitter`, falling
back to the small monotonic-only nudge when none is declared. With the reorder
depth known, DTS <= PTS holds (verified on the real kyrion 1080i feed).
This rides through the relay via the catalog, so it survives pub | relay | sub with
no per-frame wire change. No catalog format change (jitter already existed).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Stacked on #1843. Makes the exporter's decode-clock reserve exact instead of a fixed guess, so
DTS ≤ PTSholds for real B-frame feeds — by carrying the reorder depth the source already knows through the catalog.What
max(PTS − DTS)), and folds it into the video rendition's catalogjitter. Thejitterfield already documents this exact case ("up to 3 b-frames in a row → 3 × 1000/fps") — this finally populates it. The jitter estimator now reportsmax(min frame duration, max reorder), and a freshly created rendition is seeded from it so a dirty start (frames before the first SPS, as in the kyrion capture) doesn't lose the value.jitter, falling back to the small monotonic-only nudge (fix(moq-mux): author DTS for B-frame MPEG-TS export #1843) when none is declared. With the reorder depth known, the authored DTS is both strictly increasing and≤ PTS.This rides through the relay via the catalog, so it survives
pub | relay | subwith no per-frame wire change, and no catalog format change (jitteralready existed — only its population and consumption change).Why this over the fixed reserve
#1843 keeps DTS monotonic (fixes
+igndts) but can't guaranteeDTS ≤ PTSwithout either over-buffering (large fixed reserve = latency) or guessing. The source TS states the exact reorder (PTS − DTS); this carries it, so the reserve equals the actual reorder depth — minimal latency, exact, and B-frame-free streams are unaffected (reserve ≈ one frame).Notes / decisions for the reviewer
dev) only to keep the diff to one commit —devis currently ~35 commits behindmain, so a directdevPR would show all of that. It's not a catalog format change, so it can land onmaintogether with fix(moq-mux): author DTS for B-frame MPEG-TS export #1843, or be retargeted todevif you'd rather batch it there. Your call at merge time.jitter(the reorder delay, e.g. ~167 ms for kyrion) instead of just the frame interval — which is the field's documented meaning, and correctly sizes the browser player's buffer too.Test plan
author_dts: monotonic across reorder with the fallback;DTS ≤ PTSonce the reserve covers the reorder span.import_kyrion_video_jitter_captures_reorderasserts the videojitterreflects the ~5-frame reorder (~167 ms), not the ~33 ms frame interval.DTS ≤ PTStimeline (the whole import → jitter → export chain).moq-muxsuite (249 tests),cargo clippy,cargo fmtclean (via nix).(Written by Claude)