slhck / ffmpeg-normalize

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

show warning when using non-default target level #254

Closed milahu closed 6 months ago

milahu commented 6 months ago

setting the target level too high can produce broken output

for example, increasing the target level from -23 to -14 can create ugly volume glitches see also https://github.com/milahu/ffmpeg-loudnorm-volume-glitches-bug/issues/1

in my case, the volume glitches were hidden in the middle of the album so the defect is not obvious, and requires manual inspection of the result

https://github.com/slhck/ffmpeg-normalize/blob/94c2c6a6e05cbf6bc29aa5f052d7c5fdb111b8a9/ffmpeg_normalize/__main__.py#L140-L155

slhck commented 6 months ago

I think there are two issues at play here:

  1. An apparently broken algorithm that is not fixed upstream (which seems to be worked on in some fork of FFmpeg, so it seems like that should be merged back into FFmpeg itself).

  2. Usage notes that would help prevent issues from an end-user perspective.

What are you suggesting specifically? If "Going higher (> -14 LUFS) than source LUFS is forcing dynamic processing" (per the comment thread) then there could be a warning that dynamic mode is being used.

There is a warning already affecting the loudness range: https://github.com/slhck/ffmpeg-normalize/blob/94c2c6a6e05cbf6bc29aa5f052d7c5fdb111b8a9/ffmpeg_normalize/_streams.py#L426-L438

Are you suggesting something akin to this?

milahu commented 6 months ago

What are you suggesting specifically?

"show warning when using non-default target level"

if cli_args.target_level < -23:
    print(f"warning: using non-default target level {cli_args.target_level}. this can produce volume glitches. please verify the result.")
slhck commented 6 months ago

I find this a bit too drastical. In your original issue you talked about increasing the target beyond the input loudness. I can imagine adding a warning for that.

slhck commented 6 months ago

I did some checks on some files and it seems like the filter does not always revert to dynamic mode when the target is higher than the existing target. Instead, I'll parse the second pass loudnorm output and check if it shows that dynamic mode was used, compare that with the user's intent (i.e., if they wanted linear mode), and if there's a mismatch, print a warning.

slhck commented 6 months ago

Fixed in v1.28.0, see #256