Repository navigation
Take a source's subtitles from their own input (fixes #266) - #291
Merged
Merged
Conversation
An untrimmed Passthrough of a source with subtitles stored its sound up to ~38 s ahead of its picture in the file (MKV and MP4), and players dropped the sound in stretches; re-muxing fixed it. The subtitles shared input 1 with the sound: between cues the sparse subtitle stream is the one FFmpeg's scheduler waits for, so the source's sound ran ahead of the picture vspipe was still making and the muxer flushed it past max_interleave_delta. The subtitles now come from a second -i of the source with input 1's own seek, last of the inputs (subtitle_mapping), added only when the probe finds a subtitle stream; a failed probe keeps Matroska's old 1:s?. Through the worker: 22.7 s (MKV) / 23.3 s (MP4) ahead -> 0.10 s. Trimmed encodes were never affected (-shortest's sync queue). Report: docs/reports/issue-266-subtitle-interleave. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
StuartCameronCode
force-pushed
the
stuart/142-investigate-github-issue-266
branch
from
November 28, 2026 11:27
2ad9b5b to
372f69b
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #266.
Problem
When a source had subtitles, an untrimmed Passthrough encode into MKV or MP4 stored its sound far ahead of its picture in the file: about 38 s in the reported file. Players then dropped the sound in stretches, and a remux fixed it.
The cause: the subtitles were mapped from the same ffmpeg input as the sound. Between cues, the sparse subtitle stream is the stream FFmpeg's scheduler waits for, so the source's sound ran ahead of the picture vspipe was still making. Once the muxer's queue spanned
max_interleave_delta(10 s), it wrote the sound out ahead of the picture. Trimmed encodes were never affected, because-shortest's sync queue holds the streams together.Fix
pipeline_executor::subtitle_mappingis now the one place that decides the subtitle mapping. When the probe finds a subtitle stream, the encode takes the subtitles from a second-iof the source.1:s?copy and MP4/MOV maps none, as before.-max_interleave_delta 0was rejected: it fixes the layout but buffers the sound until the next cue (265 vs 83 MB for a 7.1 PCM minute).Tests
cargo test --lib(696) andfilter_integration_test(253) pass.integration_subtitle_interleave_test.dart, with the fixturesparse_subs.mkv(cues 34 s apart) and its generator. Sound ahead of picture in file order: before the fix, MKV 22.7 s and MP4 23.3 s, and the test fails. After the fix, 0.10 s. Both cues keep their times, including in a trimmed encode.Docs
Report
docs/reports/issue-266-subtitle-interleave, plus an ENGINEERING_NOTES entry, a row in the reports index and a CLAUDE.md rule.🤖 Generated with Claude Code