FFmpeg Speed Up Video and Keep Audio Synced

Changing the speed of a video file using FFmpeg requires adjusting both the video frames and the audio track simultaneously to prevent synchronization issues. This article provides the exact commands and filter configurations needed to accelerate your video while keeping the audio perfectly in sync, whether you are doubling the speed or applying a custom speed multiplier.

The Basic Command for 2x Speed

To speed up a video, FFmpeg uses the setpts video filter to manipulate presentation timestamps and the atempo audio filter to adjust the audio speed.

To double the speed (2x) of a video and keep the audio synced, use the following command:

ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=0.5*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" output.mp4

How It Works:


Customizing the Speed Multiplier

If you want to speed up your video by a factor other than 2, you must calculate the correct values for both the video and audio filters.

The formula for the video filter is 1 / Speed Multiplier. The formula for the audio filter is simply the Speed Multiplier itself.

Example: 1.5x Speed

ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=0.67*PTS[v];[0:a]atempo=1.5[a]" -map "[v]" -map "[a]" output.mp4

Speeding Up Beyond 2x Speed

The atempo audio filter in FFmpeg has a limitation: it only accepts values between 0.5 and 2.0. If you want to speed up your video by more than double, you must chain multiple atempo filters together.

Example: 4x Speed

ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=0.25*PTS[v];[0:a]atempo=2.0,atempo=2.0[a]" -map "[v]" -map "[a]" output.mp4

Example: 8x Speed

ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=0.125*PTS[v];[0:a]atempo=2.0,atempo=2.0,atempo=2.0[a]" -map "[v]" -map "[a]" output.mp4

Optimizing the Process (Without Re-encoding Audio)

If you do not care about keeping the audio track and want a faster render process, you can discard the audio entirely. This allows FFmpeg to process the video much quicker since it does not have to recalculate audio waveforms:

ffmpeg -i input.mp4 -an -filter:v "setpts=0.5*PTS" output.mp4

(The -an flag disables audio entirely).