我正在使用通过 Homebrew 安装的 libav 9.6。
$ avprobe -version
avprobe version 9.6, Copyright (c) 2007-2013 the Libav developers
built on Jun 8 2013 02:44:19 with Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)
avprobe 9.6
libavutil 52. 3. 0 / 52. 3. 0
libavcodec 54. 35. 0 / 54. 35. 0
libavformat 54. 20. 3 / 54. 20. 3
libavdevice 53. 2. 0 / 53. 2. 0
libavfilter 3. 3. 0 / 3. 3. 0
libavresample 1. 0. 1 / 1. 0. 1
libswscale 2. 1. 1 / 2. 1. 1
即使采样率显示在命令行输出的标准输出中,该-show_format
选项根本不会显示音频文件的采样率信息。
这是 BASH 终端输出:
$ avprobe -v verbose -show_format -of json sample.gsm
avprobe version 9.6, Copyright (c) 2007-2013 the Libav developers
built on Jun 8 2013 02:44:19 with Apple LLVM version 4.2 (clang-425.0.24)
(based on LLVM 3.2svn)
configuration: --prefix=/usr/local/Cellar/libav/9.6 --enable-shared
--enable-pthreads --enable-gpl --enable-version3 --enable-nonfree
--enable-hardcoded-tables --enable-avresample --enable-vda --enable-gnutls
--enable-runtime-cpudetect --disable-indev=jack --cc=cc --host-cflags=
--host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame
--enable-libxvid --enable-avplay
libavutil 52. 3. 0 / 52. 3. 0
libavcodec 54. 35. 0 / 54. 35. 0
libavformat 54. 20. 3 / 54. 20. 3
libavdevice 53. 2. 0 / 53. 2. 0
libavfilter 3. 3. 0 / 3. 3. 0
libavresample 1. 0. 1 / 1. 0. 1
libswscale 2. 1. 1 / 2. 1. 1
[gsm @ 0x7f8012806600] Estimating duration from bitrate, this may be inaccurate
Input #0, gsm, from 'sample.gsm':
Duration: 00:03:52.32, start: 0.000000, bitrate: 13 kb/s
Stream #0.0: Audio: gsm, 8000 Hz, mono, s16, 13 kb/s
{ "format" : {
"filename" : "sample.gsm",
"nb_streams" : 1,
"format_name" : "gsm",
"format_long_name" : "raw GSM",
"start_time" : "0.000000",
"duration" : "232.320000",
"size" : "383328.000000",
"bit_rate" : "13200.000000"
}}
和python代码示例:
>>> filename = 'sample.gsm'
>>> result = subprocess.check_output(['avprobe', '-show_format', '-of',
'json', filename])
avprobe version 9.6, Copyright (c) 2007-2013 the Libav developers
built on Jun 8 2013 02:44:19 with Apple LLVM version 4.2
(clang-425.0.24) (based on LLVM 3.2svn)
[gsm @ 0x7fe0b1806600] Estimating duration from bitrate, this may be
inaccurate
Input #0, gsm, from 'sample.gsm':
Duration: 00:03:52.32, start: 0.000000, bitrate: 13 kb/s
Stream #0.0: Audio: gsm, 8000 Hz, mono, s16, 13 kb/s
>>> print result
{ "format" : {
"filename" : "sample.gsm",
"nb_streams" : 1,
"format_name" : "gsm",
"format_long_name" : "raw GSM",
"start_time" : "0.000000",
"duration" : "232.320000",
"size" : "383328.000000",
"bit_rate" : "13200.000000"
}}
所以我知道采样率可能是在-show_format
选项结果中显示的特定于流的显示。但是没有任何其他选项可以检测特定音频流的采样率,即使可以-ar
在重新编码时设置它。
我向 libav 提交了一张票,但我只是好奇是否有任何其他方法可以从 libav 探测工具中提取采样率。我很感激事先的回答。
PS:在这种情况下,对于ffmpeg(ffprobe)的上游项目将是相同的问题。