milahu / ffmpeg-loudnorm-volume-glitches-bug

0 stars 0 forks source link

In current ffmpeg version you should never ever use default/dynamic loudnorm mode #1

Closed richardpl closed 3 months ago

richardpl commented 4 months ago

Loudnorm filter code in FFmpeg for dynamic processing is full of bugs and un-fixable.

milahu commented 4 months ago

thanks for the bad news ^^

turns out, this was a user error on my side

i was too greedy with the "Integrated Loudness Target" parameter im using two-pass EBU normalization, and the default value for EBU is -23

$ ffmpeg-normalize --help

  -t TARGET_LEVEL, --target-level TARGET_LEVEL
                        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.

i was using -14 which is too loud for EBU, which creates these ugly "volume glitches"

https://github.com/milahu/ffmpeg-loudnorm-volume-glitches-bug/blob/d0c669e0181f5f4235bfe25ca5f6db3024ddbe16/ffmpeg-loudnorm-analyze.sh#L87

https://github.com/milahu/ffmpeg-loudnorm-volume-glitches-bug/blob/d0c669e0181f5f4235bfe25ca5f6db3024ddbe16/ffmpeg-loudnorm-format-filters.sh#L63

fixed by using -23

#loudnorm_i=-14.0 # max integrated # no!! too loud for EBU. creates ugly volume glitches
loudnorm_i=-23.0 # max integrated

why was it -14?

https://superuser.com/questions/1604545/ffmpeg-loudnorm-results-in-not-very-loud

https://youlean.co/loudness-standards-full-comparison-table/

i was using the same value as YouTube, Spotify, TIDAL, Amazon Music, Amazon Alexa, ... but apparently, these services are not doing two-pass EBU normalization (?)

# Film, TV and Gaming
# max_integrated=-23 # EBU
# max_integrated=-24 # ATSC, OP-59, ARIB, AGCOM, ASWG-R001 HOME
# max_integrated=-18 # ASWG-R001 PORTABLE
# Online Streaming
# max_integrated=-14 # YouTube, Spotify, TIDAL, Amazon Music, Amazon Alexa
# max_integrated=-15 # Deezer
# max_integrated=-16 # Apple, AES
richardpl commented 4 months ago

If your original audio source integrated is already >= -14 LUFS than you cant do much with dual-pass, as proper dual-pass is single constant attenuation for whole audio file, thus you can make target loudness integrated only <= current source LUFS. Going higher (> -14 LUFS) than source LUFS is forcing dynamic processing. So it depends on input audio original dynamics/volume. What online streaming services use is probably applied in near-real-time thus dynamic. If you really want/need better dynamic mode loudnorm processing for online/streaming audio streams (instead of only offline - dual-pass solution) look at loudnorm in Librempeg fork of ffmpeg and report your findings.

milahu commented 4 months ago

this is the volume profile of all 131 concatted mp3 files of the album from loudnorm pass 1 with loudnorm_i=-23.0

{
    "input_i" : "-23.66",
    "input_tp" : "-0.04",
    "input_lra" : "3.40",
    "input_thresh" : "-34.00",
    "output_i" : "-23.05",
    "output_tp" : "-2.00",
    "output_lra" : "3.30",
    "output_thresh" : "-33.40",
    "normalization_type" : "dynamic",
    "target_offset" : "0.05"
}

file 57 has "input_i" : "-23.62"

"input_i" : "-23.66" is close to -23, so no need to normalize (right?) anyway, the volume difference was near-zero, so i decided to leave these files untouched

my goal is to fix audio/video releases which are waay too quiet, like by factor 2 this should be a "fire and forget" solution, similar to ffmpeg-normalize so i will just stick to the default loudnorm_i=-23.0 for EBU (they will have their reasons) loudnorm_i=-14.0 was a bit louder, but not worth the volume glitches

richardpl commented 4 months ago

When you concat album (and each segment of album have different loudness) before concat do loudnorm on each segment separately and then after that do concat, otherwise you will not get much with loudnorm dual-pass on single file if it have different ranges of loudness in each segment... If you insist on using single-pass mode with current ffmpeg loudnorm on files, than I can only say you good luck to whoever will listen to such output.

milahu commented 3 months ago

before concat do loudnorm on each segment separately

no, i want to preserve the relative loudness of tracks. if one track of an album is quiet, then thats the intention of the creator

single-pass mode

nope, always two-pass

anyway, my issue is fixed, closing

fixed by using -23

#loudnorm_i=-14.0 # max integrated # no!! too loud for EBU. creates ugly volume glitches
loudnorm_i=-23.0 # max integrated