[FFmpeg-devel] [RFC] Audio normalization

Clément Bœsch ubitux at gmail.com
Fri Feb 22 00:22:38 CET 2013


Hi,

So here is a first attempt to add automatic audio normalization on the fly with
FFmpeg. The basic idea is to make EBU R.128 filter inject metadata about the
loudness analysis every audio frame of 100ms (BTW, a big thanks to Nicolas
George for the {min,max}_samples features in lavfi), and then make volume do
the normalization according to these data.

How to test it:

    ./ffplay -f lavfi -i 'amovie=in.mp3,ebur128=video=1:metadata=1[r128-before][a]; [a]volume=metadata=lavfi.r128.I,ebur128=video=1[r128-after][out1]; [r128-before] pad=iw*2 [padded]; [padded][r128-after] overlay=w'

The graph on the left is the audio before normalization, the graph on the right
is after normalization, and what you hear is the audio normalized.

You can in the volume filter use another metadata, such as lavfi.r128.L400 or
lavfi.r128.L3000, respectively for momentary and short-term loudness. The
normalization should be relatively smooth with the integrated loudness (I) and
short-term (L3000) one.

It's mostly done, what's left is maybe to make the standard hardcoded volume
(-23 LUFS/dB) in volume filter configurable, and maybe other settings.

Also, there is bug: it seems ffmpeg and ffprobe don't appreciate very much the
segmentation through {min,max}_samples in lavfi, and exit very quickly without
giving much info (AFAICT it seems the fifo is empty after a first request
frame). How to reproduce: after the patchset,
    ffmpeg -f lavfi -i 'amovie=in.mp3,ebur128=metadata=1' -f null -



More information about the ffmpeg-devel mailing list