[FFmpeg-user] Get sample rate in mp3 files

Reindl Harald h.reindl at thelounge.net
Mon Feb 7 03:29:16 EET 2022



Am 07.02.22 um 02:25 schrieb CMG DiGiTaL:
> Hi,
> I'm creating a bat file that will access a folder with several mp3 files. I
> would like to be able to select in this folder only the mp3s with a sample
> rate of 48000 khz and copy them to another folder where I will change from
> 48000 khz to 44100 khz. What command can I use to select only 48000kHz mp3
> from original folder to destination folder?  I will use ffmpeg in a batch
> file.

you need to parse the output the same way as for other infos

Stream #0:0: Audio: mp3, 48000 Hz, stereo, fltp, 277 kb/s

-----------------

[harry at srv-rhsoft:/audio/Steve Vai/Inviolate]$ ffmpeg -i 'Steve Vai - 
Apollo In Color.mp3'
ffmpeg version 5.0 Copyright (c) 2000-2022 the FFmpeg developers
   built with gcc 11 (GCC)
   configuration: --prefix=/usr/local --bindir=/usr/local/bin 
--mandir=/usr/local/man 
--extra-cflags='-I/rpmbuild/BUILD/ffmpeg-20220201/x264-static -m64 -O2 
-g0 -march=sandybridge -mtune=sandybridge -mno-avx512f -mfpmath=sse 
-msse2avx -ftree-slp-vectorize -fopenmp -pipe -fno-strict-aliasing 
-fomit-frame-pointer -fexceptions -fno-asynchronous-unwind-tables 
-fstack-protector-strong --param=ssp-buffer-size=6 
-Wp,-D_FORTIFY_SOURCE=2 -w -Wformat -Werror=format-security -fPIC -O3 
-mno-avx512f -fno-strict-aliasing -fno-tree-vectorize 
-ftree-slp-vectorize -fno-gcse-after-reload -fno-inline-functions 
-fno-ipa-cp -fno-ipa-cp-clone -fno-peel-loops -fno-predictive-commoning 
-fno-tree-loop-distribute-patterns -fno-unswitch-loops -flto=8 
-fwhole-program -w' 
--extra-ldflags='-I/rpmbuild/BUILD/ffmpeg-20220201/x264-static 
-L/rpmbuild/BUILD/ffmpeg-20220201/x264-static -ldl -Wl,--as-needed 
-Wl,-z,now -Wl,-z,relro -m64 -O2 -g0 -march=sandybridge 
-mtune=sandybridge -mno-avx512f -mfpmath=sse -msse2avx 
-ftree-slp-vectorize -fopenmp -pipe -fno-strict-aliasing 
-fomit-frame-pointer -fexceptions -fno-asynchronous-unwind-tables 
-fstack-protector-strong --param=ssp-buffer-size=6 
-Wp,-D_FORTIFY_SOURCE=2 -w -Wformat -Werror=format-security -fPIC -O3 
-mno-avx512f -fno-strict-aliasing -fno-tree-vectorize 
-ftree-slp-vectorize -fno-gcse-after-reload -fno-inline-functions 
-fno-ipa-cp -fno-ipa-cp-clone -fno-peel-loops -fno-predictive-commoning 
-fno-tree-loop-distribute-patterns -fno-unswitch-loops -flto=8 
-fwhole-program -pie -fPIE -w' --ar=gcc-ar --ranlib=true --enable-lto 
--enable-gpl --enable-libmp3lame --enable-libtheora --enable-libvpx 
--enable-libx264 --enable-libx265 --enable-nonfree --enable-openssl 
--enable-pic --enable-runtime-cpudetect --enable-static 
--enable-version3 --disable-amf --disable-appkit --disable-autodetect 
--disable-avdevice --disable-avfoundation --disable-coreimage 
--disable-debug --disable-devices --disable-ffplay --disable-ffprobe 
--disable-htmlpages --disable-hwaccels --disable-iconv 
--disable-libdc1394 --disable-libfreetype --disable-libgsm 
--disable-libopencore-amrnb --disable-libopencore-amrwb 
--disable-libopencv --disable-libopenjpeg --disable-libopus 
--disable-librtmp --disable-libspeex --disable-libvorbis 
--disable-libxcb --disable-libxcb-shape --disable-libxcb-shm 
--disable-libxcb-xfixes --disable-libxvid --disable-podpages 
--disable-postproc --disable-protocol=gopher --disable-shared 
--disable-txtpages --disable-xlib
   libavutil      57. 17.100 / 57. 17.100
   libavcodec     59. 18.100 / 59. 18.100
   libavformat    59. 16.100 / 59. 16.100
   libavfilter     8. 24.100 /  8. 24.100
   libswscale      6.  4.100 /  6.  4.100
   libswresample   4.  3.100 /  4.  3.100
Input #0, mp3, from 'Steve Vai - Apollo In Color.mp3':
   Metadata:
     title           : Apollo In Color
     artist          : Steve Vai
     album           : Inviolate
     genre           : Instrumental Rock
     date            : 2022
   Duration: 00:04:18.84, start: 0.000000, bitrate: 277 kb/s
   Stream #0:0: Audio: mp3, 48000 Hz, stereo, fltp, 277 kb/s


More information about the ffmpeg-user mailing list