[筆記]ffmpeg volumedetect - Begining

使用 ffmpeg audiodetect filter

Scenario:
有 multi-stream MXF 檔案,想知道哪一個 audio stream 是有聲音的

選擇第1個 audio stream,並將其轉換成 WAV 格式,顯示在 console 並輸出至 txt (使用 Linux 指令 2>&1 以及 tee)

1
ffmpeg -i in.MXF -af volumedetect -map0:1 temp.wav 2>&1 | tee output.txt

同理,若要看其他 stream 就變更 -map 的參數

volumedetect輸出結果會像是:

  1. 這個沒聲音

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    [Parsed_volumedetect_0 @ 000001d7d2505500] n_samples: 9513504
    [Parsed_volumedetect_0 @ 000001d7d2505500] mean_volume: -83.3 dB
    [Parsed_volumedetect_0 @ 000001d7d2505500] max_volume: -65.7 dB
    [Parsed_volumedetect_0 @ 000001d7d2505500] histogram_65db: 2
    [Parsed_volumedetect_0 @ 000001d7d2505500] histogram_66db: 10
    [Parsed_volumedetect_0 @ 000001d7d2505500] histogram_67db: 14
    [Parsed_volumedetect_0 @ 000001d7d2505500] histogram_68db: 98
    [Parsed_volumedetect_0 @ 000001d7d2505500] histogram_69db: 166
    [Parsed_volumedetect_0 @ 000001d7d2505500] histogram_70db: 627
    [Parsed_volumedetect_0 @ 000001d7d2505500] histogram_71db: 2518
    [Parsed_volumedetect_0 @ 000001d7d2505500] histogram_72db: 9846
  2. 這個是有聲音的

    1
    2
    3
    4
    5
    6
    7
    8
    9
    [Parsed_volumedetect_0 @ 0000016965965500] n_samples: 9513504
    [Parsed_volumedetect_0 @ 0000016965965500] mean_volume: -18.1 dB
    [Parsed_volumedetect_0 @ 0000016965965500] max_volume: -0.3 dB
    [Parsed_volumedetect_0 @ 0000016965965500] histogram_0db: 4
    [Parsed_volumedetect_0 @ 0000016965965500] histogram_1db: 47
    [Parsed_volumedetect_0 @ 0000016965965500] histogram_2db: 235
    [Parsed_volumedetect_0 @ 0000016965965500] histogram_3db: 1114
    [Parsed_volumedetect_0 @ 0000016965965500] histogram_4db: 3706
    [Parsed_volumedetect_0 @ 0000016965965500] histogram_5db: 10167

(還只知道個大概…)

Reference

“How do I save terminal output to a file?” - askubuntu

ffmpeg filters - volumedetect