Sync a Specific Subtitle Track in MKV Using FFmpeg

Adjusting the timing of a single subtitle track in a multi-track MKV file without altering the other video, audio, or subtitle streams can be done efficiently using FFmpeg. This guide explains how to use the -itsoffset option and stream mapping to delay or advance a specific subtitle track while keeping all other tracks in their original state, all without re-encoding.

The Logic Behind the Command

FFmpeg applies the -itsoffset option to the input file that immediately follows it in the command line. To adjust only one subtitle track, you must load the MKV file twice: 1. First Input (unsynced): Used for the video, audio, and any other subtitle tracks that do not need adjustment. 2. Second Input (offset): Preceded by -itsoffset to shift the timing, used solely to extract the target subtitle track.

By mapping the unaffected tracks from the first input and the offset subtitle track from the second input, you merge them into a single, corrected output file.

Step-by-Step Command

To delay or advance a specific subtitle track, use the following command structure:

ffmpeg -i input.mkv -itsoffset 3.5 -i input.mkv -map 0:v -map 0:a -map 0:s:0 -map 1:s:1 -c copy output.mkv

Explaining the Command Parameters

How to Identify Your Subtitle Stream Indices

To ensure you map the correct streams, first check the stream layout of your MKV file using ffprobe:

ffprobe input.mkv

Look for the subtitle streams in the output. For example: * Stream #0:2: Subtitle: subrip (This is the first subtitle track, referenced as s:0) * Stream #0:3: Subtitle: subrip (This is the second subtitle track, referenced as s:1)

Match these indices to your -map options to ensure only the desired track receives the time offset.