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

CMG DiGiTaL cmarciog at gmail.com
Sun Feb 20 03:31:48 EET 2022


> Why do you think you need EnableDelayedExpansion?

Because when I remove EnableDelayedExpansion, the script does not recognize
some variables, the script follows without using EnableDelayedExpansion :

ps: as I'm learning, maybe some procedure in my script can be done
otherwise it can be optimized.
ps2: if you want to put EnableDelayedExpansion to see how it behaves, feel
free!

@echo off
chcp 65001
cls
REM
**************************************************************************************************************************
REM *                                                       LUFS Converter
                                                  *
REM *
                                                 *
REM
**************************************************************************************************************************
REM *  The purpose of this Script is to read several audio files in a
folder and change the LUFS value according to the      *
REM *                           target value entered by the user along with
the real true peak value.                        *
REM
**************************************************************************************************************************
REM SETLOCAL ENABLEDELAYEDEXPANSION
ENDLOCAL
SETLOCAL ENABLEEXTENSIONS
echo.-------------------------------------------------------------------------------------------------------------------

echo                                                  LUFS Converter Áudio
echo.-------------------------------------------------------------------------------------------------------------------
set /p folder= Enter the FOLDER NAME audios:
set /p vluf= Enter the target LUFS VALUE:
set /p vpeak= Enter Real True Peak VALUE:
echo.-------------------------------------------------------------------------------------------------------------------
cd\Users\%username%\Desktop\%folder%
md "C:\Users\%username%\Desktop\Converting_lufs"
FOR %%a IN (*.mp3) DO (
    ffmpeg -i "%%a" -filter_complex
"[0:a]loudnorm=I=-15:TP=-1.5:LRA=11:print_format=summary" -f null x 2>%1.txt
    @for /f "tokens=3" %%b in ('findstr /C:"Input Integrated" %1.txt') do
(set II=%%b)
    echo %II% is the Input Integrated
    @for /f "tokens=4" %%b in ('findstr /C:"Input True Peak" %1.txt') do
(set ITP=%%b)
    echo %ITP% is the Input True Peak
    @for /f "tokens=3" %%b in ('findstr /C:"Input LRA" %1.txt') do (set
ILRA=%%b)
    echo %ILRA% is the Input LRA
    @for /f "tokens=3" %%b in ('findstr /C:"Input Threshold" %1.txt') do
(set IT=%%b)
    echo %IT% is the Input Threshold
    @for /f "tokens=3" %%b in ('findstr /C:"Output Integrated" %1.txt') do
(set OI=%%b)
    echo %OI% is the Output Integrated
    @for /f "tokens=4" %%b in ('findstr /C:"Output True Peak" %1.txt') do
(set OTP=%%b)
    echo %OTP% is the Output True Peak
    @for /f "tokens=3" %%b in ('findstr /C:"Output LRA" %1.txt') do (set
OLRA=%%b)
    echo %OLRA% is the Output LRA
    @for /f "tokens=3" %%b in ('findstr /C:"Output Threshold" %1.txt') do
(set OT=%%b)
    echo %OT% is the Output Threshold
    @for /f "tokens=3" %%b in ('findstr /C:"Target Offset" %1.txt') do (set
TO=%%b)
    echo %TO% is the Target Offset
    ffmpeg -i "%%a" -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
-acodec mp3 -b:a 192k -ar:a 44100
"C:\Users\%username%\Desktop\Converting_lufs\%%a"
)
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
IF NOT EXIST "C:\Users\%username%\Desktop\Converted LUFS Audio" (
echo.-------------------------------------------------------------------------------------------------------------------

echo                                        No Audios found for LUFS
Conversion^!^
echo.-------------------------------------------------------------------------------------------------------------------
) ELSE (
echo.-------------------------------------------------------------------------------------------------------------------
echo                                           ****     IMPORTANT^!^
****
echo.
echo                 Upon completion of this program, the CONVERTED LUFS
FILES will be on your ^(Desktop^)
echo          in the folder named "Converted LUFS Audios" so that you can
move them wherever you want on your PC.
echo                   After moving the files, you can delete the Converted
LUFS Audios folder.
echo.
echo.-------------------------------------------------------------------------------------------------------------------
)
pause

Thanks
Clamarc

Em sáb., 19 de fev. de 2022 às 21:46, Mark Filipak <
markfilipak.noreply at gmail.com> escreveu:

> On 2022-02-19 18:37, CMG DiGiTaL wrote:
> > hi Mark,
> > you're the same Mark who helped me with the Sample Rate Conversion code
> > right?...
>
> Yes.
>
> > nice talking to you again... thanks for that help!
> > ... so in that sample rate code, we had the same problem with the
> > exclamation mark, remember?...
>
> Not the same. I think you are misunderstanding what EnableDelayedExpansion
> does.
>
> > but you mentioned EnableDelayedExpansion and
> > I removed it from the code and it worked.
>
> That code didn't need it. I suspect your code now does need it.
>
> > The same thing happened here, only when I removed the
> > EnableDelayedExpansion, the code gives these variables messages, which
> did
> > not happen in the other one....
> >
> > ....it's all very strange a code practically the same, I just removed the
> > EnableDelayedExpansion and it worked... in this code this solution
> doesn't
> > work!...
> >
> > so, in this code with problems in the variables, I'll have to create a
> > routine to analyze the input file, remove the exclamation, then, in the
> > output, rewrite the file putting the exclamation?... is that it?
>
> Why do you think you need EnableDelayedExpansion?
>
> What is your script? Show it.
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".
>


More information about the ffmpeg-user mailing list