How to Use the Atempo Filter in FFmpeg
This article provides a quick overview and practical guide on how to
use the atempo audio filter in FFmpeg. You will learn the
basic syntax of the filter, how to speed up or slow down audio without
changing its pitch, and how to synchronize these audio changes with
video speed adjustments.
Understanding the Atempo Filter
The atempo filter in FFmpeg allows you to adjust the
playback speed of an audio stream while preserving its original pitch.
This prevents the “chipmunk effect” when speeding up audio or a deep,
distorted voice when slowing it down.
The filter accepts a single parameter: a multiplier for the speed. *
A value of 1.0 represents normal speed. * Values
greater than 1.0 speed up the audio (e.g.,
2.0 doubles the speed). * Values less than
1.0 slow down the audio (e.g., 0.5 cuts the speed
in half).
The allowed range for a single atempo filter is between
0.5 and 100.0.
Basic Syntax and Examples
To apply the filter, use the -filter:a option (or its
alias -af).
1. Double the Audio Speed (2.0x)
To make your audio play twice as fast, set the atempo
value to 2.0:
ffmpeg -i input.mp3 -filter:a "atempo=2.0" output.mp32. Halve the Audio Speed (0.5x)
To slow the audio down to half-speed, set the atempo
value to 0.5:
ffmpeg -i input.mp3 -filter:a "atempo=0.5" output.mp33. Chaining Filters for Extreme Speed (Older FFmpeg Versions)
In older versions of FFmpeg, the atempo filter was
limited to a range of 0.5 to 2.0. If you need
to go faster than 2.0x on legacy systems, you can chain multiple
atempo filters together by separating them with commas.
For example, to achieve a 4.0x speed increase (2.0 multiplied by 2.0):
ffmpeg -i input.mp3 -filter:a "atempo=2.0,atempo=2.0" output.mp3Synchronizing Audio and Video Speed
When changing the speed of a video file, you must adjust both the
video speed (using the setpts filter) and the audio speed
(using the atempo filter) to keep them in sync.
To double the speed of a video file (which requires half the presentation timestamps for video, and double speed for audio), 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.mp4To slow down both video and audio to half-speed:
ffmpeg -i input.mp4 -filter_complex "[0:v]setpts=2.0*PTS[v];[0:a]atempo=0.5[a]" -map "[v]" -map "[a]" output.mp4