[FFmpeg-user] How can I read multiple audio files in a folder to convert LUFS value?

CMG DiGiTaL cmarciog at gmail.com
Thu Feb 17 17:04:16 EET 2022


hi,

I made a batch file code to change the LUFS of my Audio Files and it is
working and converting the files ok. Turns out it only does this for one
file at a time.
How can I make it convert multiple files at once?... see my code that is
generating one file at a time:

@echo off
chcp 65001
cls
ENDLOCAL
SETLOCAL ENABLEEXTENSIONS
echo.-------------------------------------------------------------------------------------------------------------------------

echo                              Converter LUFS Áudio File (File entry and
setting LUFS and True Peak values)
echo.-------------------------------------------------------------------------------------------------------------------------
set /p folder= Enter the FOLDER NAME where the audios to be converted are
located:
set /p filename= Enter the FULL NAME OF THE FILE to be converted (eg
lalala.mp3):
set /p vluf= Enter the LUFS VALUE you want to achieve:
set /p tpeak= Enter the True Peak VALUE of the audio:
echo.-------------------------------------------------------------------------------------------------------------------------
REM
--------------------------------------------------------------------------------------------------------------------------

REM                                          Read the file to convert the
LUFS value
REM
--------------------------------------------------------------------------------------------------------------------------
cd\Users\%username%\Desktop\%folder%
ffmpeg -report -i "%filename%" -filter_complex
"[0:a]loudnorm=I=-10:TP=-0.0:LRA=11:print_format=summary" -f null x 2>%1.txt
@for /f "tokens=3" %%a in ('findstr /C:"Input Integrated" %1.txt') do (set
II=%%a)
echo %II% is the Input Integrated
@for /f "tokens=4" %%a in ('findstr /C:"Input True Peak" %1.txt') do (set
ITP=%%a)
echo %ITP% is the Input True Peak
@for /f "tokens=3" %%a in ('findstr /C:"Input LRA" %1.txt') do (set
ILRA=%%a)
echo %ILRA% is the Input LRA
@for /f "tokens=3" %%a in ('findstr /C:"Input Threshold" %1.txt') do (set
IT=%%a)
echo %IT% is the Input Threshold
@for /f "tokens=3" %%a in ('findstr /C:"Output Integrated" %1.txt') do (set
OI=%%a)
echo %OI% is the Output Integrated
@for /f "tokens=4" %%a in ('findstr /C:"Output True Peak" %1.txt') do (set
OTP=%%a)
echo %OTP% is the Output True Peak
@for /f "tokens=3" %%a in ('findstr /C:"Output LRA" %1.txt') do (set
OLRA=%%a)
echo %OLRA% is the Output LRA
@for /f "tokens=3" %%a in ('findstr /C:"Output Threshold" %1.txt') do (set
OT=%%a)
echo %OT% is the Output Threshold
@for /f "tokens=3" %%a in ('findstr /C:"Target Offset" %1.txt') do (set
TO=%%a)
echo %TO% is the Target Offset
md "C:\Users\%username%\Desktop\converting_lufs"
REM
--------------------------------------------------------------------------------------------------------------------------

REM                                   Generating the audio file with the
converted LUFS value
REM
--------------------------------------------------------------------------------------------------------------------------
ffmpeg -report -show_error -i "%filename%" -af
loudnorm=linear=true:I=%vluf%:LRA=11:tp=%tpeak%:measured_I=%II%:measured_LRA=%ILRA%:measured_tp=%ITP%:measured_thresh=%IT%:offset=%TO%:print_format=summary
-acodec mp3 -b:a 192k -ar:a 44100
"C:\Users\%username%\Desktop\converting_lufs\%filename%"

REM
--------------------------------------------------------------------------------------------------------------------------

REM                                   Copying the generated file to the
folder "Converted LUFS Audio"
REM
--------------------------------------------------------------------------------------------------------------------------
IF EXIST "C:\Users\%username%\Desktop\converting_lufs\*.mp3" (
xcopy "C:\Users\%username%\Desktop\converting_lufs\*.mp3"
"C:\Users\%username%\Desktop\Converted LUFS Audio\" /y /s /i
)
del /q "C:\Users\%username%\Desktop\converting_lufs\*.*"
del /q "C:\Users\%username%\Desktop\%folder%\%1.txt"
rmdir "C:\Users\%username%\Desktop\converting_lufs" /s /q
pause

thanks
Clamarc


More information about the ffmpeg-user mailing list