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.
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?