Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show warning when using non-default target level #254

Closed
milahu opened this issue May 11, 2024 · 5 comments
Closed

show warning when using non-default target level #254

milahu opened this issue May 11, 2024 · 5 comments

Comments

@milahu
Copy link

milahu commented May 11, 2024

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 milahu/ffmpeg-loudnorm-volume-glitches-bug#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

group_normalization.add_argument(
"-t",
"--target-level",
type=float,
help=textwrap.dedent(
"""\
Normalization target level in dB/LUFS (default: -23).
For EBU normalization, it corresponds to Integrated Loudness Target
in LUFS. The range is -70.0 - -5.0.
Otherwise, the range is -99 to 0.
"""
),
default=-23.0,
)

@slhck
Copy link
Owner

slhck commented May 12, 2024

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:

if (
self.media_file.ffmpeg_normalize.loudness_range_target
< self.loudness_statistics["ebu"]["input_lra"]
and not will_use_dynamic_mode
):
_logger.warning(
f"Input file had loudness range of {self.loudness_statistics['ebu']['input_lra']}. "
f"This is larger than the loudness range target ({self.media_file.ffmpeg_normalize.loudness_range_target}). "
"Normalization will revert to dynamic mode. Choose a higher target loudness range if you want linear normalization. "
"Alternatively, use the --keep-loudness-range-target or --keep-lra-above-loudness-range-target option to keep the target loudness range from "
"the input."
)
will_use_dynamic_mode = True

Are you suggesting something akin to this?

@milahu
Copy link
Author

milahu commented May 12, 2024

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
Copy link
Owner

slhck commented May 13, 2024

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
Copy link
Owner

slhck commented May 13, 2024

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
Copy link
Owner

slhck commented May 13, 2024

Fixed in v1.28.0, see #256

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants