Loudness normalization with ffmpeg

My first blog post, showing how loudness normalization with ffmpeg works

Published on Aug 24, 2023

Reading time: 3 minutes.


Well, here we are again. I rember I once posted about loudness normalization with ffmpeg. But this post is long lost, and I honestly could not find it again. So, now in my new blog, I am gonna post about this topic again. In general I am going to post about technical topics all over my mind, about work specific things as well as personal projects. Whatever I deem interesting I will post, also as kind of archive of problems and how to solve them, if they ever arise again. I can not and will not guarentee a certain number of posts on a certain timeframe, but I will try to keep the posts I post as relevant to my profession and interests as possible.

Why loudness normalization?

Maybe you are wondering why you need loudness normalization in the first place, after all the user you deliver your content to can just turn the volume up/down how they want anyways. Why put extra effort into this topic? Well, depending on your content loudness, most platforms will significantly reduce the loudness if you just upload your stuff “as loud as possible”, therefore removing a lot of dynamics from your music/video, making everything sound flat and dull. At the same time, when uploading your content too silent, well, the platforms usually do not increase the volume, so it will be way more silent than other content.

Analyze (and view) loudness

Before you can normalize the loudness of a file, you should find out how loud it actually is! Luckily ffmpeg has a handy command for that as well, or well, actually two commands.

To visualize the loudness of a given file use the following command, replacing FILE.flac with the name of the audio or video file you want to visualize:

ffplay -f lavfi -i "amovie=FILE.flac,ebur128=video=1:meter=18 [out0][out1]"

This will produce the following output: ffplay visualizing the loudness of a audio file This produces a neat graph which shows the loudness over time, allowing you to fine tune your master if you notice something off in the mixing. If you however don’t need a graph of the loudness over time, you can just use the following command to analyze the file and print the loudness. Again, replacing FILE.flac with your actual file:

ffmpeg -i FILE.flac -af loudnorm=I=-23:TP=-1:print_format=summary -f null -

Note: Integrated loudness is set to -23 LUFS and TruePeak to -1 dBTP, this is in accordance with the EBU R128, if you want to normalize for other standards, you have to adapt these values accordingly. The following output will be produced:

Input Integrated:    -24.5 LUFS
Input True Peak:      -5.4 dBTP
Input LRA:            12.0 LU
Input Threshold:     -35.8 LUFS

Apply normalization

You can either apply one pass normalization with the command shown above, with a proper output instead of null, like this:

ffmpeg -i FILE.flac -af loudnorm=I=-23:TP=-1:print_format=summary OUTFILE.flac

Or, for better results, use two pass normalization, where we now need the values shown above again to provide them to the filter to now actually do the normalization work:

ffmpeg -i FILE.flac -af loudnorm=I=-23:TP=-1:measured_I=-24.5:measured_TP=-5.4:measured_LRA=12:measured_thresh=-35.8:print_format=summary OUTFILE.flac

This will produce the following output, along with the specified – now normalized – output file:

Input Integrated:    -24.5 LUFS
Input True Peak:      -5.4 dBTP
Input LRA:            12.0 LU
Input Threshold:     -35.8 LUFS

Output Integrated:   -23.1 LUFS
Output True Peak:     -4.0 dBTP
Output LRA:            7.7 LU
Output Threshold:    -34.1 LUFS

Normalization Type:   Dynamic
Target Offset:        +0.1 LU

Other Values for Integrated Loudness and True Peak

Besides the EBU R128, which is the go to recommendation for European TV, there are many other recommendations for target loudness for different platforms, here is a (non exhaustive) list of a few important ones:

NameIntegrated LoudnessTrue PeakNotes
EBU R128-23 LUFS-1 dBTPEuropean TV
YouTube-14 LUFS-1 dbTP
Spotify-14 LUFS-1 dBTP
Apple Music-16 LUFS-1 dBTP
Soundcloud-8 to -13 LUFS-1 dBTP

Resources