Skip to content

export ts drops about a fifth of a field-coded feed's pictures since #8638 #9081

Open

Description

@t0ms

Since #8638 (7d1bee79cb, groups addressed by their start), import ts --program 1 → relay → export ts --delay 2s on loopback loses video it used to carry, on our broadcast feed's content: 1080i25 H.264 coded as field pictures (DTS steps of 20 ms and 40 ms), MP2 and AC-3 audio. Still the case on main c19c723d90.

Build Pictures out in 37 s (video PES) MP2 PES out media skipped upstream lines
466f2f6c81 (#8638's parent) 1,038 258 0
7d1bee79cb (#8638) 829 258 33 on video (240–320 ms each, about one per group), ~2,900 on MP2 (24 ms each)

Bisected over cd560bde5e..5ae846326b with a test that replays a 50 s capture (tsp --realtime -P regulate --pcr-synchronous) into a fresh relay and counts the export's video PES, skipping any run whose export delivered less than 100 MB. On the live feed main delivers about 30 distinct pictures per second where cd560bde5e delivers 40.

Two observations that may help:

  • The audio is not lost. Every MP2 PES arrives on both builds, yet the export logs a 24 ms skip at almost every MP2 frame.
  • A progressive synthetic stream logs the same video skips with nothing missing. ffmpeg testsrc2 720p25, x264 GOP 25 with B-frames, MP2 or AAC: feat(moq-net)!: address groups by their start #8638 logs a skip at every video group (37 in 40 s) and, with MP2, at most audio frames, while its output has the same bytes and pictures as its parent's. So the skip decision fires at every group boundary. On this content it costs nothing; on field pictures it costs real pictures.

My guess is that a group's end is now reckoned from its start and the frames' durations, and that the reckoning falls short of the next group's start by one frame (a field, on this feed), which then reads as a hole. We can run any branch against the capture and the live feed.

(Written by Claude Opus 5.5)

Activity

  1. coderabbitai commented on Nov 18, 2026

    @coderabbitai
    Contributor
    🔗 Related PRs

    #6252 - fix(mux): give every TS PID a declared route [closed]
    #7981 - fix(mux)!: flag PCR discontinuities only when the clock jumps [merged]


    📝 Issue Planner

    Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

  2. t0ms commented on Nov 20, 2026

    @t0ms
    ContributorAuthor

    Still the case on main 60d6bd0f4b, after #9196 moved the container reader onto Ordered, and it is confined to moq-lite-06. Same replay as above (50 s of the field-coded capture, import ts --program 1 → loopback relay → export ts --delay 2s, 40 s):

    Build, version negotiated Video PES out MP2 PES out media skipped upstream on video
    cd560bde5e, moq-lite-06 1,542 / 1,538 272–275 0
    60d6bd0f4b, moq-lite-06 (the default) 1,211 / 1,211 275 34 a run
    60d6bd0f4b, --connect-version moq-lite-07-wip 1,552 275 0
    60d6bd0f4b, --connect-version moq-transport-22 1,552 275 0

    What is lost. Every missing PES is an open-GOP leading picture: decoded after its group's keyframe, presented before it. On this feed the keyframe presents 400 ms after it decodes, and all 7 or 14 leading pictures of every group go (331 of 331 missing).

    Why, as far as I can read it. On lite-06 the groups are keyed by their start and nothing declares the keys between two groups, so Consumer::poll_event_once marks the step unproven and judges it by pts_contiguous(self.presented_end, first), where first is the next group's first frame in decode order, its keyframe. TS frames carry no duration, so presented_end is the previous group's highest PTS. The leading pictures sit between the two, so the check fails by their span plus one picture (300–320 ms here), and lose() reports a gap. The TS export then does what it should after a real loss: queue arms recovery and trims the leading pictures below the keyframe (leading_floor), though their references were all delivered. On progressive closed-GOP content the shortfall is one picture: a skip is logged at every group and nothing is trimmed, which is the synthetic stream in the report. lite-07 names each group's Previous Start, which proves the step; moq-transport-22 does not fail either, though I have not traced why. The MP2 skip lines look like the same check without the codec durations that codec_durations_bridge_undeclared_runs_between_audio_groups gives Opus; they cost nothing, since audio has no leading pictures.

    A test that fails on main the same way:

    	/// Video groups addressed by their start, as a moq-lite-06 hop delivers them, with nothing
    	/// declared between them. The second is an open GOP: its leading pictures present between the
    	/// first group's last picture and its keyframe, so the two groups meet and nothing is lost.
    	#[tokio::test(start_paused = true)]
    	async fn an_open_gop_that_continues_the_previous_video_group_is_no_gap() {
    		let track = track_producer("gaps", hang::container::track_info(hang::catalog::PRIORITY.video));
    		let subscription = track.subscribe(
    			moq_net::track::Subscription::default().with_delay(Delay::default().with_max(Duration::from_secs(10))),
    		);
    		let mut reader = Consumer::new(subscription, Container::Legacy(crate::container::Kind::Video));
    		// 40 ms pictures in decode order, each group keyed by its keyframe's presentation time.
    		for (start, pictures) in [
    			(0, &[0, 120_000, 40_000, 80_000][..]),
    			(280_000, &[280_000, 160_000, 200_000, 240_000][..]),
    		] {
    			let mut group = track.create_group(moq_net::group::Info { start }).unwrap();
    			for &micros in pictures {
    				let frame = Frame {
    					timestamp: ts(micros),
    					payload: Bytes::from_static(&[0xDE, 0xAD]),
    					keyframe: micros == start,
    					duration: None,
    				};
    				Container::Legacy(crate::container::Kind::Video)
    					.write(&mut group, &[frame])
    					.unwrap();
    			}
    			group.finish().unwrap();
    		}
    		let _track = track.finish().unwrap();
    		assert_eq!(
    			items(&mut reader).await,
    			["0", "120000", "40000", "80000", "280000", "160000", "200000", "240000"]
    		);
    	}

    On main it reads "gap 120000+160000" before "280000".

    Which way would you want it fixed, if at all while lite-06 is the default? Two that I can see: judge the step against the next group's earliest presentation rather than its first frame, with a picture's duration from the importer or the codec as audio has; or, since lite-07 and moq-transport already prove the step, leave lite-06 as it is. We can run any branch against the capture and the live feed.

    (Written by Claude Opus 5.5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions