0

I use the Loundnorm filter in Ffmpeg to normalize LUFS in a folder containing three audios, Music1.mp3, Music2.mp3 and Music3.mp3 using the double-pass method.

The LUFS and True Peak values are the same for all audio files:
LUFS -10.0 and True Peak -0.5

Code:

md "C:\Users\%username%\Desktop\Temp_normalizing_lufs"    ------> temp folder audio files being normalized   
pushd "%Userprofile%\Desktop\Audios LUFS"                 ------> folder with the original audio files

                                                                                                      __
FOR /F "delims=" %%a in ('where .:*.mp3 ^|findstr /vi "_LOUDNORM  _EBU"') DO (                          |                
  SET "filename=%%~na"                                                                                  |
  ffmpeg -hide_banner -i "%%a" -af "[0:a]loudnorm=print_format=summary" -f null NUL 2> "%%~na.log"      |   
  @FOR /F "tokens=3" %%b IN ('FINDSTR /C:"Input Integrated" "%%~na.log"') DO (SET II=%%b)               |
  @FOR /F "tokens=4" %%b IN ('FINDSTR /C:"Input True Peak" "%%~na.log"') DO (SET ITP=%%b)               |  set original audio files values  
  @FOR /F "tokens=3" %%b IN ('FINDSTR /C:"Input LRA" "%%~na.log"') DO (SET ILRA=%%b)                    |  to use as parameters in loudnorm
  @FOR /F "tokens=3" %%b IN ('FINDSTR /C:"Input Threshold" "%%~na.log"') DO (SET IT=%%b)                |
  @FOR /F "tokens=3" %%b IN ('FINDSTR /C:"Target Offset" "%%~na.log"') DO (SET TO=%%b)                  |
  DEL "%%~na.log"                                                                                     __|

  SETLOCAL ENABLEDELAYEDEXPANSION
  FOR /F "tokens=1,2 delims=," %%b IN ('ffprobe -v 0 -select_streams a -show_entries "stream=bit_rate,sample_rate" -of "csv=p=0" "!filename!.mp3"')     ----> getting the sample rate and bitrate of the original audio file to use as parameters in loudnorm
  DO (  
      ffmpeg -hide_banner -i "!filename!.mp3" -af "loudnorm=linear=true:I=!-10.0!:LRA=11:tp=!-0.5!:measured_I=!II!:measured_LRA=!ILRA!:measured_tp=!ITP!:measured_thresh=!IT!:offset=!TO!:print_format=summary" -c:v copy -id3v2_version 3 -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (front)" -acodec mp3 -b:a %%c -ar:a %%b "C:\Users\%username%\Desktop\Temp_normalizing_lufs\!filename!.mp3"
     )
  ENDLOCAL
)

xcopy "C:\Users\%username%\Desktop\Temp_normalizing_lufs\*.mp3" "C:\Users\%username%\Desktop\Normalized Audios Lufs\LOUDNORM\MP3\LUFS %-10.0%" /y /s /i   ----> copying the audio files from the temporary folder to the final folder

                                                                __
del /q "C:\Users\%username%\Desktop\Temp_normalizing_lufs\*.*"    |
rmdir "C:\Users\%username%\Desktop\Temp_normalizing_lufs" /s /q   |  Removing the temporary folder from the desktop
                                                                __|

Result of the Music1 audio file:

Input Integrated:    -13.3 LUFS
Input True Peak:      +1.6 dBTP
Input LRA:             6.1 LU
Input Threshold:     -23.4 LUFS

Output Integrated:   -11.8 LUFS
Output True Peak:     -0.5 dBTP
Output LRA:            4.5 LU
Output Threshold:    -21.9 LUFS

Normalization Type:   Dynamic
Target Offset:        +1.8 LU

Why doesn't the above value in the Output Integrated reach the LUFS of -10.0?
PS: even if I change the LUFS to -9.0, the Intregede Output value remains the same -11.8 LUFS.

I analyzed the Music1 audio using the volumedetect function, see the results below:

Output #0, null, to 'NUL':
  Metadata:
    title           : Music1
    TKEY            : F#m
    comment         : 
    album           : Electro's Remix
    genre           : Electro
    artist          : Chic
    encoder         : Lavf59.17.102
  Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
    Metadata:
      encoder         : Lavc59.21.100 pcm_s16le
size=N/A time=00:00:00.02 bitrate=N/A speed=2.61e+04x    
size=N/A time=00:04:30.26 bitrate=N/A speed= 541x    
size=N/A time=00:05:44.60 bitrate=N/A speed= 543x    
video:0kB audio:59364kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[Parsed_volumedetect_0 @ 0000022928c2e1c0] n_samples: 30394368
[Parsed_volumedetect_0 @ 0000022928c2e1c0] mean_volume: -15.7 dB
[Parsed_volumedetect_0 @ 0000022928c2e1c0] max_volume: 0.0 dB
[Parsed_volumedetect_0 @ 0000022928c2e1c0] histogram_0db: 13190
[Parsed_volumedetect_0 @ 0000022928c2e1c0] histogram_1db: 37702

In the result above that the max_volume parameter has a value of 0.0 dB.
Could this be the problem with normalization not reaching -10.0 that I set?

I applied a compressor in Music1 with the parameters:

Threshold: -25.00 db
Ratio  : 2.00:1
Attack : 0.25 ms
Release: 20.0 ms 

The result of the volumedetect function was:

Output #0, null, to 'NUL':
  Metadata:
    title           : Music1
    TKEY            : F#m
    comment         : 
    album           : Electro's Remix
    genre           : Electro
    artist          : Chic
    encoder         : Lavf59.17.102
  Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s
      Metadata:
        encoder         : Lavc61.5.104 pcm_s16le
[Parsed_volumedetect_0 @ 0000021002da5180] n_samples: 30392156
[Parsed_volumedetect_0 @ 0000021002da5180] mean_volume: -17.1 dB
[Parsed_volumedetect_0 @ 0000021002da5180] max_volume: -0.9 dB
[Parsed_volumedetect_0 @ 0000021002da5180] histogram_0db: 2
[Parsed_volumedetect_0 @ 0000021002da5180] histogram_1db: 9

Note above that the max_volume value has changed to -0.9 db

I performed audio normalization with the parameter LUFS = -10.0 and the True Peak = -0.0:

Input Integrated:    -14.6 LUFS
Input True Peak:      -0.7 dBTP
Input LRA:             4.6 LU
Input Threshold:     -24.6 LUFS

Output Integrated:   -10.5 LUFS
Output True Peak:     +0.0 dBTP
Output LRA:            3.8 LU
Output Threshold:    -20.5 LUFS

Normalization Type:   Dynamic
Target Offset:        +0.5 LU

Note above that the result of Output Integration was much better.

Results of the Music2 audio file:

Input Integrated:     -6.0 LUFS
Input True Peak:      +4.9 dBTP
Input LRA:             4.8 LU
Input Threshold:     -16.3 LUFS

Output Integrated:   -10.0 LUFS
Output True Peak:     -0.5 dBTP
Output LRA:            4.3 LU
Output Threshold:    -20.3 LUFS

Normalization Type:   Dynamic
Target Offset:        +0.0 LU

Results of the Music3 audio file:

Input Integrated:     -5.9 LUFS
Input True Peak:      +0.6 dBTP
Input LRA:             4.5 LU
Input Threshold:     -16.0 LUFS

Output Integrated:   -10.0 LUFS
Output True Peak:     -3.5 dBTP
Output LRA:            4.5 LU
Output Threshold:    -20.1 LUFS

Normalization Type:   Linear
Target Offset:        -0.0 LU

Why in the above audio files, Music2 uses Normalization Type: Dynamic and Music3 uses Normalization Type: Linear?... what rule defines when it is Dynamic and when it is Linear?

11
  • From just comparing numbers, I'd say you should try lowering the first file's input threshold to -16.0
    – JayCravens
    Commented May 26 at 0:33
  • @JayCravens It didn't work, the only thing that changed was the Output Threshold to -21.8 LUFS... I think this audio must have some limitation that doesn't allow it to reach -10.0 LUFS!
    – Clamarc
    Commented May 26 at 8:39
  • Only a .1 difference. Yeah, that's an weird one. Are the mp3's 44100? Try .wav. You could try converting them to PCM 16-bit 48000k. That will give you more frequency range for potential adjustment.
    – JayCravens
    Commented May 26 at 12:33
  • @JayCravens yes the mp3 is 44100... are you suggesting that I transform the mp3 to wav with 48000 normalize and then return the wav to mp3 with 44100? Ps: I need the audio in mp3, ok?
    – Clamarc
    Commented May 26 at 14:09
  • Yup, that's correct. Try the processing with an uncompressed file with full range. It's worth a shot. If it works it works, the re-compression won't harm what the wav changed. I've found it's the secret, most of the time, to success. Do all processing as PCM in nearly all use cases with filtering.
    – JayCravens
    Commented May 26 at 14:24

1 Answer 1

0

I looked up LUFS. I didn't know, exactly, what LUFS was doing, and it's purely dB range. The file's max. volume of 0dB, shows there's parts of the song that are already at peak. So, -11.8 LUFS, is the loudest it can be, or it will clip (or redline and distort) the audio.

Compressor is how you can lower the peak. This will show you the concept of using compressors.

This is going to really smash it, because it's addressing red lined audio, but it's exactly the same thing you want. Just don't go as low on the noise floor and threshold.

For clipped audio, a faster attack time will help catch the peaks, but slower release times provide a more natural sound. Do the make-up gain after compression. I like to use "loudness normalization" after a compressor. If you still have available peak after that, do a standard 0.0dB amplify.

8
  • I did a test using a compressor on the Music1 audio and posted the results in my question. If you could analyze the values ​​I used in the compressor, I would appreciate it.
    – Clamarc
    Commented Jun 2 at 19:58
  • with the parameters you suggested, Output Integrated improved over -10.2 LUFS.
    – Clamarc
    Commented Jun 2 at 22:33
  • @Clamarc Excellent! Determination wins the race!
    – JayCravens
    Commented Jun 3 at 11:12
  • Thank's for your help.
    – Clamarc
    Commented Jun 3 at 21:26
  • When I normalize some audio using True Pak with a value of -0.5, parts of the normalized audio have higher volume peaks... I'll open another question about this problem and let you know if I can take a look at this problem too.
    – Clamarc
    Commented Jun 3 at 21:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .