Repository navigation
feat(mux): import timed SRT and WebVTT captions #5281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
152170b
chore(quest): claim caption import
kixelated 73ed7cc
feat(mux): import Matroska text and skip unknown MP4 subtitles
kixelated 07c29e6
chore: merge main into caption import
kixelated 10f4d7f
fix(mux): preserve subtitle timing across file imports
kixelated a31ab21
fix(mux): keep subtitle duration handling scoped to text
kixelated 055926d
Merge origin/main into quest/m1/captions-import
kixelated f744a43
fix(mux): satisfy clippy and rustfmt in the merged subtitle branch
kixelated 8bffb3c
Merge origin/main into quest/m1/captions-import
kixelated 4ab433a
fix(mux): address WebVTT import review findings
kixelated 7109b4e
fix(mux): bound WebVTT fragments by their decode end and escape SRT a…
kixelated 2531156
fix(mux): refuse subtitle CodecState updates instead of ignoring them
kixelated 879f968
Merge remote-tracking branch 'origin/main' into worktree-agent-ad5e0d…
kixelated 92c2c42
quest(m1): defer fMP4 WebVTT ctim and vtta support
kixelated 00cdd4e
Merge remote-tracking branch 'origin/main' into worktree-agent-ad5e0d…
kixelated 26a2fcf
fix(mux): refuse unanchored inline WebVTT timestamps and keep sub-ms …
kixelated File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # [M] TTML caption import | ||
|
|
||
| ## Goal | ||
|
|
||
| Importing an fMP4 `stpp` track within a supported TTML/IMSC profile yields a `ttml` text | ||
| rendition whose cues stay on the shared media clock. Today those XML tracks are | ||
| skipped with a warning while SRT and WebVTT import as `vtt`. | ||
|
|
||
| ## Plan | ||
|
|
||
| Copying XML bytes is not enough. MP4 `stpp` names an XML namespace, which is not | ||
| necessarily TTML, and the importer shifts the source clock, so every TTML time | ||
| expression must be rewritten onto the catalog clock. | ||
|
|
||
| - Support a bounded TTML/IMSC timing profile: validate the namespace and refuse | ||
| anything outside the profile instead of relabelling arbitrary XML as TTML. | ||
| - Convert every time expression, including nested `begin`/`end`/`dur` and | ||
| `ttp:timeBase` variants the profile admits, after the clock shift. | ||
| - Keep skipping XML tracks the profile does not cover, one track at a time. | ||
|
|
||
| Matroska has no registered TTML codec ID (the old `S_TEXT/TTML` claim was | ||
| removed), so confirm a real mapping before adding one. | ||
|
|
||
| Cover a namespace mismatch, nested timing, and a shifted source clock. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| # [S] fMP4 WebVTT ctim and vtta | ||
|
|
||
| ## Goal | ||
|
|
||
| An fMP4 `wvtt` sample whose cue carries a `ctim` CueTimeBox, or which | ||
| interleaves `vtta` additional-text boxes, imports as WebVTT text instead of | ||
| failing the import. Today both are refused with `InvalidSubtitle`, as is any | ||
| inline timestamp in a cue payload. | ||
|
|
||
| ## Plan | ||
|
|
||
| Both boxes are defined by ISO/IEC 14496-30 §6.6. | ||
|
|
||
| - `ctim` records the cue's start on the original WebVTT timeline. Rebase each | ||
| inline `<hh:mm:ss.ttt>` timestamp in the payload by `inline - ctim` onto the | ||
| sample start, reusing the Matroska rebase in `rs/moq-mux/src/container/text.rs`. | ||
| Refuse inline timestamps that arrive without `ctim`, since their origin is | ||
| unknown. | ||
| - `vtta` holds text between cues (such as `NOTE` blocks). Serialize it in sample | ||
| order, validated like the Matroska cue-comment path. | ||
|
|
||
| Cover an inline timestamp with `ctim` on a shifted clock, one without `ctim`, | ||
| and a sample mixing `vtta` and `vttc`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
vttCcontains the validKind: captionsmetadata header, this constructor still leavesroleatTextConfig::new'sSubtitledefault. The player uses that catalog field to distinguish captions from subtitles, so imported closed captions lose their accessibility semantics and appear as ordinary subtitles. ISOBMFF WebVTT explicitly mapsKind: captionsandKind: subtitlesto the corresponding track kinds; parse this header when creating the config. W3C in-band track mappingUseful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 4ab433a. The WebVTT
Kindheader now maps toTextRole::Caption/Subtitle(other values are kept asUnknown), for both fMP4vttCand the Matroska CodecPrivate. Covered bywebvtt_kind_and_lone_cr_terminators.(Written by Claude Opus 5.5)