Fix Video Audio Sync with FFmpeg itsoffset
Audio and video synchronization issues often occur during recording,
editing, or transcoding, causing voices not to match mouth movements.
This guide explains how to correct this desynchronization directly using
FFmpeg's -itsoffset option to shift the video stream
relative to the audio. By passing the input file twice and applying
timestamp offsets without re-encoding, you can permanently realign your
media in seconds.
How the
-itsoffset Parameter Works
The -itsoffset flag alters the timestamps of the input
file that immediately follows it on the command line. To adjust only the
video stream, you must define the input file twice: once for the
untouched audio stream, and a second time—preceded by
-itsoffset—for the video stream. You then map the
synchronized streams together into a single output file.
Shifting the Video Stream
The offset value can be specified in seconds (e.g., 1.5)
or in timestamp format (HOURS:MM:SS.MILLISECONDS).
1. Delaying the Video (When Video Plays Too Early)
If the visual action happens before the corresponding sound, you need to delay the video stream. Use a positive offset:
ffmpeg -i input.mp4 -itsoffset 1.25 -i input.mp4 -map 0:a -map 1:v -c copy output.mp4In this command:
-i input.mp4loads the original file as input 0.-itsoffset 1.25 -i input.mp4delays the second instance (input 1) by 1.25 seconds.-map 0:atakes the audio stream from the original, unshifted input 0.-map 1:vtakes the video stream from the delayed input 1.-c copycopies both streams without re-encoding, ensuring fast processing and zero loss in quality.
2. Advancing the Video (When Video Plays Too Late)
If the audio plays before the visual action, you need to advance the video stream so it appears earlier. Use a negative offset:
ffmpeg -i input.mp4 -itsoffset -0.75 -i input.mp4 -map 0:a -map 1:v -c copy output.mp4This shifts the video stream forward by 0.75 seconds relative to the audio.
Determining the Correct Offset
To find the precise offset needed:
- Open the original video in a media player that supports manual sync adjustments (such as VLC).
- Use the shortcut keys (
JandKin VLC) to adjust audio synchronization in real time until the voices match the video. - Note the exact millisecond value that resolved the issue.
- Apply that value to the FFmpeg command. If the player required delaying the audio to fix the sync, apply that same value as a positive offset to the video stream in FFmpeg.