Adjust and Normalize Your Music Files with FFMPEG

Not all audio files are created equal. Sometimes, they’re too quiet, too loud, or just off. When you find yourself with a problematic audio file, you aren’t stuck just dealing with it. FFmpeg, a powerful open-source audio utility can help. It can adjust the volume of your files and normalize them to get rid of unpleasant fluctuations in volume. What’s even better, it’s fully scriptable and even baked into Python scripts that streamline the whole thing.

Installing FFmpeg

If you don’t already have it, FFmpeg is really easy to get. Linux users can almost always find it in their distribution repositories. For Windows and Mac, you can find it on the project’s download page.

Basic Loudness

Everything here’s going to be done through the terminal. FFmpeg does have graphical front ends, but the command line is the simplest and most direct way to work with it. Go ahead and open a terminal to work in.

Increase Volume With FFMPEG

Change directories into one that has files you would like to work with. FFmpeg supports just about every audio format you can think of, so don’t worry about that. When you have files to work with, run FFmpeg. Use the -i flag to specify an input file. Then, the -filter:a flag lets you specify a filter, in this case adjusting the volume. FFmpeg uses 1 as the original volume of the file. To decrease the volume by half, set “volume” equal to 0.5. Then, end with the output file name. Altogether, it should look like the example below.

Running that command will cause FFmpeg to create a copy of your input file with half the volume and output it to the specified file name. Of course, you can also increase the volume by providing a number greater than 1. In the case of the example below, the volume will increase by 50%.

FFmpeg is also fully capable of converting your files. Specify a different output extension, and FFmpeg will take care of the rest.

Some people are more comfortable working with decibels for more technical control of their files. FFmpeg supports that too. Instead of using the base one system from before, specify the amount of decibels that you would like to increase the volume by followed by “dB.”

Supply a negative number to decrease the volume in decibels.

Loudness Normalization

FFMPEG Loudnorm function

If your file’s volume is inconsistent, you can always use FFmpeg’s built-in normalization function to try to get things under control. Set up your command just like you were changing the volume, but use “loudnorm” instead of volume as the filter. FFMpeg will attempt to lower and raise the peaks and valleys in the sound to make it more pleasant to listen to.

Automated with Python

There’s actually more available when normalizing audio with FFmpeg, but it requires some knowledge of how audio works and some math. Rather than do it yourself, there’s a convenient Python script that automates the whole thing. Plus, it can handle entire folders at once.

Install ffmpeg-normalize

If you have Python installed on your computer with the Pip package manager, you can use it to install ffmpeg-normalize. Linux and Mac users will probably need to use “sudo,” unless they’ve configured things differently.

Using ffmpeg-normalize

FFmpeg-normalize single file

FFmpeg-normalize is very simple to use. Provide an input file followed by an output file after the -o flag, and the script will automatically normalize your file. You will need to specify a codec for it to work, though.

It also allows you to specify multiple input and output files at once.

You can use it to convert files as well. You’ll still need to specify a codec and bitrate, but it does work well. The flags are the same ones you’d use for plain FFmpeg.

Using ffmpeg-normalize on Whole Folders

FFmpeg-normalize Entire Folder

You can also use the wildcard character(*) to normalize entire folders with or without converting them. The outputs will automatically by placed in their own folder. The command looks a bit different on Windows than it does on Linux and Mac, but the result is the same. As an added note, you’ll need to specify the output extension of each file with the -ext flag, otherwise you’ll get .mkv files.

Mac and Linux

Windows

Whichever method you choose, there’s no reason do deal with poor quality audio. You can easily use FFmpeg to adjust and normalize the volume to get something much more evenly balanced that fits in better with the rest of your collection.

One comment

  1. I use Audacity for the task of normalization. Not much for the terminal personally. I also use wxMP3Gain for albums and playlists, but MP3 gain is no longer developed and almost done for last I heard.

Leave a Comment

Yeah! You've decided to leave a comment. That's fantastic! Check out our comment policy here. Let's have a personal and meaningful conversation.

Sponsored Stories