How to Sync Video and Audio in FFmpeg with -async

When muxing separate video and audio streams, synchronization issues can often occur, causing the audio to drift ahead of or lag behind the video. This article provides a straightforward guide on how to use FFmpeg’s -async option to align your audio stream with the video stream, ensuring perfect playback synchronization in your output file.

The Basic Muxing Command with -async

To combine a video file and an audio file while keeping them synchronized, use the following FFmpeg command structure:

ffmpeg -i input_video.mp4 -i input_audio.wav -c:v copy -c:a aac -async 1 output.mp4

How the Command Works

Understanding the -async Option

The -async parameter synchronizes the start of the audio stream with the video stream.

Modern Alternative: The aresample Filter

In newer versions of FFmpeg, the standalone -async option is deprecated in favor of the audio resampling filter. If you encounter issues with -async, you can achieve the exact same synchronization effect using the -af (audio filter) flag:

ffmpeg -i input_video.mp4 -i input_audio.wav -c:v copy -c:a aac -af aresample=async=1 output.mp4

This filter-based approach is highly robust and performs the same stream stretching, squeezing, or padding required to keep your media perfectly aligned.