Skip to content

fix(mux): preserve Opus timing in fMP4 exports (backport #7118) - #7273

Merged
kixelated merged 1 commit into
releasefrom
backport/opus-edit-list
Oct 30, 2026
Merged

kixelated merged 1 commit into
releasefrom
backport/opus-edit-list

Conversation

@kixelated

Copy link
Copy Markdown
Collaborator

Problem

The released moq export fmp4 presents Opus one pre-skip late (6.5 ms at the usual 312 samples) in any MP4 reader. Hang places every decoded Opus sample one pre-skip before its packet timestamp, but the exporter drops every edit list and dOps alone does not express that presentation shift. moq-dev/moq#7118 fixed this on main. On release it also fails the 12 stable wire-compat cells where a current publisher feeds a released Rust reader (moq-dev/moq#7061).

Approach

Port the encode_init half of moq-dev/moq#7118. When the init is assembled, after track timescales settle, an Opus track with nonzero pre-skip gets one edit: media_time is the pre-skip in the output media timescale, and the zero segment duration follows the live convention. This covers both synthesized and source CMAF tracks. extract_init still drops source edits.

It does not cherry-pick: release has no edit-list import (container/fmp4/edit.rs), and its exporter is older. So the comments are rewritten for release, and the test asserts the emitted elst directly instead of round-tripping through main's Edit. The test covers zero and maximum pre-skip, 48 kHz and microsecond scales, synthesized and source CMAF inits (with the source edit replaced), and a non-Opus track that keeps no edit.

release's importer ignores source edits, so a release round trip of an FFmpeg Opus MP4 now writes back the same edit it read.

Impact

  • Public API: none. Only pub(crate) encode_init changes.
  • Wire: none.
  • fMP4 output: Opus tracks with nonzero pre-skip gain the priming edit. Zero-pre-skip tracks and other codecs are unchanged.
  • Versions: none hand-picked. release-plz bumps moq-mux and its dependents, including moq-cli, in its release PR.

Alternatives

Waiting for the next cut from main would leave the released exporter wrong and the wire-compat pins stale until then.

Validation

  • cargo test -p moq-mux --lib: 1009 passed, including the two new tests.
  • just ci check origin/release and just ci test origin/release (Nix dev shell): passed.

Follow-ups

After this publishes in a patch moq-cli, moq-dev/moq#7061 reruns the full wire-compat remeasurement. No new quests.

(Written by Claude Opus 5.5)

🤖 Generated with Claude Code

Hang places every decoded Opus sample one pre-skip before its packet
timestamp, but the fMP4 exporter dropped every edit list, so an MP4
reader presented Opus one pre-skip late. Rebuild the Opus priming edit
when the init is assembled, after the output timescales are settled.

Adapted to release's exporter, which has no edit-list import.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T04:30:25.670082Z 598f29e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@kixelated kixelated left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Automated review by review (OpenAI)

Reviewed commit: 598f29e42261449dbaf4f1b8857e2ed908bbf0ed against the release base ffa2ff0edaf16d22504bc81c878abfc8c9d18049.

No actionable bugs found. The production change matches the Opus edit-generation portion of #7118: it converts pre-skip using the output media timescale at final init assembly, after either synthesized or extracted tracks are available. Source edits remain stripped, zero pre-skip produces no edit, and non-Opus behavior is unchanged. The widened arithmetic safely accommodates the input field ranges.

Direction: a narrow exporter-only backport is preferable to pulling the newer importer/edit machinery into this release. The tests inspect the emitted edit directly and cover both init paths, zero/max pre-skip, two timescales and a non-Opus control.

Verification limits: GitHub-only static review with an independent pass. I did not run tests, FFmpeg/player playback or wire-compat measurements; author-reported passes were not reproduced. This review does not establish that every released-reader compatibility cell now passes.

@kixelated

Copy link
Copy Markdown
Collaborator Author

Landing as a merge commit into release. Summary: ports the Opus priming edit from moq-dev/moq#7118 into release's encode_init, with a release-specific test. No public API or wire change, and no versions are hand-picked: release-plz bumps moq-mux and moq-cli. Reviews: Codex 👍 and an automated review with no findings. All 20 checks passed.

(Written by Claude Opus 5.5)

@kixelated
kixelated merged commit 6da7efd into release Oct 30, 2026
20 checks passed
@kixelated
kixelated deleted the backport/opus-edit-list branch October 30, 2026 05:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant