We covered some quick video editing commands with ffmpeg over in Command Line Video Editing. Now let’s take a look at some useful audio editing options. Most of the same switches used in video editing will apply to audio with few or no differences. For example cropping by time with -ss and -t, and avoiding reencoding with -c copy. Or reencoding to a different file format by simply appending the desired file extension to the output file. Just watch out for lossy changes.
ffmpeg -i audio.mp3 -af 'asetrate=44100*0.8,atempo=1/0.8' output.mp3
The value (0.8 in this example) represents the desired percentage change in pitch, so 0.8 would reduce pitch by 80%. Both values need to be the same at the end of the asetrate= and atempo= arguments, respectively. The sample rate (44100) should also match the source file, otherwise the speed of the audio will change.
ffmpeg -i audio1.mp3 -i audio2.mp3 -filter_complex amerge=inputs=2 -c:a copy -c:a mp3 output.mp3
The longer audio file should be the first input.
ffmpeg -i input.ogg -map 0 -af 'aecho=1:0.8:120:0.5' output.ogg
The first two paramters in aecho= set the gain while the last two control for delay. A more distant sounding echo should have higher values.
ffmpeg -i input.mp3 -filter:a "volume=0.6" output.mp3
A volume value of 0.6 would reduce the volume by 60%. This command has saved me quite a few headaches with overly loud or quiet podcasts.
These are just the one-liners I find myself using occasionally. It has enabled me to quickly throw together sound library game mods, interview archives and to fix issues within my personal music directories. As always, ffmpeg can handle a ton of different tasks from the mundane to the eccentric. Just have a read through the ffmpeg manpages.