Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to change the frequency of an audio file. Meaning: the whole file should sound (say) one octave higher or lower. How to do it? Using ffmpeg or other command line open source tool would be preferable.

share|improve this question
up vote 4 down vote accepted

If you need a GUI, use Audacity, it's a free, open source, cross platform audio editing tool.

Features: Change the pitch without altering the tempo, or vice-versa.

If you want to use the command line, try sox:

SoX is a cross-platform (Windows, Linux, MacOS X, etc.) command line utility that can convert various formats of computer audio files in to other formats. It can also apply various effects to these sound files, and, as an added bonus, SoX can play and record audio files on most platforms.

Something like that:

sox <infile> <outfile> pitch <shift>

where gives the pitch shift as positive or negative ‘cents’ (i.e. 100ths of a semitone). There are 12 semitones to an octave, so that would mean ±1200 as a parameter.

share|improve this answer
awesome... sox is just what i need! – tanon Jun 4 '11 at 10:36

Find input audio rate beforehand thus:

ffmpeg -i input.mp4

Assuming input audio rate 44,100 Hz, this command will do the job:

ffmpeg -i input.mp4 -af asetrate=44100*3/4,atempo=4/3 output.mp4

The factor of 3/4 will change most female and skinny (chipmunk) voices into male and fat voices. Use 4/3 for the opposite:

ffmpeg -i input.mp4 -af atempo=3/4,asetrate=44100*4/3 output.mp4

Notice reversed filter order to prevent signal degradation. Whenever possible, lossless operation should come before lossy operation. I’m not 100% sure whether I’m not making some mistake here from misunderstanding FFmpeg filters.

FFmpeg filter asetrate should have a variable named ir for input audio rate, in analogy to iw×ih in some video filters, but I couldn’t find any mention of it in the documentation.

For factors greater than 2 (such as 4/1 or 1/4), you must use multiple atempo filters (1/4 = 1/2 * 1/2 or 4/1 = 2/1 * 2/1):

ffmpeg -i input.mp4 -af asetrate=44100*4,atempo=1/2,atempo=1/2 output.mp4

I don’t know how to obtain skinny male voice and fat female voice.

Instead of -af, you can write -filter:audio or -filter:a.


share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .