Alex Balgavy

Just some stuff about me.

Here's my dotfiles repository.

Check out my blog.

My keys: PGP, SSH

My crypto wallets (BTC, XMR)

ffmpeg how to change the pitch sample rate of an audio track mp3

Written by John Riselvato - original link

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

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