Imajes / Files
FFmpeg Patch Fixes MP4 Subtitle Desync That Broke Popular Editing Workflows
16 October 2026
FFmpeg's subtitle pipeline has undergone a significant overhaul in 2022 to address long-standing issues with subtitle timing and desync problems that could severely disrupt editing and playback workflows, particularly when merging segmented MP4 files.
2022 Subtitle Filtering Redesign Paves the Way
The foundation for the fixes came in a sweeping October 2022 patch series that refactored and modernized FFmpeg's subtitle handling. "The goal is to make subtitle filtering more robust, flexible and capable," the lead developer wrote. "The subtitle filtering will be split across multiple filters, which give multiple prioritization modes and more robust timing control." The advanced timing and prioritization abilities paved the way to resolve some tricky real-world desync problems.
Subtitle Timing, Repeated Frames, and subfeed
The 2022 work brought a number of key architectural changes that bear directly on subtitle handling:
- Refactoring: Subtitle timing was added directly to AVFrame to avoid precision loss.
- Repeat Flag: A repeat_sub field was added to specify how many times a subtitle should be repeated.
- Arbitration: The subfeed filter has replaced the old heartbeat logic to arbitrate between subtitle streams.
The progress spanned more than just the core subtitle handling - asynchronous repeated subtitle frames were also addressed. "The current repeat option leads to out of sync subtitles if the next frame is late," a developer pitched. The solution was to store the repetition in the main subtitle queue and try to resolve it in the conversion process.
Segment Merge Issue Exposes Gray Edge Cases
Tackling subtle bugs in segment merging can be a tricky business, as highlighted by FFmpeg Trac ticket #10525, titled "Video/audio desync between segments in MPV and in VLC is delay between segments and missing subtitles." The summary states that the problem appears when an .mp4 file containing subtitles is split into smaller segments and merged back together.
Ticket #10525 illustrates a granular timing pathology: the issue arises specifically in the exact window while the subtitle is playing. VLC and MPV exhibit the same symptoms, indicating it's not a player-specific bug. A workaround identified was to remove subtitles altogether, showing the problem is rooted in the subtitle syncing path.
Desync Risk When Fragmenting HFR Content
MP4 fragmentation handling can be a flashpoint for subtle audio/video desync, particularly for higher frame rate (HFR) video. A 2014 FFmpeg patch message noted that "In fragmented mp4, if the timestamps are stationary, no cues are sent in the initialization segment, so it is not possible to establish a timebase and it doesn't work. And of course fragmented mp4 changes the timestamps to be relative to the start of the fragment, not to the global start, so it becomes completely wrong when the fragment start time is not subsecond." Unchecked, the fragmented timestamps could cause major desync and usability breakdowns, rendering the files impossible to reliably use in streaming workflows like HLS. The warning shows the importance of re-establishing timing context across segment boundaries for subtitle sync too.
Robustness & Buffer Handling Remain
Fortunately, commentary on a 2023 robustness patch may hint at further efforts on the horizon: "I think the current implementation has a serious flaw - it is sensitive to malformed or misaligned source content and will hang or produce overwhelming amounts of 'frame is going to arrive soon' messages."
The warning suggests some glue code between sync, repeat behavior, and frame integrity may be needed. It's clear that ensuring rock-solid subtitle sync between brittle segment edits remains a work in progress.
Subtitle Sync Stability for Editors & Content Providers
When refining content with subtitle overlays, an editor's content workflow hinges on the reliability of the subtitle sync between the source, intermediate, and final versions. The 2022 redesign aims to significantly improve asynchronous subtitle handling robustness and consistency across cut, splice and reassemble workflows.
For content providers, fragility at the merging and assembly stage of segmented subtitled streams could expose timing errors that would have to be handled manually in post-production. While commercial video tools have proprietary solutions, the FFmpeg patches aim to ensure smooth subtitle editing & segment merge experiences can be had from open-source, community-maintained software on the front line of media workflows.