DEV Community

Javid Jamae
Javid Jamae

Posted on • Originally published at ffmpeg-micro.com

FFmpeg atempo Filter: Change Audio Speed Without Pitch Shift

Originally published at ffmpeg-micro.com

You need to speed up or slow down audio in FFmpeg without making everyone sound like a chipmunk or a slow-motion monster. The pitch shift that comes from naive speed changes ruins the audio. The atempo filter solves this by time-stretching audio while preserving the original pitch.

Quick Answer

The FFmpeg atempo audio filter changes playback speed without altering pitch. Set a tempo value between 0.5 (half speed) and 2.0 (double speed) with -af "atempo=1.5". For changes beyond that range, chain multiple atempo filters together.

How to Change Audio Speed with FFmpeg atempo

The basic syntax is simple. Pass atempo as an audio filter with your desired speed multiplier:

ffmpeg -i input.mp4 -af "atempo=1.5" -c:v copy output.mp4
Enter fullscreen mode Exit fullscreen mode

This produces audio that plays 1.5x faster with no pitch distortion. The -c:v copy flag passes the video through unchanged. A value of 1.0 means no change. Values above 1.0 speed up the audio, values below 1.0 slow it down.

To slow audio to 75% of the original speed:

ffmpeg -i input.mp4 -af "atempo=0.75" -c:v copy output.mp4
Enter fullscreen mode Exit fullscreen mode

And to double the speed:

ffmpeg -i input.mp4 -af "atempo=2.0" -c:v copy output.mp4
Enter fullscreen mode Exit fullscreen mode

That's it for basic usage. But the filter has one constraint that trips people up.

The atempo Range Limit: 0.5 to 2.0

Each atempo filter instance only accepts values between 0.5 and 2.0. Try passing atempo=4.0 and FFmpeg will reject it outright.

The workaround is chaining. You multiply multiple atempo filters together to reach your target speed. Want 4x speed? Chain two 2.0 filters:

ffmpeg -i input.mp4 -af "atempo=2.0,atempo=2.0" -c:v copy output.mp4
Enter fullscreen mode Exit fullscreen mode

Want 0.25x speed (quarter speed)? Chain two 0.5 filters:

ffmpeg -i input.mp4 -af "atempo=0.5,atempo=0.5" -c:v copy output.mp4
Enter fullscreen mode Exit fullscreen mode

For 3x speed, you could use atempo=1.5,atempo=2.0 since 1.5 * 2.0 = 3.0. Any combination works as long as each individual value stays within the 0.5-2.0 range.

Syncing Audio and Video Speed with atempo + setpts

When you speed up or slow down video, the audio track doesn't automatically follow. The setpts video filter handles the visual speed, but you need atempo on the audio side to keep them in sync.

To make a video play at 2x speed with synced audio:

ffmpeg -i input.mp4 -vf "setpts=0.5*PTS" -af "atempo=2.0" output.mp4
Enter fullscreen mode Exit fullscreen mode

Notice the inverse relationship. A setpts value of 0.5*PTS doubles the video speed, so you need atempo=2.0 to match. For 4x speed:

ffmpeg -i input.mp4 -vf "setpts=0.25*PTS" -af "atempo=2.0,atempo=2.0" output.mp4
Enter fullscreen mode Exit fullscreen mode

The setpts multiplier is 1/speed while the atempo multiplier is the speed itself. Get that relationship wrong and your audio drifts out of sync with the video.

If you've seen the FFmpeg Micro post on speeding up and slowing down video, that covers the setpts side in more detail. This post is the deep-dive on atempo specifically.

Running atempo Through the FFmpeg Micro API

If you don't want to install FFmpeg locally or manage transcoding servers, FFmpeg Micro is a cloud API that lets you add video processing to any app with a single HTTP call, no FFmpeg installation, no server management.

The atempo filter works through the -af option, which is in the API's allowlist. A request to double audio speed looks like this:

{
  "inputs": [
    { "url": "https://storage.example.com/input.mp4" }
  ],
  "outputFormat": "mp4",
  "options": [
    { "option": "-af", "argument": "atempo=2.0" }
  ]
}
Enter fullscreen mode Exit fullscreen mode

Send it as a POST to https://api.ffmpeg-micro.com/v1/transcodes with your API key:

curl -X POST https://api.ffmpeg-micro.com/v1/transcodes \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": [{ "url": "https://storage.example.com/input.mp4" }],
    "outputFormat": "mp4",
    "options": [
      { "option": "-af", "argument": "atempo=2.0" }
    ]
  }'
Enter fullscreen mode Exit fullscreen mode

For combined video and audio speed changes, include both -vf and -af:

{
  "inputs": [
    { "url": "https://storage.example.com/input.mp4" }
  ],
  "outputFormat": "mp4",
  "options": [
    { "option": "-vf", "argument": "setpts=0.5*PTS" },
    { "option": "-af", "argument": "atempo=2.0" }
  ]
}
Enter fullscreen mode Exit fullscreen mode

The API returns a job object with id and status. Poll GET /v1/transcodes/{id} until the status is completed to get the output URL.

Common Pitfalls

Forgetting the 0.5-2.0 range

FFmpeg won't warn you gracefully. It just fails. Always check that each atempo value in your chain falls within bounds.

Audio-video desync after speed changes

If you apply setpts to video but forget atempo on the audio, playback will be out of sync. Always apply both filters together when working with video files.

Chaining math errors

When chaining atempo filters, the final speed is the product of all values. Double-check your multiplication. atempo=2.0,atempo=1.5 gives 3x, not 3.5x.

Using atempo on video-only streams

If your input file has no audio track, the -af flag will cause FFmpeg to error. Check your input with ffprobe first, or add -an to skip audio processing entirely.

Expecting lossless quality at extreme speeds

At very high or very low speeds (achieved through long chains), audio quality degrades. Tools like Sox and Audacity use different algorithms that may produce better results at extreme time-stretch values, but for the 0.5x-4x range that covers most use cases, atempo works well.

FAQ

What is the FFmpeg atempo filter?

The FFmpeg atempo filter is an audio filter that changes playback speed without shifting pitch. It uses time-stretching to speed up or slow down audio while keeping voices and instruments sounding natural.

Can atempo go beyond 2x speed?

Not in a single filter instance. Each atempo filter accepts values from 0.5 to 2.0 only. But you can chain multiple filters to reach any speed. For example, atempo=2.0,atempo=2.0 produces 4x speed.

How do I speed up video and audio together in FFmpeg?

Use setpts for the video track and atempo for the audio track in the same command. For 2x speed: -vf "setpts=0.5*PTS" -af "atempo=2.0". The setpts multiplier is the inverse of your target speed.

Does atempo affect audio quality?

For moderate speed changes (0.5x to 2.0x per filter), quality loss is minimal. Longer chains for extreme speeds can introduce artifacts. If you need high-quality time-stretching at 8x or beyond, consider dedicated tools like Sox or Audacity's Paulstretch.

Can I use atempo with the FFmpeg Micro API?

Yes. The -af option is in the FFmpeg Micro API allowlist. Pass {"option": "-af", "argument": "atempo=2.0"} in the options array of your transcode request.

Speed Up Audio Processing in Production

Running FFmpeg on your own servers means managing binaries, scaling workers, and handling failures. Get a free FFmpeg Micro API key at ffmpeg-micro.com and run atempo jobs from any HTTP client, no FFmpeg install needed.

Top comments (0)