[FFmpeg-user] Get sample rate in mp3 files

CMG DiGiTaL cmarciog at gmail.com
Mon Feb 21 04:35:35 EET 2022

hi Reino,

ok, but I liked your idea of putting the convert at the end of the file! so
I don't need to create another folder...
...regarding quality, I have a large majority of FLAC audios, I think these
commands work for FLAC too, right?!

Thank you very much for your help.. It was really appreciated!


Em dom., 20 de fev. de 2022 às 22:44, Reino Wijnsma <rwijnsma at xs4all.nl>

> On 2022-02-21T01:38:30+0100, CMG DiGiTaL <cmarciog at gmail.com> wrote:
> > OK, I would also need, along with the sample rate, to get the bitrate of
> > the file, because I realized that in the conversion, because I'm using
> > --acodec -b:a 320k, it's passing all the aidios to 320 kbps... until even
> > 192 kbps audio!. is there a way in the conversion I can get the correct
> > bitrate of each file?
> You could do...
> ffprobe -v 0 -show_entries stream=bit_rate,sample_rate -of csv=p=0
> "input.mp3"
> ...which would return for instance:
> 48000,128000
> Then within the FOR-loop set the delimiter to the comma:
> FOR %A IN (*.mp3) DO @FOR /F "tokens=1,2 delims=," %B IN ('ffprobe -v 0
> -show_entries stream^=bit_rate^,sample_rate -of csv^=p^=0 "%A"') DO @IF %B
> EQU 48000 ffmpeg -hide_banner -i "%A" -c:a libmp3lame -b:a %C -ar 44100
> "..\48000 sample rates Audio\%A"
> ...or prettified:
> FOR %A IN (*.mp3) DO @(
>   FOR /F "tokens=1,2 delims=," %B IN ('ffprobe -v 0 -show_entries
> stream^=bit_rate^,sample_rate -of csv^=p^=0 "%A"') DO @(
>     IF %B EQU 48000 ffmpeg -hide_banner -i "%A" -c:a libmp3lame -b:a %C
> -ar 44100 "..\48000 sample rates Audio\%A"
>   )
> )
> - Notice the -b:a %C.
> - Initially I had %~nA_converted.mp3 for the output, but if you want the
> original filename (seeing they're being dumped into a separate directory
> anyway), then you can just as well enter %A.
> Note: lossy to lossy conversions are NOT recommended quality wise.
> Especially with a low bitrate. Always try to use the lossless source as
> much as possible!
> --
> 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