Pitch Shifting and Time Stretching with FFmpeg

This is how to do pitch shifting and time stretching with FFmpeg. In this tutorial, I will explain how to adjust the pitch and speed of audio files using two powerful tools. These are the FFmpeg and Audacity software. Whether you want to create unique sound effects, adjust the tempo of a music track, or match audio to video, pitch shifting and time stretching can help you achieve your desired results.

Pitch Shifting and Time Stretching with FFmpeg

Install FFmpeg which I have added to this website. Once you have complete the install you can then proceed to the first steps as I have listed below. Note that you should first insure proper installation with no issues. Likewise see also the articles that I wrote on creating a looping audio clip with FFmpeg as well as the articles on removing background noise with FFmpeg as well.

Likewise you might like to read the converting audio with FFmpeg and Audacity as well as the FFmpeg Audacity.


Step 2:

Firstly you will need to open Terminal (or Command Prompt): Launch your terminal or command prompt.


Step 3:

Navigate to the directory containing your audio file: Use the cd command to navigate to the directory where your audio file is located.


Step 4:

Perform Pitch Shifting: To shift the pitch of the audio file, use the following FFmpeg command:

ffmpeg -i input_file.wav -af asetrate=44100*1.2,aresample=44100 output_pitch_shifted.wav

This command increases the pitch by 20%. Adjust the multiplier (1.2 in this example) to increase or decrease the pitch as desired.


Step 5:

Perform Time Stretching: To stretch or shrink the duration of the audio file without affecting pitch, use the following FFmpeg command:

ffmpeg -i input_file.wav -filter:a “atempo=1.2” output_time_stretched.wav


This command increases the duration by 20%. Adjust the value (1.2 in this example) to stretch or shrink the audio file as needed.

Step 6:

Verify the Output: Once the processing is complete, verify that the output audio files have been created in the same directory. Lastly also see the articles on FourCC : BINK as well as FFmpeg for Audacity Audio. Likewise there is also the adding fade-in and fade-out effects with Audacity as well.