I have a bat file that reads several audio files in the "µudios LUFS" folder and performs LUFS normalization by copying the files to the "Normalized µudios Lufs" folder.
I'm trying to generate the log of each file, with its respective name, in another folder called Logs.
On the command line where the files will be normalized, I use -report:
-report file="%Userprofile%\Desktop\Logs\!filename!.mp3.log":level=24
Code:
md "C:\Users\%username%\Desktop\Temp_normalizing_lufs" ------> temp folder audio files being normalized
pushd "%Userprofile%\Desktop\µudios 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 (
SET FFREPORT=file="C:\Users\%username%\Desktop\Logs\!filename!.log":level=24 ffmpeg -hide_banner -i "!filename!.mp3" -af "loudnorm=linear=true:I=!-10.0!:LRA=11:tp=!-0.1!: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 µudios 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
__|
Error log message:
Successfully opened the file.
Parsing a group of options: output url file=ACDC - Jailbreak.mp3.log:level=24.
Successfully parsed a group of options.
Opening an output file: file=ACDC - Jailbreak.mp3.log:level=24.
[NULL @ 0000021f879b8680] Unable to find a suitable output format for 'file=ACDC - Jailbreak.mp3.log:level=24'
file=ACDC - Jailbreak.mp3.log:level=24: Invalid argument
[AVIOContext @ 0000021f87967840] Statistics: 131072 bytes read, 0 seeks
Ps: Log files are generated in the original audio folder with the name ffmpeg-20240427-105701.log (without the audio name) and bat does not convert the audio.
How do I create log files, with the name of each audio, in another folder?
Баяр Гончикжапов
i insert your suggestion in my bat, but no works, see the change in my question.
Ps: In my bat, the FFREPORT environment variable only works if I put SET before it.
I used command to change the log file path to another folder, shown in this link, but it did not work:
Creating a log file for my ffmpeg output
Command:
SET FFREPORT=file="C:\Users\%username%\Desktop\Logs\!filename!.log":level=24
Ps2: the command is inside a DO loop, because bat will convert several audios in the folder.
Results:
the path does not work, the log file is generated in the same folder as the audio files, then it is automatically deleted and bat does not convert the audio files.
-report
doesn't have argument. Try to set environment variableFFREPORT
...s\!filename!.mp3" -v 24 2>"C:\Users\%username%\Desktop\Logs\!filename!.log"
cd "C:\Users\%username%\Desktop\Logs"
thenmd "!filename!"
thencd "!filename!"
then runffmpeg -report ...
but level will be 48