Repository navigation
fix(moq-mux): a TS export pads AAC to a rate its slots can carry - #9609
Merged
Merged
Conversation
Quest-Claim: 7f21aa8e7e3ccebb
`moq export ts` of an MPEG-TS AAC source packed as FFmpeg packs it by default failed with "MPEG-TS output missed a decode deadline". The source's recorded multiplex rate is its audio's own, with no nulls, but the export sends a frame no more than a slot ahead and leads some slots with the PAT, the PMT and a clock packet, so a slot has to carry all of them. - A padded export raises a catalog rate to what its AAC entries' bitrates need per slot. - A packed PES's later frames are due at their own decode times, not the first's, which they were held to whole. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…trate-less sources Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ext packet Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
kixelated
marked this pull request as ready for review
November 25, 2026 19:03
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 9 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
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.
Finishes quest/m1/ts-aac-export-rate.md and deletes it.
Problem
moq export tsof an MPEG-TS AAC source packed as FFmpeg packs it by default (186 ms of AAC per PES, no nulls) failed withMPEG-TS output missed a decode deadline on PID 256 at 158726 b/s. Reproduced onmainwith the real binaries (just test ts --source <ffmpeg stereo 44.1 kHz 128 kb/s AAC>) and in process.The quest guessed an undercounted rate estimate. It isn't one. The recorded rate (158.7 kb/s) is the audio's own packing with no spare, and the export cannot lay that audio in it:
Approach
schedule.rs: each packet of a packed PES is due at the decode time of the frame it starts in (Unit::decode_at/by_at), as the T-STD removes a frame at its own time. Occupancy is still gated per frame. Measured on the paced in-process export: the least working rate falls from about 500 kb/s to 300 kb/s.export.rs: a catalog rate is raised toaudio_floor, the slots' need from the catalog's AAC bitrates: a frame at twice the bitrate (variable-rate peaks), plus PAT, PMT and a clock packet per slot. The floor is bounded by each entry's decoder buffer and by the rate limit, since the catalog is untrusted. An explicit--mux-rateis still honored as given. The 128 kb/s source above now exports at 481 kb/s.Impact
--mux-ratehelp,Export::with_mux_ratedocs anddoc/bin/ts.mdnow say the recorded rate is raised for AAC.Alternatives
Validation
main:just test ts --sourceof FFmpeg stereo 44.1 kHz 128 kb/s AAC fails in the subscriber, "needed rate 211366 b/s" at 158726 b/s. On this head it passes every check, including the independent T-STD model (peak B fill 44%, no overflow or underflow, which checks the per-frame deadline) and TBsys/Bsys.just test ts,ts --fullandts --headroompass.an_ffmpeg_aac_source_exports_with_default_settingsfeeds a 5 s FFmpeg-packed AAC fixture (test_data/ffmpeg_aac.ts) paced on its PCRs into the default export (500 ms delay, no rate given). It fails onmainwith the error above, and needs both changes: the floor alone fails at 481 kb/s, the deadline change alone at 159 kb/s.just checkpasses on the final head (11,5xx tests); the review foundassert_next_offlineno longer blockscargo test -p moq-muxon this base, so no local removal was needed for the last runs (earlier runs applied chore: run pre-0.22 recurring audits, fix moq-net fuzz build, and file blockers #9505's one-line removal locally, uncommitted).the_aac_floor_*), and heap ranking by the next packet's deadline.Overlap
schedule.rs): no conflict, and it changes the unpadded path, which this does not touch.revision_test.rs'sreexport_framesand conflict there: it gains anopeningargument there and arateargument here, so whichever lands second keeps both.Caused by
Decisions
Taken with no one to ask (afk), each with my recommendation, for review:
--mux-rateis not floored (it fails loud as before). Recommendation: keep.Follow-ups
Models
Size: S
Implementer: Claude Code, claude-sonnet-5-5, unknown effort (arm B)
🤖 Generated with Claude Code
(Written by Claude Sonnet 5.5)
Review
Rewritten by
quest reviewafter each round.Head: c026292
Base: origin/main at 420b8dc
Risk: medium,
If the default TS export's padding or packet scheduling is wrong, users exporting AAC TS sources with default settings get a different multiplex rate or a missed-deadline error, and only after the next release cut publishes it; a revert of this change undoes it fully. The exported container format and public API are unchanged (the `--mux-rate` override path is untouched and the catalog-rate path only gains a floor), so it is not a wire or format break, which keeps it out of high.Classified: medium by Claude Code, claude-haiku-5-5, low effort, session
c42d5ea7-7bcf-4e45-8674-96a96181d802Reviewer: Codex, gpt-6.2-sol, medium effort
Session:
01a21400-b73a-75c1-a2d6-bc7dcdf4c358, round 2Score: 10/10,
The head is ready to land because the capped AAC floor keeps padding enabled when the recorded rate is valid.Rounds: 3; first round 2 (high 1, medium 1); findings 2 (medium 2): fixed 2, refuted 0, open 0
Findings: none
The last round's findings, at ba2ff02:
rs/moq-mux/src/container/ts/export.rs:2457:Keep a valid recorded rate when the AAC floor exceeds the limit;The cap at `rs/moq-mux/src/container/ts/export.rs:129` keeps the maximum of the AAC floor and a valid recorded rate within the sanitizer’s accepted range at line 2462.