Audio Loudness Normalization With FFmpeg

The most well known audio loudness normalization method currently is ebu R128.
This standard was defined by the European brodcasting union the sepcification of the standard can be found here.
FFmpeg implements the loudnorm filter that supports ebu R128 standard.

The aim of this standard is to make audio equally loud everywhere.

Overview

When using FFmpeg to normalize audio with ebu R128 you have two options.
Single is ideal for live normalization, produces worse results but is faster.
With a single pass you can set parameters for the loudness and apply them directly.

Double pass is ideal for postprocessing, produces better results but slower.
With double pass first you scan the media file you want to normalize and then apply target loudness parameters with the measured values.

Parameters

When using FFmpeg to normalize audio with the loudnorm filter you can use the following parameters.

input_i : The target loudness in LUFs ( LUF stands for Loudness Units Full Scale and one unit of LUF equals one dB ).

input_lra: This stands for Loudness Range. This describes the overall loduness range, from the softest part to the loudest part.

input_tp: This stands for true peak.

Using FFmpeg

From the terminal you can perform a double pass ebu R128 normalization with the following commands.

For a double pass normalization you have to store the measured values and feed them back to the command.

1
2
3
4
ffmpeg -i input.mp4 -af loudnorm=I=-23:LRA=7:tp=-2:print_format=json -f null -

ffmpeg -i input.mp4 -af
loudnorm=I=-23:LRA=7:tp=-2:measured_I=-30:measured_LRA=1.1:measured_tp=-11 04:measured_thresh=-40.21:offset=-0.47 -ar 48k -y output.mp4

Using ffmpeg-normalize

To make this simpler and get rid of the manual ffmpeg install I’ve created a small Node.js package to perform the single pass, double pass ebu R128 normalization without having to install ffmpeg or any other dependencies.

Install

1
npm install ffmpeg-normalize

Usage

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const { normalize } = require('ffmpeg-normalize');

normalize({
input: 'input.mp4',
output: 'output.mp4',
loudness: {
normalization: 'ebuR128',
target:
{
input_i: -23,
input_lra: 7.0,
input_tp: -2.0
}
}
})
then(normalized => {
// Normalized
})
.catch(error => {
// Some error happened
});