Normalize Audio with FFmpeg: Loudness Explained
In this article
Yes, you can normalize audio files with FFmpeg, and the best way to do it is by using the loudnorm filter, which applies EBU R128 loudness normalization. You run a one-line command like ffmpeg -i input.mp3 -af loudnorm=I=-16:TP=-1.5:LRA=11 output.mp3 to bring the perceived loudness of any file to a consistent target. This article explains the difference between peak and loudness normalization, how to choose the right settings, and common pitfalls to avoid.
What Normalization Actually Does
Normalization adjusts the overall gain of an audio file so that its loudness reaches a target level. There are two main approaches: peak normalization and loudness normalization. Peak normalization scans the file for the highest sample value and raises the entire file until that peak hits a set ceiling (usually 0 dBFS). This is simple but doesn't account for how loud the audio perceives to the human ear—a quiet, dynamic recording and a heavily compressed one can both be peak-normalized yet sound very different in volume.
Loudness normalization, which FFmpeg's loudnorm filter implements, measures perceived loudness using a model based on the EBU R128 standard. It calculates an integrated loudness value (in LUFS, Loudness Units relative to Full Scale) over the whole file, along with a true peak and a loudness range. It then applies gain to hit a target integrated loudness, while also limiting the true peak to prevent clipping. This is the method used by streaming platforms like YouTube and Spotify, and it's the recommended way to normalize music in FFmpeg.
Peak vs. Loudness: Why It Matters
The distinction between peak and loudness is the most common source of confusion. A file can have a peak of -1 dBFS but still sound quiet if it's a sparse classical piece with long pauses. Conversely, a heavily compressed pop track with the same peak can sound twice as loud. Peak normalization only cares about the highest sample, so it will not fix this discrepancy.
Loudness normalization, on the other hand, matches the average perceived level. This makes it ideal for creating a playlist or album where all tracks should feel equally loud. For example, if you have a podcast with quiet speech and a music track with heavy bass, loudness normalization will bring them to a consistent level that sounds natural when played back-to-back. FFmpeg's loudnorm implements this by first measuring the file's loudness, then applying a gain and a limiter to achieve the target.
Choosing the Right Target Values
When using loudnorm, you specify three parameters: integrated loudness (I), true peak (TP), and loudness range (LRA). The integrated loudness is the main target, measured in LUFS. A common target for music streaming is -14 LUFS, but for broadcast and podcasting, -16 LUFS is often used. The true peak is the maximum allowed sample value, usually set to -1.5 dBTP to leave headroom for lossy codecs. The LRA describes how much the loudness varies; a setting of 11 is typical for music, while speech might use 7.
Here is a practical guide for typical use cases:
- Music for streaming:
I=-14:TP=-1.5:LRA=11 - Podcast or speech:
I=-16:TP=-1.5:LRA=7 - Broadcast (EBU R128):
I=-23:TP=-1.0:LRA=7 - Peak normalization only:
volume=0dB(not recommended for consistent loudness)
You can also use the two-pass mode for more accurate results. First, run ffmpeg -i input.mp3 -af loudnorm=I=-16:TP=-1.5:LRA=11 -f null - to get a JSON output with measured values. Then, feed those values back into the filter as parameters (e.g., measured_I=-18.2) to achieve a more precise gain. This is overkill for most users, but it's available if you need it.
How to Run the Command
The basic syntax is straightforward. Open a terminal (Command Prompt on Windows, Terminal on macOS/Linux) and navigate to the folder containing your audio file. Then run:
ffmpeg -i input.mp3 -af loudnorm=I=-16:TP=-1.5:LRA=11 output.mp3
Replace input.mp3 and output.mp3 with your actual filenames. FFmpeg will process the file and create a new one with the normalized audio. The original file is left untouched. If you want to overwrite the original, you can use the same name for output, but FFmpeg will ask for confirmation unless you add -y before the output.
For batch processing multiple files, you can use a simple loop in your shell. For example, in bash:
for f in *.mp3; do ffmpeg -i "$f" -af loudnorm=I=-16:TP=-1.5:LRA=11 "normalized_$f"; done
This will create a new file for each MP3 in the folder, prefixed with normalized_. Be careful with spaces in filenames—always quote the variables.
Common Problems and Misconceptions
One frequent mistake is assuming that normalization will make a quiet file as loud as a loud one without any distortion. If the source is extremely quiet, the gain applied will be large, and the limiter may cause audible pumping or distortion. In such cases, it's better to use a compressor or limiter separately, but that's beyond simple normalization.
Another misconception is that normalization fixes clipping. If your file already has clipped samples (flat-topped waveforms), normalization will not restore the lost information; it will only make the clipping louder. You need a declipping tool for that, which FFmpeg does not have natively.
Also, be aware that MP3 and other lossy formats have a true peak that can exceed 0 dBFS after decoding. That's why setting a true peak target like -1.5 dBTP is recommended—it prevents inter-sample peaks from causing distortion when the file is played back on different systems.
Alternatives and Comparisons
FFmpeg is not the only tool for normalization. Dedicated audio editors like Audacity (free) or Adobe Audition (paid) offer loudness normalization with graphical interfaces. There are also batch processors like MP3Gain, which applies peak normalization specifically to MP3 files. However, FFmpeg is unique in that it's a command-line tool that works on virtually any audio format, is scriptable, and is completely free. It also handles video files, so you can normalize the audio track of a video in one command.
Compared to MP3Gain, FFmpeg's loudnorm is more accurate because it uses perceptual loudness rather than peak. MP3Gain only adjusts the volume of the decoded audio, which can still leave perceived loudness mismatches. For a quick fix, MP3Gain is simpler, but for professional results, FFmpeg is superior.
Safety and Quality Considerations
Normalization is a lossless operation in the sense that it only changes the gain, not the audio content. However, if you save to a lossy format like MP3 at a low bitrate, you will lose quality. To preserve the original quality, always work with lossless formats (WAV, FLAC) and only convert to lossy after normalization. If you must work with MP3, use a high bitrate (at least 192 kbps) to minimize artifacts.
Also, be careful with the true peak setting. If you set it to 0 dBTP, you risk inter-sample clipping. A value of -1.0 dBTP is a safe compromise for most playback systems. For broadcast, -1.0 dBTP is standard. For streaming, -1.5 dBTP is common to avoid issues with lossy codecs.
Always keep a backup of your original files. Even though normalization is reversible in theory (you can apply negative gain), it's easy to forget the exact parameters used. Storing the original ensures you can redo the process if needed.
Frequently Asked Questions
Does FFmpeg normalization work for video files?
Yes. You can use the same loudnorm filter on the audio stream of a video file, for example: ffmpeg -i video.mp4 -af loudnorm=I=-16:TP=-1.5 -c:v copy output.mp4. The video stream is copied without re-encoding, so only the audio is processed.
What is the difference between loudnorm and volume filter?
The volume filter applies a fixed gain in decibels, e.g., volume=2.0 doubles the amplitude. It does not measure loudness. loudnorm first measures the file's loudness and then applies the correct gain to hit a target, making it automatic and more consistent.
Can I normalize a file to a specific LUFS value?
Yes, set the I parameter to your desired target, e.g., I=-14 for -14 LUFS. The filter will adjust the gain accordingly. You can verify the result by running the filter again with -f null - and reading the measured values.
Will normalization make all my songs the same volume?
Yes, in terms of perceived loudness. However, if a song has a very wide dynamic range (e.g., classical), it may still sound quieter in quiet passages and louder in loud passages compared to a compressed pop song, even at the same integrated loudness.
Is it safe to normalize a file multiple times?
Yes, but each pass applies gain, which can accumulate rounding errors, especially in lossy formats. It's best to normalize once from the original file. If you need to change the target, start from the original again.
Does FFmpeg support ReplayGain?
FFmpeg does not have a built-in ReplayGain scanner, but you can use the ebur128 filter to measure loudness and then apply gain manually. Alternatively, use a tool like loudgain which uses FFmpeg under the hood to add ReplayGain tags.