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.mp4

In this command:

  • -i input.mp4 loads the original file as input 0.
  • -itsoffset 1.25 -i input.mp4 delays the second instance (input 1) by 1.25 seconds.
  • -map 0:a takes the audio stream from the original, unshifted input 0.
  • -map 1:v takes the video stream from the delayed input 1.
  • -c copy copies 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.mp4

This shifts the video stream forward by 0.75 seconds relative to the audio.

Determining the Correct Offset

To find the precise offset needed:

  1. Open the original video in a media player that supports manual sync adjustments (such as VLC).
  2. Use the shortcut keys (J and K in VLC) to adjust audio synchronization in real time until the voices match the video.
  3. Note the exact millisecond value that resolved the issue.
  4. 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.