[FFmpeg-user] Fwd: Get sample rate in mp3 files

CMG DiGiTaL cmarciog at gmail.com
Tue Feb 22 08:32:05 EET 2022

hi Reino,

thanks for the clarifications...

> FOR *%G* IN (*.mp3) DO (
 Please don't do this. I understand you're trying to emphasize parts of

   it was because I took part of the sample rate command that you sent me
to be able to use it in my batch file that I already had here, you know?...
I'm sorry about that!

...with regard to ENABLEDELAYEDEXPANSION, I put the question of this batch
LUFS here, because I already have it working in batch file with
he problem that is driving me crazy, is that as some audio files have the
exclamation mark in the name, using the ENABLEDELAYEDEXPANSION, the batch
cancels because it
doesn't recognize the files with the exclamation mark, so I'm trying
another way to make it work without using the ENABLEDELAYEDEXPANSION so
that I can have a batch file
that reads all files without giving problems.

ps. this ENABLEDELAYEDEXPANSION problem, with the exclamation mark, is
killing me...
...because I can't get my batch file to read all files without problems..
so what I'm doing is, taking the exclamation mark out of the files, running
the batch and then putting the
exclamation mark on the files manually!


Em seg., 21 de fev. de 2022 às 22:02, Reino Wijnsma <rwijnsma at xs4all.nl>

> On 2022-02-21T08:52:44+0100, CMG DiGiTaL <cmarciog at gmail.com> wrote:
> > I did these commands below
> This has nothing to with your initial question "Get sample rate in mp3
> files", or even FFmpeg. This is in fact a question about CMD and Batch.
> I will respond to this now, but I don't believe questions like these are
> for the ffmpeg-user mailinglist.
> I know CMD / Batch, but to be honest I don't know enough about FFmpeg's
> features to know what LUFS is/does. So I can't comment on whether this is a
> useful approach or not.
> I can see you're trying to parse a loudnorm log and use these values in
> another FFmpeg call. A rather inefficient process, calling the txt-file
> multiple times with FINDSTR, if you ask me. Especially because you can
> enter print_format=json for the loudnorm-filter.
> > - Can I use a command of this size directly in cmd?
> Sure. The amount of characters doesn't come near CMD's commandline buffer
> of 8192 bytes.
> But you're gonna need delayed expansion for this, so I'd say you're better
> off creating a bat-file.
> > FOR *%G* IN (*.mp3) DO (
> Please don't do this. I understand you're trying to emphasize parts of
> code, but in this particular case it's not bold printed, which raises the
> question if it's part of the code or not.
> >   set vluf=-10.0
> >   set vpeak=-0.0
> If these are always the same value for each mp3-file, then I would've
> declared them before the FOR-loop.
> >   @for /f "delims=" *%A* IN ('ffprobe -v 0 -show_entries
> *stream^=bit_rate*
> > -of csv^=p^=0 "*%G*"')
> This FFprobe call shouldn't be here. It should be right before the final
> FFmpeg call.
> >   *ffmpeg* -i "%G" -filter_complex
> > "[0:a]loudnorm=I=-15:TP=-1.5:LRA=11:print_format=summary" -f null x
> 2>%1.txt
> On Linux the convention is -f null /dev/null, but on Windows it's -f null
> NUL.
> I would recommend naming a file "%1". Could cause lots of problems.
> >   echo "%II" is the Input Integrated
> You forgot the closing % --> %II%. Only FOR-loop variables work without a
> closing %.
> >   @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)
> You don't seem to be using these variables in the final FFmpeg call, so
> why extract them?
> I'd recommend this for a Batch-file:
> @ECHO off
> SET vluf=-10.0
> SET vpeak=-0.0
> FOR %%A IN (*.mp3) DO (
>   ffmpeg -hide_banner -i "%%A" -af
> "loudnorm=I=-15:TP=-1.5:LRA=11: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)
>   ECHO !II! is the Input Integrated
>   @FOR /F "tokens=4" %%B IN ('FINDSTR /C:"Input True Peak" "%%~nA.log"')
> DO (SET ITP=%%B)
>   ECHO !ITP! is the Input True Peak
>   @FOR /F "tokens=3" %%B IN ('FINDSTR /C:"Input LRA" "%%~nA.log"') DO (SET
> ILRA=%%B)
>   ECHO !ILRA! is the Input LRA
>   @FOR /F "tokens=3" %%B IN ('FINDSTR /C:"Input Threshold" "%%~nA.log"')
> DO (SET IT=%%B)
>   ECHO !IT! is the Input Threshold
>   @FOR /F "tokens=3" %%B IN ('FINDSTR /C:"Target Offset" "%%~nA.log"') DO
> (SET TO=%%B)
>   ECHO !TO! is the Target Offset
>   FOR /F "delims=" %%B IN ('ffprobe -v 0 -show_entries stream^=bit_rate
> -of default^=nk^=1:nw^=1 "%%A"') DO ffmpeg -hide_banner -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"
> -c:a libmp3lame -b:a %%B "..\Áudios LUFS ORI\%%~nA_LUFS_CONVERTED.mp3"
> )
> --
> Reino
> _______________________________________________
> 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