我想在MacOS平台上编写一个bash脚本,它将使用ALAC编码对m4a
个文件执行不同的操作,具体取决于它们是立体声还是单声道。我怎样才能进行立体声/单声道检测?我可以使用任何工具/库吗?谢谢。
答案 0 :(得分:0)
使用https://ffmpeg.org/ffprobe.html
if ffprobe -i the-audio-file.mp4 |& grep stereo; then
echo stereo
else
echo mono
fi
用作ffprobe将输出如下结果:
ffprobe version 3.4.2 Copyright (c) 2007-2018 the FFmpeg developers
built with Apple LLVM version 9.0.0 (clang-900.0.39.2)
configuration: --prefix=/usr/local/Cellar/ffmpeg/3.4.2 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --disable-jack --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-opencl --enable-videotoolbox --disable-lzma --enable-nonfree
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libavresample 3. 7. 0 / 3. 7. 0
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'the-audio-file.mp4':
Metadata:
major_brand : M4A
minor_version : 0
compatible_brands: M4A mp42isom
creation_time : 2018-01-27T18:53:31.000000Z
track : 0
disc : 0
Duration: 04:59:13.02, start: 0.000000, bitrate: 381 kb/s
Stream #0:0(eng): Audio: alac (alac / 0x63616C61), 44100 Hz, stereo, s16p, 381 kb/s (default)
Metadata:
creation_time : 2018-01-27T18:53:31.000000Z
0 0 0
注意,由于this bug in ffprobe
,这对he-aac不起作用