[FFmpeg-user] Batch conversion LUFS to multiple audio formats
CMG DiGiTaL
cmarciog at gmail.com
Mon Mar 28 19:15:31 EEST 2022
hi,
I have a bat that converts LUFS from audio files, but it only converts to
.mp3 files. How do I get it to convert any type of audio?
I tried to add two variables in the for command, but it doesn't work,
eg.
In:
FOR %%a IN (*.mp3) DO (
SET "filename=%%~na"
I tried:
FOR %%a %%e IN (*.*) DO (
SET "filename=%%~na"
SET "extension=%%~xe"
The FOR command looks like it doesn't accept two variables!
see the batch file below:
echo.-------------------------------------------------------------------------------------------------------------------------
echo LUFS Audio Converter
echo.-------------------------------------------------------------------------------------------------------------------------
set /p audios_folder= Type the Folder Name:
set /p vLUF= Type the LUFS Value:
set /p vPEAK= Type the True Peak Values:
echo.-------------------------------------------------------------------------------------------------------------------------
cd\Users\%username%\Desktop\%audios_folder%
FOR %%a IN (*.mp3) 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)
@FOR /F "tokens=3" %%b IN ('FINDSTR /C:"Input LRA" "%%~na.log"') DO (SET
ILRA=%%b)
@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
ECHO !II! is the Input Integrated
ECHO !ITP! is the Input True Peak
ECHO !ILRA! is the Input LRA
ECHO !IT! is the Input Threshold
ECHO !TO! is the Target Offset
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"') DO (
ffmpeg -hide_banner -i "!filename!.mp3" -af
"loudnorm=linear=true:I=!vLUF!:LRA=11:tp=!vPEAK!:measured_I=!II!:measured_LRA=!ILRA!:measured_tp=!ITP!:measured_thresh=!IT!:offset=!TO!:print_format=summary"
-c:v copy -id3v2_version 3 -acodec mp3 -b:a %%c -ar:a %%b "..\LUFS
Audio\!filename!_LUFS_CONVERTED.mp3"
)
ENDLOCAL
)
More information about the ffmpeg-user
mailing list