Configure Tempo Factor in FFmpeg Atempo Filter

Adjusting audio playback speed without altering its pitch is a common task in audio and video processing. This guide demonstrates how to configure the tempo factor using the FFmpeg atempo filter, explaining the syntax, parameter limits, and how to chain filters for extreme speed adjustments.

Basic Syntax of the Atempo Filter

The atempo filter accepts a single float value as its tempo factor. The basic syntax for applying this filter is:

ffmpeg -i input.mp3 -filter:a "atempo=FACTOR" output.mp3

You can also use the shorthand -af instead of -filter:a.

Allowed Value Limits

The atempo filter has a strict limitation on the range of the tempo factor: * Minimum value: 0.5 (slows the audio down to half speed) * Maximum value: 2.0 (doubles the audio speed)

If you need to go beyond these limits, you must chain multiple atempo filters together.

Practical Examples

1. Speed Up Audio (1.5x Speed)

To increase the audio speed by 50%, set the tempo factor to 1.5:

ffmpeg -i input.mp3 -filter:a "atempo=1.5" output.mp3

2. Slow Down Audio (0.75x Speed)

To decrease the audio speed to 75% of the original, set the tempo factor to 0.75:

ffmpeg -i input.mp3 -filter:a "atempo=0.75" output.mp3

3. Exceeding the Limits (e.g., 4x Speed)

Since the maximum factor for a single filter is 2.0, you can multiply the effect by chaining filters separated by commas. To achieve a 4x speed increase (\(2.0 \times 2.0 = 4.0\)):

ffmpeg -i input.mp3 -filter:a "atempo=2.0,atempo=2.0" output.mp3

To achieve an 8x speed increase, chain three filters:

ffmpeg -i input.mp3 -filter:a "atempo=2.0,atempo=2.0,atempo=2.0" output.mp3

4. Adjusting Audio and Video Simultaneously

When speeding up a video file, you must adjust both the video presentation timestamp (setpts) and the audio tempo (atempo) so they remain in sync.

To speed up both video and audio to 1.5x speed:

ffmpeg -i input.mp4 -filter:v "setpts=0.67*PTS" -filter:a "atempo=1.5" output.mp4

(Note: The video PTS factor is the inverse of the speed change: \(1 / 1.5 \approx 0.67\))