From d392c8c631d9d033cb9f822407be7ff847d2b65a Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 31 Oct 2026 02:25:48 -0700 Subject: [PATCH 1/6] chore(quest): claim quest/m1/hls-final-aac-segment.md Quest-Claim: 6de1c05a3437d71e From 9b757fadd5b8bf2e7f32b6cda309a37be419c8a6 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 31 Oct 2026 02:32:54 -0700 Subject: [PATCH 2/6] fix(mux): bound TS AAC groups by their sample endpoint Co-Authored-By: GPT-6.1 Sol --- quest/m1/hls-final-aac-segment.md | 8 ++++++++ rs/moq-mux/src/container/ts/import.rs | 25 +++++++++++++++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/quest/m1/hls-final-aac-segment.md b/quest/m1/hls-final-aac-segment.md index 43b3a4505a1..35d28800941 100644 --- a/quest/m1/hls-final-aac-segment.md +++ b/quest/m1/hls-final-aac-segment.md @@ -10,6 +10,14 @@ Found by the conformance test in [moq-dev/moq#7387](https://github.com/moq-dev/m Decided 2026-10-30 (maintainer, follow-up planning after the /quest-afk run). Find the root cause before changing anything; fix it at the source rather than padding the advertised duration. The conformance test's audio check is the regression test. +Implementation checkpoint 2026-10-31 (GPT-6.1 Sol): the TS importer cuts every AAC frame into its own group, so the container producer clears its previous timestamp before it can measure a cadence. `cut(None)` reports only that frame's start to the HLS recorder. Pass the next PTS, already computed from the ADTS frame's 1024 samples, as the group's endpoint instead. No advertised-duration padding or codec API change is needed. + +The existing split-frame EOF test now checks the final HLS stop record. Before the fix it reads 1021 ms instead of the two frames' 1042 ms endpoint; with the fix it passes. + +The existing conformance test from [moq-dev/moq#7387](https://github.com/moq-dev/moq/pull/7387) was run locally using a temporary overlay adapted to the checkout's mp4-atom API. All 13 AAC segments' HLS and DASH durations pass its 2.5 ms tolerance. The final segment advertises 1.387 s and decodes 1.386667 s. The whole test still fails on 13 video decoder-identity/recording findings owned by the related quest; its assertions were kept intact. No conformance changes are included here. + +Remaining before completion: run `just ci` and obtain the required other-vendor local review. The host's Claude weekly review quota is reportedly exhausted; keep the PR draft if that blocks the review. + Public API: none. Wire: none. ## Related diff --git a/rs/moq-mux/src/container/ts/import.rs b/rs/moq-mux/src/container/ts/import.rs index 2d41ce0825c..29d08850130 100644 --- a/rs/moq-mux/src/container/ts/import.rs +++ b/rs/moq-mux/src/container/ts/import.rs @@ -3941,15 +3941,14 @@ impl AacStream { // Count only completed frames; input gaps and unfinished tails are not a media burst. burst += std::time::Duration::from_nanos((1024_u64 * 1_000_000_000).div_ceil(header.sample_rate as u64)); // The importer accumulates; cut each ADTS frame into its own group (one QUIC stream) - // so the relay forwards it without waiting for the next. - import.cut(None)?; + // so the relay forwards it without waiting for the next. Its known endpoint also + // bounds the final HLS segment, since a one-frame group has no measured cadence. + pts = advance_pts(pts, 1024, header.sample_rate)?; + import.cut(pts)?; self.resync.published(unvouched); published += 1; // Offsets behind the published frame are spent; carrying one would republish it. fallback = None; - - // Every ADTS frame is 1024 samples. - pts = advance_pts(pts, 1024, header.sample_rate)?; offset = end; } @@ -6390,7 +6389,7 @@ pub(super) mod test { let mut broadcast = moq_net::broadcast::Info::new().produce(); let consumer = broadcast.consume(); - let catalog = crate::catalog::Producer::new(&mut broadcast, crate::catalog::Config::default()).unwrap(); + let mut catalog = crate::catalog::Producer::new(&mut broadcast, crate::catalog::Config::default()).unwrap(); let mut import = super::Import::new(broadcast, catalog.reserve()); let pmt = synth_pmt(&[(StreamType::AdtsAac, AAC_PID)], false); @@ -6415,6 +6414,20 @@ pub(super) mod test { [0xAA, 0xBB].map(|fill| adts_frame(40, fill)[7..].to_vec()).to_vec(), "the last frame was held for a confirmation that could never arrive" ); + catalog.finish().unwrap(); + let snapshot = catalog.snapshot(); + let hls = snapshot.audio.renditions.values().next().unwrap().hls.as_ref().unwrap(); + let mut records = crate::hls::Consumer::subscribe(&consumer, hls).await.unwrap(); + let mut end = None; + while let Some(event) = records.next().await.unwrap() { + if let crate::hls::Event::Push { entry, .. } = event + && entry.is_stop() + { + end = Some(entry.pts); + } + } + // Both 1024-sample frames at 48 kHz, including the one completed by the EOF drain. + assert_eq!(end, Some(Timestamp::from_millis(1_042).unwrap())); } /// One whole MPEG-2 Layer II frame (8 kbps, 16 kHz, mono = 72 bytes), filled with From ccbfb694cdfdf68e4623b87c946f90e34dc10dc1 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 31 Oct 2026 02:39:10 -0700 Subject: [PATCH 3/6] docs(quest): record AAC validation and review blockers Co-Authored-By: GPT-6.1 Sol --- quest/m1/hls-final-aac-segment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quest/m1/hls-final-aac-segment.md b/quest/m1/hls-final-aac-segment.md index 35d28800941..b4143c10bc9 100644 --- a/quest/m1/hls-final-aac-segment.md +++ b/quest/m1/hls-final-aac-segment.md @@ -16,7 +16,7 @@ The existing split-frame EOF test now checks the final HLS stop record. Before t The existing conformance test from [moq-dev/moq#7387](https://github.com/moq-dev/moq/pull/7387) was run locally using a temporary overlay adapted to the checkout's mp4-atom API. All 13 AAC segments' HLS and DASH durations pass its 2.5 ms tolerance. The final segment advertises 1.387 s and decodes 1.386667 s. The whole test still fails on 13 video decoder-identity/recording findings owned by the related quest; its assertions were kept intact. No conformance changes are included here. -Remaining before completion: run `just ci` and obtain the required other-vendor local review. The host's Claude weekly review quota is reportedly exhausted; keep the PR draft if that blocks the review. +Remaining before completion: finish the required full checks and other-vendor review after host blockers clear. `quest gate just ci` stayed queued for host capacity and was stopped at handoff. `quest gate just test interop --all` passed its nine protocol tests, then failed to launch the media matrix's Cargo build with mbx's `Argument list too long (os error 7)`. `quest review --base origin/main --json` failed because Claude's weekly limit resets November 2 at 02:00 America/Los_Angeles. No review verdict was obtained, so the PR remains draft and this quest remains open. The launcher and harness hooks were left untouched. Public API: none. Wire: none. From 161fc891e5abc1a9f769e71d74a1eac162dc11f9 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 31 Oct 2026 12:00:18 -0700 Subject: [PATCH 4/6] fix(mux): bound TS MPEG audio and Opus groups by their sample endpoint The same one-frame-group gap as AAC: each frame's cut carried no endpoint, so the final HLS/DASH segment ended at the last frame's start. Pass the already-known next PTS, and share the EOF stop-record check across the AAC, MPEG audio, and Opus tests. Co-Authored-By: Claude Opus 5.5 --- rs/moq-mux/src/container/ts/import.rs | 80 ++++++++++++++++----------- 1 file changed, 47 insertions(+), 33 deletions(-) diff --git a/rs/moq-mux/src/container/ts/import.rs b/rs/moq-mux/src/container/ts/import.rs index 29d08850130..471375a2683 100644 --- a/rs/moq-mux/src/container/ts/import.rs +++ b/rs/moq-mux/src/container/ts/import.rs @@ -4049,23 +4049,16 @@ impl OpusStream { // 48 kHz samples elapsed since this PES's PTS, advancing each packet after the first. let mut elapsed: u64 = 0; for packet in packets { - let pts = match base { - Some(base) if elapsed > 0 => { - let advance = Timestamp::from_scale(elapsed, 48_000)?; - // `base` is a 90 kHz PTS; rescale the sample advance to match before - // adding (the scale-aware Timestamp rejects mixed scales). - Some(base.checked_add(advance.convert(base.scale())?)?) - } - other => other, - }; - self.import.decode(packet, pts)?; - // The importer accumulates; cut each Opus packet into its own group (one QUIC stream) - // so the relay forwards it without waiting for the next. - self.import.cut(None)?; - + let pts = advance_pts(base, elapsed, 48_000)?; // Default to 20 ms (960 samples) if the TOC can't be read, so a malformed packet // doesn't stall the timeline for the rest of the PES. elapsed += opus::packet_samples(packet).unwrap_or(960) as u64; + let end = advance_pts(base, elapsed, 48_000)?; + self.import.decode(packet, pts)?; + // The importer accumulates; cut each Opus packet into its own group (one QUIC stream) + // so the relay forwards it without waiting for the next. Its known endpoint also + // bounds the final HLS segment, since a one-packet group has no measured cadence. + self.import.cut(end)?; published += 1; } Ok(published) @@ -4551,14 +4544,14 @@ impl LegacyStream { import.decode(&data[offset..end], pts)?; // The importer accumulates; cut each frame into its own group (one QUIC stream) - // so the relay forwards it without waiting for the next. - import.cut(None)?; + // so the relay forwards it without waiting for the next. Its known endpoint also + // bounds the final HLS segment, since a one-frame group has no measured cadence. + pts = advance_pts(pts, header.samples, header.sample_rate)?; + import.cut(pts)?; self.resync.published(unvouched); published += 1; // Offsets behind the published frame are spent; carrying one would republish it. fallback = None; - - pts = advance_pts(pts, header.samples, header.sample_rate)?; offset = end; } @@ -6036,6 +6029,26 @@ pub(super) mod test { } /// Read every retained frame of the single audio rendition in `catalog`. + /// Where the only audio rendition's HLS records end, once the catalog finishes. + async fn hls_audio_end( + consumer: &moq_net::broadcast::Consumer, + catalog: &mut crate::catalog::Producer, + ) -> Option { + catalog.finish().unwrap(); + let snapshot = catalog.snapshot(); + let hls = snapshot.audio.renditions.values().next().unwrap().hls.as_ref().unwrap(); + let mut records = crate::hls::Consumer::subscribe(consumer, hls).await.unwrap(); + let mut end = None; + while let Some(event) = records.next().await.unwrap() { + if let crate::hls::Event::Push { entry, .. } = event + && entry.is_stop() + { + end = Some(entry.pts); + } + } + end + } + async fn read_audio_frames( consumer: &moq_net::broadcast::Consumer, catalog: &crate::catalog::Producer, @@ -6414,20 +6427,11 @@ pub(super) mod test { [0xAA, 0xBB].map(|fill| adts_frame(40, fill)[7..].to_vec()).to_vec(), "the last frame was held for a confirmation that could never arrive" ); - catalog.finish().unwrap(); - let snapshot = catalog.snapshot(); - let hls = snapshot.audio.renditions.values().next().unwrap().hls.as_ref().unwrap(); - let mut records = crate::hls::Consumer::subscribe(&consumer, hls).await.unwrap(); - let mut end = None; - while let Some(event) = records.next().await.unwrap() { - if let crate::hls::Event::Push { entry, .. } = event - && entry.is_stop() - { - end = Some(entry.pts); - } - } // Both 1024-sample frames at 48 kHz, including the one completed by the EOF drain. - assert_eq!(end, Some(Timestamp::from_millis(1_042).unwrap())); + assert_eq!( + hls_audio_end(&consumer, &mut catalog).await, + Some(Timestamp::from_millis(1_042).unwrap()) + ); } /// One whole MPEG-2 Layer II frame (8 kbps, 16 kHz, mono = 72 bytes), filled with @@ -6791,7 +6795,7 @@ pub(super) mod test { let mut broadcast = moq_net::broadcast::Info::new().produce(); let consumer = broadcast.consume(); - let catalog = crate::catalog::Producer::new(&mut broadcast, crate::catalog::Config::default()).unwrap(); + let mut catalog = crate::catalog::Producer::new(&mut broadcast, crate::catalog::Config::default()).unwrap(); let mut import = super::Import::new(broadcast, catalog.reserve()); let pmt = synth_pmt(&[(StreamType::Mpeg1Audio, MP2_PID)], false); @@ -6835,6 +6839,11 @@ pub(super) mod test { )]), "the drained frame was published without a trace" ); + // Both 1152-sample frames at 16 kHz, including the one completed by the EOF drain. + assert_eq!( + hls_audio_end(&consumer, &mut catalog).await, + Some(Timestamp::from_millis(1_144).unwrap()) + ); } // A sync word is short enough to turn up by chance in compressed payload (a valid-looking @@ -9701,7 +9710,7 @@ pub(super) mod test { async fn damaged_opus_pes_is_not_half_published() { let mut broadcast = moq_net::broadcast::Info::new().produce(); let consumer = broadcast.consume(); - let catalog = crate::catalog::Producer::new(&mut broadcast, crate::catalog::Config::default()).unwrap(); + let mut catalog = crate::catalog::Producer::new(&mut broadcast, crate::catalog::Config::default()).unwrap(); let mut import = super::Import::new(broadcast, catalog.reserve()); import .ensure_stream( @@ -9727,6 +9736,11 @@ pub(super) mod test { let name = catalog.snapshot().audio.renditions.keys().next().unwrap().clone(); let frames = read_track(&consumer, &name, crate::container::Kind::Audio).await; assert_eq!(frames.len(), 2, "no packet from the damaged PES is published"); + // The last PES starts at 1.0667 s and holds one 20 ms packet, recorded in milliseconds. + assert_eq!( + hls_audio_end(&consumer, &mut catalog).await, + Some(Timestamp::from_millis(1_086).unwrap()) + ); } /// An aborted track is a feed-wide publishing failure, never a damaged media unit. From 57184181d31fa72a8c88fd626857204c5c0bdede Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 31 Oct 2026 12:00:39 -0700 Subject: [PATCH 5/6] chore(quest): finish quest/m1/hls-final-aac-segment.md Co-Authored-By: Claude Opus 5.5 --- quest/m1/README.md | 1 - quest/m1/hls-conformance.md | 1 - quest/m1/hls-final-aac-segment.md | 25 ------------------------- 3 files changed, 27 deletions(-) delete mode 100644 quest/m1/hls-final-aac-segment.md diff --git a/quest/m1/README.md b/quest/m1/README.md index fdf97415a72..c8886e44a43 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -186,7 +186,6 @@ removed). - [Poll-first async](/quest/m1/poll-first/README.md) - library crates compile no coroutines by default: async wrappers are generated from `poll_*` and gated behind an `async` feature - [Binding announcements always carry captures](/quest/m1/ffi-required-captures.md) - moq-ffi and its generated bindings make `captures` a required list, as #7266 always sets it - [HLS export follows a resolution change](/quest/m1/hls-reinit-same-codec.md) - a decoder-identity change under the same codec string starts a new init and segment tag -- [The last AAC segment advertises its full duration](/quest/m1/hls-final-aac-segment.md) - a TS import's final audio segment's EXTINF matches what decodes - [A JS reader finishes after a clean close](/quest/m1/js-close-range-finish.md) - a range ending below the cache delivers what's held and then ends - [fMP4 decode times keep increasing](/quest/m1/fmp4-bframe-decode-time.md) - fragments shorter than a GOP of B-frame video never step `tfdt` backwards - [A JS relay floors an unresolved copy at its newest group](/quest/m1/js-early-latest.md) - lite-01..05 subscribes without a start don't replay the cache from group 0 diff --git a/quest/m1/hls-conformance.md b/quest/m1/hls-conformance.md index b0d21709e1a..72a06a67c69 100644 --- a/quest/m1/hls-conformance.md +++ b/quest/m1/hls-conformance.md @@ -36,7 +36,6 @@ with both checks intact. ## Required - [HLS export follows a resolution change](/quest/m1/hls-reinit-same-codec.md) - the conformance test's same-codec switch fails until it lands -- [The last AAC segment advertises its full duration](/quest/m1/hls-final-aac-segment.md) - the conformance test's audio check fails until it lands ## Related diff --git a/quest/m1/hls-final-aac-segment.md b/quest/m1/hls-final-aac-segment.md deleted file mode 100644 index b4143c10bc9..00000000000 --- a/quest/m1/hls-final-aac-segment.md +++ /dev/null @@ -1,25 +0,0 @@ -# [S] The last AAC segment after a TS import advertises its full duration - -## Goal - -After an MPEG-TS import ends, the final AAC segment's `EXTINF` and DASH `S@d` match what decodes, as they already do for the plain producer path. - -## Plan - -Found by the conformance test in [moq-dev/moq#7387](https://github.com/moq-dev/moq/pull/7387): the last audio segment advertises 1.365 s but 1.387 s decodes, one AAC frame short. The plain producer path gets it right, so the gap is somewhere in the TS import's end handling (likely the last frame's duration, which the importer infers from the next timestamp and has none for at the end). - -Decided 2026-10-30 (maintainer, follow-up planning after the /quest-afk run). Find the root cause before changing anything; fix it at the source rather than padding the advertised duration. The conformance test's audio check is the regression test. - -Implementation checkpoint 2026-10-31 (GPT-6.1 Sol): the TS importer cuts every AAC frame into its own group, so the container producer clears its previous timestamp before it can measure a cadence. `cut(None)` reports only that frame's start to the HLS recorder. Pass the next PTS, already computed from the ADTS frame's 1024 samples, as the group's endpoint instead. No advertised-duration padding or codec API change is needed. - -The existing split-frame EOF test now checks the final HLS stop record. Before the fix it reads 1021 ms instead of the two frames' 1042 ms endpoint; with the fix it passes. - -The existing conformance test from [moq-dev/moq#7387](https://github.com/moq-dev/moq/pull/7387) was run locally using a temporary overlay adapted to the checkout's mp4-atom API. All 13 AAC segments' HLS and DASH durations pass its 2.5 ms tolerance. The final segment advertises 1.387 s and decodes 1.386667 s. The whole test still fails on 13 video decoder-identity/recording findings owned by the related quest; its assertions were kept intact. No conformance changes are included here. - -Remaining before completion: finish the required full checks and other-vendor review after host blockers clear. `quest gate just ci` stayed queued for host capacity and was stopped at handoff. `quest gate just test interop --all` passed its nine protocol tests, then failed to launch the media matrix's Cargo build with mbx's `Argument list too long (os error 7)`. `quest review --base origin/main --json` failed because Claude's weekly limit resets November 2 at 02:00 America/Los_Angeles. No review verdict was obtained, so the PR remains draft and this quest remains open. The launcher and harness hooks were left untouched. - -Public API: none. Wire: none. - -## Related - -- [HLS and DASH segment conformance](/quest/m1/hls-conformance.md) - the test that found it, which waits on this From cc017cab5eb67012351dd1d4ec973c7b7f5e9bba Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Sat, 31 Oct 2026 12:51:27 -0700 Subject: [PATCH 6/6] test(mux): keep read_audio_frames' doc comment on its function Co-Authored-By: Claude Opus 5.5 --- rs/moq-mux/src/container/ts/import.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rs/moq-mux/src/container/ts/import.rs b/rs/moq-mux/src/container/ts/import.rs index 471375a2683..3547ee36de1 100644 --- a/rs/moq-mux/src/container/ts/import.rs +++ b/rs/moq-mux/src/container/ts/import.rs @@ -6028,7 +6028,6 @@ pub(super) mod test { ); } - /// Read every retained frame of the single audio rendition in `catalog`. /// Where the only audio rendition's HLS records end, once the catalog finishes. async fn hls_audio_end( consumer: &moq_net::broadcast::Consumer, @@ -6049,6 +6048,7 @@ pub(super) mod test { end } + /// Read every retained frame of the single audio rendition in `catalog`. async fn read_audio_frames( consumer: &moq_net::broadcast::Consumer, catalog: &crate::catalog::Producer,