Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save elvuel/8e9e856f11824493f9d8ee850b0836b4 to your computer and use it in GitHub Desktop.
Save elvuel/8e9e856f11824493f9d8ee850b0836b4 to your computer and use it in GitHub Desktop.
ffmpeg change voice pitch frequency

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.

References

Source

https://superuser.com/a/1076762/881022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment