ffmpeg 音频音量的获取

使用 ffmpeg 的 volumedetect 获取音频音量信息,测试命令如下:

ffmpeg -i ~/media/test.mp4 -filter_complex volumedetect -c:v copy -f null /dev/null 

命令执行结果如下:

[Parsed_volumedetect_0 @ 0x7fb417591180] n_samples: 0
Stream mapping:
  Stream #0:1 (aac) -> volumedetect
  volumedetect -> Stream #0:0 (pcm_s16le)
  Stream #0:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
Output #0, null, to '/dev/null':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.20.100
    Stream #0:0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s (default)
    Metadata:
      encoder         : Lavc58.35.100 pcm_s16le
    Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 1301 kb/s, 24 fps, 24 tbr, 12288 tbn, 12288 tbc (default)
    Metadata:
      handler_name    : VideoHandler
frame= 1085 fps=0.0 q=-1.0 Lsize=N/A time=00:00:45.08 bitrate=N/A speed= 569x    
video:7183kB audio:7764kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[Parsed_volumedetect_0 @ 0x7fb417474d80] n_samples: 3975168
[Parsed_volumedetect_0 @ 0x7fb417474d80] mean_volume: -20.0 dB
[Parsed_volumedetect_0 @ 0x7fb417474d80] max_volume: -7.2 dB
[Parsed_volumedetect_0 @ 0x7fb417474d80] histogram_7db: 6
[Parsed_volumedetect_0 @ 0x7fb417474d80] histogram_8db: 107
[Parsed_volumedetect_0 @ 0x7fb417474d80] histogram_9db: 6261
bogon:~ xubinbin$ 

从输出信息中我们可以看到 mean_volume 为获取到的平均值 -20.0 dB。

你可能感兴趣的:(ffmpeg)