Two Kinds of Audio Sync Problems
The audio is either behind the video or ahead of it. For every method, including -async, see Fix Audio Sync.
| Pattern | Symptom | Typical cause |
|---|---|---|
| Audio is behind the video | Sound arrives after the mouth moves | Microphone latency, recording settings |
| Audio is ahead of the video | Sound arrives before the mouth moves | Capture-device latency mismatch |
Method 1: adelay — Add Delay to the Audio
Use adelay when the audio is ahead of the video and has to start later. The same filter is useful when adding background music, to set when a sound effect or narration starts.
Add 500 ms of delay to stereo audio
ffmpeg -i input.mp4 \
-af "adelay=500|500" \
-c:v copy \
output.mp4
500|500 delays the left and the right channel of a stereo track by 500 ms each.
Mono audio
ffmpeg -i input.mp3 \
-af "adelay=300" \
output.mp3
adelay Parameter Details
adelay=delays[|delays...]
- Give one delay per channel, separated by
| - The unit is milliseconds (ms)
0means no delay
# Stereo: different delay per channel
ffmpeg -i input.mp4 -af "adelay=200|400" -c:v copy output.mp4
# 5.1 surround (6 channels)
ffmpeg -i input.mp4 -af "adelay=300|300|300|300|300|300" -c:v copy output.mp4
Method 2: -itsoffset — Shift Input Timestamps
-itsoffset shifts the timestamps of an input file. Open the same file twice and apply the offset to only one of them, and you can move the video or the audio on its own.
Delay audio by 0.5 s (audio is ahead of the video)
ffmpeg -i input.mp4 -itsoffset 0.5 -i input.mp4 \
-map 0:v -map 1:a \
-c:v copy -c:a copy \
output.mp4
0:v: video from the first input (original timestamps)1:a: audio from the second input (shifted by 0.5 s)
Advance audio by 0.5 s (audio is behind the video)
ffmpeg -itsoffset 0.5 -i input.mp4 -i input.mp4 \
-map 0:v -map 1:a \
-c:v copy -c:a copy \
output.mp4
This time itsoffset applies to the video (0:v). Starting the video 0.5 s later has the same effect as moving the audio 0.5 s earlier.
Method 3: Trim the Start of the Audio with atrim
If the audio is behind the video, you can also cut the start of the audio so the two line up.
ffmpeg -i input.mp4 \
-vf "setpts=PTS-STARTPTS" \
-af "atrim=start=0.3,asetpts=PTS-STARTPTS" \
-c:v libx264 \
output.mp4
atrim=start=0.3 removes the first 0.3 seconds of audio, so the rest of the audio moves earlier by that amount.
Check Audio Delay with ffprobe
ffprobe -v quiet -print_format json -show_streams input.mp4 2>&1 | grep "start_time"
The difference between the video and audio start_time values gives a rough idea of the delay. If the offset is in the recording itself (for example, capture-device latency), the start_time values are the same, so check by playing the file.
Start Timestamps at Zero (-avoid_negative_ts)
When the video and audio start_time values differ, this command moves every stream by the same amount so that the first timestamp is 0:
ffmpeg -i input.mp4 -c:v copy -c:a copy -avoid_negative_ts make_zero output.mp4
The gap between the video and audio start_time stays the same, so this does not fix the sync. To move one stream by that gap, use -itsoffset (Method 2).
Practical Workflow
Step 1: Confirm the drift
Play the file in a media player such as VLC and estimate the offset in seconds.
Step 2: Decide the direction
- Mouth moves first, sound arrives late → audio is behind → delay the video with
-itsoffset(notadelay, which can only delay audio) - Sound arrives first, mouth moves later → audio is ahead → delay the audio with
adelay
Step 3: Run the command
# Example: audio is 300 ms ahead (delay the audio with adelay)
ffmpeg -i input.mp4 -af "adelay=300|300" -c:v copy output.mp4
Anti-Pattern
Bad: passing a single channel value to adelay on a stereo file
ffmpeg -i input.mp4 -af "adelay=500" -c:v copy output.mp4
With a single value (adelay=500) on a stereo file, only the left channel is delayed and the right channel stays where it was. Give one value per channel.
Notes
adelaycan only add delay to audio. It cannot move audio earlier.- To move audio earlier, use
-itsoffsetoratrim. -c:a copyavoids re-encoding the audio (no quality loss), butadelaychanges the samples, so it needs re-encoding.
Related Filters
Frequently Asked Questions
Why does audio drift later in long videos?
It can happen when the recorder’s video and audio clocks run at slightly different speeds, or when software that assumes CFR (constant frame rate) handles a VFR (variable frame rate) video. A VFR video with correct timestamps does not start to drift just because you stream-copy it. If the drift appears in such software, converting to CFR first can fix it.
What does -itsoffset do?
It shifts the timestamps of every stream in the input file that follows it. -itsoffset 0.5 -i audio.aac delays that audio by 500 ms before it is written to the output. Use a negative value to move it earlier.
How can I detect the offset automatically?
The axcorrelate filter only outputs the correlation of two audio streams as an audio signal (values from -1 to 1). It does not print the lag. Measure the offset by playing the file, as in the workflow above.
Does this fix Bluetooth-induced lag?
No. Bluetooth delay is added during playback and differs from device to device. Fix it in the player or device settings, for example with an audio delay or lip-sync setting. A file shifted to match one device goes out of sync on others.
Will trimming change the offset I should use?
No. A constant offset stays the same when you cut the video and audio at the same point. With -c copy, though, the video can only start at a keyframe, so re-encode when you trim if you need an exact cut.