slhck / ffmpeg-normalize

Audio Normalization for Python/ffmpeg
MIT License
1.28k stars 118 forks source link

Enable dynamic normalization #176

Closed wyup closed 2 years ago

wyup commented 2 years ago

I'd like to ask if ffmpeg-normalize does dynamic normalization when adding -lrt and -tp values other than default. In this example I have changed -lrt and -tp but the result seems a standard default linear normalization. Thanks.

[diegohum@diegohum Música]$ ffmpeg-normalize wire.mp3 -nt ebu -t -23 -lrt 9 -tp -1.5 -o wire-dynorm.wav WARNING: The sample rate will automatically be set to 192 kHz by the loudnorm filter. Specify -ar/--sample-rate to override it. [diegohum@diegohum Música]$ ffmpeg-normalize wire.mp3 wire-dynorm.wav -p -n -f WARNING: The sample rate will automatically be set to 192 kHz by the loudnorm filter. Specify -ar/--sample-rate to override it. WARNING: The sample rate will automatically be set to 192 kHz by the loudnorm filter. Specify -ar/--sample-rate to override it. [ { "input_file": "wire.mp3", "output_file": "normalized/wire.mkv", "stream_id": 0, "ebu": { "input_i": -18.46, "input_tp": -9.19, "input_lra": 2.7, "input_thresh": -28.59, "output_i": -22.91, "output_tp": -13.7, "output_lra": 2.7, "output_thresh": -33.04, "normalization_type": "dynamic", "target_offset": -0.09 }, "mean": null, "max": null }, { "input_file": "wire-dynorm.wav", "output_file": "normalized/wire-dynorm.mkv", "stream_id": 0, "ebu": { "input_i": -23.0, "input_tp": -13.73, "input_lra": 2.7, "input_thresh": -33.12, "output_i": -22.91, "output_tp": -13.7, "output_lra": 2.7, "output_thresh": -33.04, "normalization_type": "dynamic", "target_offset": -0.09 }, "mean": null, "max": null } ]

slhck commented 2 years ago

As far as I understand, loudnorm is just linear — if you want dynamic normalization, you have to use other filters. See the example page for more: https://github.com/slhck/ffmpeg-normalize/wiki/examples

wyup commented 2 years ago

According to https://ffmpeg.org/ffmpeg-all.html#loudnorm, it does dynamic normalization by default, unless _measuredI, _measuredLRA, _measuredTP, and _measuredthresh values are all specified, being Target LRA<Source LRA and TP<target TP. Then linear norm. is performed, which is what ffmpeg-normalize does.

So I guess when feeding desired I / LRA / TP (without _measuredthresh), one should hope to get a dynamic normalization with ffmpeg-normalize, without the need for additional filters.

slhck commented 2 years ago

Seems this has been clarified/changed at some point. I added an option to force dynamic normalization and also print warnings in case the chosen range target is lower than the measured input range.