slhck / ffmpeg-normalize

Audio Normalization for Python/ffmpeg
MIT License
1.25k stars 117 forks source link

Use of EBU Offset Gain #119

Closed grb43 closed 4 years ago

grb43 commented 4 years ago

ffmpeg-normalize provides --offset to set the EBU Offset Gain. But the Offset Gain is not known until it is calculated during the first pass by the loudnorm filter (Target Offset).

It would be helpful if ffmpeg-normalize set the Offset Gain for the second pass automatically based on the outcome of the first pass. i.e. similar to the handling of Integrated Loudness, Loudness Range, etc.

As background, I note that the author of the filter states

For precise integrated loudness, always use dual-pass mode and supply the offset parameter. This linear offset gain is pre-limiter, so it will not affect your true peak value.

Testing a sample video seems to confirm the above statement.

ffmpeg -i <IN>.mp4 -af loudnorm=I=-23:TP=-2:LRA=11:print_format=summary -f null -

Input Integrated: -31.6 LUFS Input True Peak: -8.8 dBTP Input LRA: 15.8 LU
Input Threshold: -42.9 LUFS ....................... Normalization Type: Dynamic
Target Offset: +1.0 LU

After processing with ffmpeg-normalize (offset defaults to 0.0)

Input Integrated: -24.0 LUFS Input True Peak: -1.9 dBTP Input LRA: 10.9 LU Input Threshold: -35.0 LUFS

After processing with offset = 1.0

Input Integrated: -23.0 LUFS Input True Peak: -2.0 dBTP Input LRA: 10.9 LU Input Threshold: -34.0 LUFS

So not a huge difference but definitely a more accurate result.

slhck commented 4 years ago

Thanks for raising this issue. I'll have a look and fix this soon. Not sure why I didn't implement this from the start.