我需要能够扫描视频文件并报告哪些音轨/声道是静音的,而无需事先了解文件的音频映射。我已在包含 16 个音频通道的文件上尝试了此 ffmpeg (v4.1) 命令:
$ ffmpeg -i foo5.mxf -map 0:a -af astats -f null -
...
Stream mapping:
Stream #0:1 -> #0:0 (pcm_s24be (native) -> pcm_s16le (native))
Stream #0:2 -> #0:1 (pcm_s24be (native) -> pcm_s16le (native))
Stream #0:3 -> #0:2 (pcm_s24be (native) -> pcm_s16le (native))
Stream #0:4 -> #0:3 (pcm_s24be (native) -> pcm_s16le (native))
Stream #0:5 -> #0:4 (pcm_s24be (native) -> pcm_s16le (native))
Stream #0:6 -> #0:5 (pcm_s24be (native) -> pcm_s16le (native))
Stream #0:7 -> #0:6 (pcm_s24be (native) -> pcm_s16le (native))
Stream #0:8 -> #0:7 (pcm_s24be (native) -> pcm_s16le (native))
Stream #0:9 -> #0:8 (pcm_s24be (native) -> pcm_s16le (native))
Stream #0:10 -> #0:9 (pcm_s24be (native) -> pcm_s16le (native))
Stream #0:11 -> #0:10 (pcm_s24be (native) -> pcm_s16le (native))
Stream #0:12 -> #0:11 (pcm_s24be (native) -> pcm_s16le (native))
Stream #0:13 -> #0:12 (pcm_s24be (native) -> pcm_s16le (native))
Stream #0:14 -> #0:13 (pcm_s24be (native) -> pcm_s16le (native))
Stream #0:15 -> #0:14 (pcm_s24be (native) -> pcm_s16le (native))
Stream #0:16 -> #0:15 (pcm_s24be (native) -> pcm_s16le (native))
...
[Parsed_astats_0 @ 0x9123c0] Channel: 1
[Parsed_astats_0 @ 0x9123c0] DC offset: 0.000070
[Parsed_astats_0 @ 0x9123c0] Min level: -170426368.000000
[Parsed_astats_0 @ 0x9123c0] Max level: 172195840.000000
[Parsed_astats_0 @ 0x9123c0] Min difference: 0.000000
[Parsed_astats_0 @ 0x9123c0] Max difference: 58281984.000000
[Parsed_astats_0 @ 0x9123c0] Mean difference: 3089081.855667
[Parsed_astats_0 @ 0x9123c0] RMS difference: 4825348.720329
[Parsed_astats_0 @ 0x9123c0] Peak level dB: -21.918144
[Parsed_astats_0 @ 0x9123c0] RMS level dB: -34.035425
[Parsed_astats_0 @ 0x9123c0] RMS peak dB: -27.320939
[Parsed_astats_0 @ 0x9123c0] RMS trough dB: -48.414915
[Parsed_astats_0 @ 0x9123c0] Crest factor: 4.035190
[Parsed_astats_0 @ 0x9123c0] Flat factor: 0.000000
[Parsed_astats_0 @ 0x9123c0] Peak count: 2
[Parsed_astats_0 @ 0x9123c0] Bit depth: 20/20
[Parsed_astats_0 @ 0x9123c0] Dynamic range: 98.493854
[Parsed_astats_0 @ 0x9123c0] Zero crossings: 10216
[Parsed_astats_0 @ 0x9123c0] Zero crossings rate: 0.042383
[Parsed_astats_0 @ 0x9123c0] Overall
[Parsed_astats_0 @ 0x9123c0] DC offset: 0.000070
[Parsed_astats_0 @ 0x9123c0] Min level: -170426368.000000
[Parsed_astats_0 @ 0x9123c0] Max level: 172195840.000000
[Parsed_astats_0 @ 0x9123c0] Min difference: 0.000000
[Parsed_astats_0 @ 0x9123c0] Max difference: 58281984.000000
[Parsed_astats_0 @ 0x9123c0] Mean difference: 3089081.855667
[Parsed_astats_0 @ 0x9123c0] RMS difference: 4825348.720329
[Parsed_astats_0 @ 0x9123c0] Peak level dB: -21.918144
[Parsed_astats_0 @ 0x9123c0] RMS level dB: -34.035425
[Parsed_astats_0 @ 0x9123c0] RMS peak dB: -27.320939
[Parsed_astats_0 @ 0x9123c0] RMS trough dB: -48.414915
[Parsed_astats_0 @ 0x9123c0] Flat factor: 0.000000
[Parsed_astats_0 @ 0x9123c0] Peak count: 2.000000
[Parsed_astats_0 @ 0x9123c0] Bit depth: 20/20
[Parsed_astats_0 @ 0x9123c0] Number of samples: 241040
[Parsed_astats_0 @ 0x4def40] Channel: 1
[Parsed_astats_0 @ 0x4def40] DC offset: 0.000070
[Parsed_astats_0 @ 0x4def40] Min level: -170426368.000000
[Parsed_astats_0 @ 0x4def40] Max level: 172199936.000000
[Parsed_astats_0 @ 0x4def40] Min difference: 0.000000
[Parsed_astats_0 @ 0x4def40] Max difference: 58277888.000000
[Parsed_astats_0 @ 0x4def40] Mean difference: 3089075.891088
[Parsed_astats_0 @ 0x4def40] RMS difference: 4825346.346176
[Parsed_astats_0 @ 0x4def40] Peak level dB: -21.917938
[Parsed_astats_0 @ 0x4def40] RMS level dB: -34.035425
[Parsed_astats_0 @ 0x4def40] RMS peak dB: -27.320942
[Parsed_astats_0 @ 0x4def40] RMS trough dB: -48.414908
[Parsed_astats_0 @ 0x4def40] Crest factor: 4.035287
[Parsed_astats_0 @ 0x4def40] Flat factor: 0.000000
[Parsed_astats_0 @ 0x4def40] Peak count: 2
[Parsed_astats_0 @ 0x4def40] Bit depth: 20/20
[Parsed_astats_0 @ 0x4def40] Dynamic range: 98.494061
[Parsed_astats_0 @ 0x4def40] Zero crossings: 10220
[Parsed_astats_0 @ 0x4def40] Zero crossings rate: 0.042400
[Parsed_astats_0 @ 0x4def40] Overall
[Parsed_astats_0 @ 0x4def40] DC offset: 0.000070
[Parsed_astats_0 @ 0x4def40] Min level: -170426368.000000
[Parsed_astats_0 @ 0x4def40] Max level: 172199936.000000
[Parsed_astats_0 @ 0x4def40] Min difference: 0.000000
[Parsed_astats_0 @ 0x4def40] Max difference: 58277888.000000
[Parsed_astats_0 @ 0x4def40] Mean difference: 3089075.891088
[Parsed_astats_0 @ 0x4def40] RMS difference: 4825346.346176
[Parsed_astats_0 @ 0x4def40] Peak level dB: -21.917938
[Parsed_astats_0 @ 0x4def40] RMS level dB: -34.035425
[Parsed_astats_0 @ 0x4def40] RMS peak dB: -27.320942
[Parsed_astats_0 @ 0x4def40] RMS trough dB: -48.414908
[Parsed_astats_0 @ 0x4def40] Flat factor: 0.000000
[Parsed_astats_0 @ 0x4def40] Peak count: 2.000000
[Parsed_astats_0 @ 0x4def40] Bit depth: 20/20
[Parsed_astats_0 @ 0x4def40] Number of samples: 241040
...
通过管道传输到 grep(以及一些更多的过滤),我可以合并这些并检查音频通道上的峰值水平:
$ ffmpeg -i foo5.mxf -map 0:a -af astats -f null - 2>&1 | grep -E "(Channel:|Peak level|Overall)"
[Parsed_astats_0 @ 0x9123c0] Channel: 1
[Parsed_astats_0 @ 0x9123c0] Peak level dB: -21.918144
[Parsed_astats_0 @ 0x9123c0] Overall
[Parsed_astats_0 @ 0x9123c0] Peak level dB: -21.918144
[Parsed_astats_0 @ 0x4def40] Channel: 1
[Parsed_astats_0 @ 0x4def40] Peak level dB: -21.917938
[Parsed_astats_0 @ 0x4def40] Overall
[Parsed_astats_0 @ 0x4def40] Peak level dB: -21.917938
[Parsed_astats_0 @ 0xb92180] Channel: 1
[Parsed_astats_0 @ 0xb92180] Peak level dB: -6153.053111
[Parsed_astats_0 @ 0xb92180] Overall
[Parsed_astats_0 @ 0xb92180] Peak level dB: -6153.053111
...
如果我过滤掉峰值水平 < -120db,它就能得到我所需要的大部分内容。问题是它将所有通道标识为“通道 1”。这可能是因为每个音频流只有一个通道。但我在原始输出中找不到任何内容可以将每个“音频状态部分”(包含“通道:”到“过零率”的部分)与相关流(例如 0:0、0:1 等)联系起来。我能否仅根据输出的顺序可靠地推断出这一点?
我是否应该使用不同的过滤器(而不是 astats)或参数集来获取此信息?
答案1
您可以volumedetect
像这样使用音频过滤器:
ffmpeg -i foo5.mxf -af "volumedetect" -vn -sn -dn -f null /dev/null
我没有测试过,但应该适合你的情况。不过你可以重新检查一下文档。