我使用 Ffmpeg 中的 Loundnorm 过滤器,使用双通道方法对包含三个音频(Music1.mp3、Music2.mp3 和 Music3.mp3)的文件夹中的 LUFS 进行标准化。
所有音频文件的 LUFS 和真实峰值都相同:
LUFS -10.0 and True Peak -0.5
代码:
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
__|
Music1 音频文件的结果:
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
为什么上面的Output Integrated 值没有达到LUFS -10.0?
PS:即使我将 LUFS 更改为 -9.0,Intregede 输出值仍保持不变 -11.8 LUFS。
我使用volumeDetect函数分析了Music1音频,结果如下:
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
在上面的结果中,max_volume参数的值为 0.0 dB。
这可能是归一化未达到我设置的-10.0 的问题吗?
我在 Music1 中应用了压缩器,参数如下:
Threshold: -25.00 db
Ratio : 2.00:1
Attack : 0.25 ms
Release: 20.0 ms
VolumeDetect 函数的结果是:
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
请注意上面max_volume值已更改为-0.9 db
我使用参数LUFS = -10.0
和执行音频标准化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
请注意,上面输出积分的结果要好得多。
Music2 音频文件的结果:
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
Music3 音频文件的结果:
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
为什么在上述音频文件中,Music2 使用归一化类型:动态,而 Music3 使用归一化类型:线性?...什么规则定义了何时为动态、何时为线性?