Adjust Subtitle Timing Offset with FFmpeg
This article explains how to quickly and precisely synchronize out-of-sync subtitles with a video using the powerful command-line tool FFmpeg. You will learn how to shift subtitle tracks forward or backward, whether you are outputting a newly synchronized standalone subtitle file or merging the adjusted subtitles directly into a video container.
To adjust subtitle timing in FFmpeg, you use the
-itsoffset option. This option delays the input file that
immediately follows it in the command. The offset value is specified in
seconds (e.g., 3.5) or in hh:mm:ss.mmm
format.
Delay Subtitles (Make Subtitles Appear Later)
If your subtitles are appearing too early and you need to delay them by a specific duration (for example, 5 seconds), apply the offset directly to the subtitle input file.
To output a new, synchronized subtitle file:
ffmpeg -itsoffset 5 -i input.srt -c copy output.srtTo merge the delayed subtitles directly into a video file:
ffmpeg -i video.mp4 -itsoffset 5 -i input.srt -c:v copy -c:a copy -c:s srt output.mkvAdvance Subtitles (Make Subtitles Appear Earlier)
If your subtitles are appearing too late and you need them to appear earlier, you can use a negative offset.
To output a corrected standalone subtitle file with a negative offset:
ffmpeg -itsoffset -5 -i input.srt -c copy output.srtAlternatively, if you are muxing the subtitles directly into a video, you can achieve the same relative sync correction by delaying the video stream instead of the subtitle stream:
ffmpeg -itsoffset 5 -i video.mp4 -i input.srt -c:v copy -c:a copy -c:s srt output.mkv(In this case, delaying the video by 5 seconds relative to the subtitles effectively makes the subtitles appear 5 seconds earlier).
Key Parameter Explanations
-itsoffset <time>: Sets the input time offset.-i: Specifies the input files (video or subtitle).-c copy(or-c:v copy -c:a copy -c:s copy): Copies the video, audio, and subtitle streams directly without re-encoding, which preserves the original quality and completes the process almost instantly.