(FFmpeg) How to Change the Pitch / Sample Rate of an Audio Track (Mp3)?

Changing the pitch of an audio track means the tempo stays the same but the audio pitch increases/decreases. There isn’t a native way to change the pitch without also changing the playback speed. Luckily, chaining the atempo and asetrate filters together can achieve this effect.

In this example, the pitch of the audio decreases by 50% by changing the sample rate with asetrate, which by itself will result in a longer playback duration:

  $ ffmpeg -i input.mp3 -af "asetrate=44100*0.5" output.mp3 

Tip: Changing the sample rate to change the pitch might create a conflict because some players or websites (like Bandcamp) require audio with a sample rate to be 44.1kHz. 

To keep the pitch change while setting the preferred sample rate the filter aresample is needed, as seen below:

  $ ffmpeg -i input.mp3 -af "asetrate=44100*0.5,aresample=44100" output.mp3 

As stated earlier in this question, for a true pitch to be applied the tempo shouldn’t change. With the use of atempo the pitch can change while the tempo nearly stays the same. In the example below, an atempo between 1.5 to 1.7 should result in proper pitch change:

  $ ffmpeg -i input.mp3 -af "asetrate=44100*0.5,atempo=1.5,aresample=44100" output.mp3 

A Note about Pitch, Tempo & Sample Rate

There are no correct answers here for what works best, that’s up to you. Play around with each version, find a sound that works with your ears and what you are trying to accomplish. 

We Are コンピューター生成 by メトロイヤー
an album made entirely with FFmpeg

For example, I’ve used pitching down, echos and randomized splicing to create sample based Vaporwave music. The entire album was completely generated with FFmpeg using Japanese vintage commercials as input. Personally, I am very pleased with the sound. 

Listen to it here: https://mthu.bandcamp.com/album/we-are

Love FFmpeg? Grab a copy of FFmpeg For Beginners on Kindle or Paperback to learn over 120 ways to master FFmpeg!

buy now on amazon