Skip to content

fix(moq-mux): strip edit lists from the CMAF init#2383

Merged
kixelated merged 1 commit into
mainfrom
claude/strip-cmaf-edit-lists-main
Jul 18, 2026
Merged

fix(moq-mux): strip edit lists from the CMAF init#2383
kixelated merged 1 commit into
mainfrom
claude/strip-cmaf-edit-lists-main

Conversation

@kixelated

Copy link
Copy Markdown
Collaborator

Problem

The fMP4 exporter copies each source track's edit list (edts/elst) straight into the merged CMAF/HLS init (extract_init). Edit lists are redundant in CMAF -- timing is carried by tfdt and per-sample composition offsets -- and browsers apply them, so a source's initial empty edit (media_time = -1) becomes a real presentation offset.

In practice this showed up as a black screen on VOD/HLS playback in the browser: the applied edit shifted the video track off the audio track's timeline (here by ~2 days, because the empty edit's -1 was being mis-encoded to +2^32-1 upstream), so Media Source Extensions left the video source buffer empty at the playhead while audio played fine. Even with a correctly-encoded -1, an edit list in a fragmented CMAF init is an interop hazard best avoided.

Fix

Drop the edit list in extract_init so the CMAF/HLS init never carries one:

for mut trak in moov.trak {
    trak.tkhd.track_id = track_id;
    trak.edts = None;   // CMAF carries timing via tfdt + composition offsets
    traks.push(trak);
}

This is the only place a source edts enters the output (the synthesized-trak paths don't add one).

Test

extract_init_strips_edit_lists builds a source moov whose trak carries an edts/elst, runs it through extract_init, and asserts the resulting trak has no edts. Full moq-mux suite green.

Note

Blanket-stripping also drops any non-empty trim edit (media_time > 0, used to trim encoder-priming samples). For such sources the first few priming samples would play instead of being trimmed -- a minor start-of-clip artifact, never a black screen. If preserving real trims matters, this could be gated to empty edits only.

🤖 Generated with Claude Code

The fMP4 exporter copied each source track's edit list (edts/elst) into the
merged CMAF/HLS init. Edit lists are redundant in CMAF -- timing is carried by
tfdt and per-sample composition offsets -- and browsers mishandle them: an
empty-edit media_time gets applied as a real offset and shifts the track off
the others, leaving the video source buffer empty (a black screen) while audio
plays. Drop the edit list in extract_init so the init never carries one.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @kixelated, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 61f8c0e9-d6c0-4291-87c0-dc9303cfcd9f

📥 Commits

Reviewing files that changed from the base of the PR and between 112fa90 and 8c5c0b8.

📒 Files selected for processing (1)
  • rs/moq-mux/src/container/fmp4/export.rs

Walkthrough

CMAF init extraction now removes each track’s edts edit list while rewriting track IDs. A unit test adds an edts/elst structure to an input initialization segment, runs extract_init, and verifies that the resulting track has no edit list.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: stripping edit lists from the CMAF init.
Description check ✅ Passed The description directly explains the edit-list removal fix, its impact, and the added test.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch claude/strip-cmaf-edit-lists-main

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kixelated
kixelated enabled auto-merge (squash) July 18, 2026 02:44
@kixelated
kixelated merged commit 2be3a55 into main Jul 18, 2026
2 checks passed
@kixelated
kixelated deleted the claude/strip-cmaf-edit-lists-main branch July 18, 2026 03:01
@moq-bot moq-bot Bot mentioned this pull request Jul 17, 2026
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