Repository navigation
fix(video): clamp corrupt live remux PTS/DTS pairs - #554
Merged
Merged
Conversation
A live capture that jumps timeline mid-file (for example across a Twitch ad break) leaves the first two post-jump video packets with the new PTS and a DTS synthesised from the pre-jump reorder buffer. Their difference overflows movenc's signed 32-bit check, so the live remux fails at the trailer with "pts/dts pair unsupported". Run setts as an input BSF on video remuxes. It leaves normal packets alone and resets only pairs whose difference exceeds ten minutes at the 90 kHz MPEG-TS timebase, before the interleaver reaches the muxer.
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.
What
Live recordings that hit a timeline discontinuity (for example a Twitch ad break) failed at finalize with:
Why
At the ad-to-content jump, the first two post-jump video packets carry the new PTS but no PES DTS. FFmpeg synthesises DTS from the pre-jump reorder buffer, leaving a PTS/DTS difference of about 5.28e9. movenc rejects any pair that does not fit a signed 32-bit delta. FFmpeg CLI discontinuity correction only starts at the third post-jump packet, so those two survive and abort the remux.
Fix
Add a
settsinput BSF for video remuxes. It is a no-op for normal packets and resets only pairs whose difference exceeds ten minutes at the 90 kHz MPEG-TS timebase, after FFmpeg discontinuity correction and before the interleaver. Audio-only remuxes skip it. A regression test pins the input-scoped placement and the audio-only exclusion.Reproduced with a 30 s capture and the Flatpak FFmpeg 8.1.3: the exact failing argv now exits 0 with a 43.5 s MP4 whose A/V stay aligned across the seam. CI is the verification for the Rust change.