Skip to content

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

Merged
kixelated merged 1 commit into
mainfrom
codex/fmp4-opus-priming
Oct 29, 2026
Merged

kixelated merged 1 commit into
mainfrom
codex/fmp4-opus-priming

Conversation

@kixelated

@kixelated kixelated commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

An Opus fMP4 export presents decoded samples one pre-skip late. The stable current/current and released/released Rust controls in moq-dev/moq#7061 both fail the unchanged tone check by 321us with a 312-sample pre-skip. Deleting only the source MP4 edit list reproduces that exact error; retaining it passes.

Hang timestamps place every decoded Opus sample one pre-skip before its packet timestamp. Import applies source edits to that timeline. Export drops those source edits, keeps dOps.pre_skip, and writes the normalized timestamps into tfdt; dOps alone does not express the inverse presentation shift to an MP4 reader.

Approach

At final fMP4 init assembly, emit an Opus-only edit starting at the pre-skip converted to the output media timescale. Its zero segment duration follows the existing live implicit-duration convention. Do this after track timescales settle, for both synthesized and source CMAF tracks. Keep source-edit stripping and frame timestamps unchanged.

Impact

  • Public API: none.
  • Hang wire: none.
  • fMP4 output: an Opus track with nonzero pre-skip gains the edit that presents decoded samples at the Hang timestamps. Zero-pre-skip tracks and other codecs keep their existing layout.

Alternatives

Shifting unsigned packet timestamps cannot represent the priming before a stream starting at zero. Adjusting the tone checker or normalizing FFmpeg output would conceal an actual export defect.

Validation

  • Focused timestamp-contract test fails before the source fix and passes after it. It covers zero and maximum pre-skip, 48 kHz and microsecond track scales, synthesized and source CMAF inits, and inverse import timing.
  • quest gate just ci: passed in 445s, including 4,140 Rust tests and the selected feature, boundary, and metadata checks.
  • git diff --check: passed.
  • Full gated just test interop --all: passed, all 180 media, authorization, finished-media, FETCH, and tail checks.
  • Actual fixed/current lite-06 control: the fixed CLI's export fmp4 decoded by FFmpeg with -copyts passes the unchanged tone/phase assertion and its swapped-tone negative control. The decode-command repair is tracked separately in moq-dev/moq#7061.
  • Exact-byte control: emitted MP4 with -copyts gives first kept PTS 0, next 13500us, and phase errors +3us/+1us. Removing only edts from those exact bytes gives PTS 6500/20000us and fails at +321us. Movie/track/edit duration and atom-order probes did not fix the old decode command: FFmpeg's default timestamp sanitization caused that separate driver error.

Follow-ups

Recommend evaluating a release backport after this fix lands. Exact published moq-cli 0.14.9/moq-relay 0.17.9 still fail their stable control with -copyts, now at +781us; that complete cause remains unverified. moq-dev/moq#7061 needs the released controls rerun after a corrected CLI is published, followed by a full wire remeasurement. No release, merge, or compatibility-policy change is made here. No new quests created.

(Written by GPT-6)

Co-Authored-By: GPT-6 <noreply@openai.com>
@kixelated
kixelated marked this pull request as ready for review October 28, 2026 17:27
@coderabbitai

coderabbitai Bot commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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 36 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5e674d37-4b3f-4beb-93d2-43aa497b2554
Commits

Reviewing files that changed from the base of the PR and between c3543bf and 313b59e.

Files selected for processing: 2
  • rs/moq-mux/src/container/fmp4/export.rs
  • rs/moq-mux/src/container/fmp4/mod.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 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-28T17:28:46.953940Z 313b59e Draft marked ready
ℹ️ 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: 313b59e

No actionable bugs found. Adding the Opus-only edit in final init assembly is a focused correction: both synthesized and source-CMAF tracks use the settled media timescale, source edits remain stripped, and the mapping agrees with the importer's pre-skip adjustment. This is simpler than changing packet timestamps and avoids changing the Hang wire/API. The regression covers zero/maximum pre-skip, both timescales and init paths, and the inverse import mapping.

Verification: static inspection of the diff, init/export/muxer paths and edit handling only; I did not run Rust tests, FFmpeg controls or browser playback, and have not independently verified the PR's reported validation.

@kixelated

Copy link
Copy Markdown
Collaborator Author

Merge summary for head 313b59e:

  • No changes made in the merge pass: no conflicts, all 11 checks passing, quest check against origin/main clean.
  • Reviews on this head: Codex (thumbs up, no findings) and the OpenAI automated review (no actionable bugs). CodeRabbit was rate-limited, so it doesn't count.
  • No decisions left open. A release backport is still a separate follow-up decision, as the PR body suggests, and is not part of this merge.

(Written by Claude Opus 5.5)

@kixelated
kixelated added this pull request to the merge queue Oct 29, 2026
Merged via the queue into main with commit dd67df8 Oct 29, 2026
11 checks passed
@kixelated
kixelated deleted the codex/fmp4-opus-priming branch October 29, 2026 08:59
kixelated added a commit that referenced this pull request Oct 30, 2026
fix(mux): preserve Opus timing in fMP4 exports (backport #7118)
This was referenced Oct 30, 2026
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