如何使用 ffmpeg 從 USB 音訊介面錄製大量通道?

如何使用 ffmpeg 從 USB 音訊介面錄製大量通道?

我有幾個 USB 音訊接口,它們有很多輸入通道,例如 10、18 或 32。

我目前將具有 10 個輸入通道的設備連接到我的 Linux PC,並且我能夠在pactl list sources.以下是相關部分:

Source #1414
    ...
    Name: alsa_input.usb-Behringer_FLOW_8_03-FF-02-11-55-44-00.Direct__hw_F8__source
    ...
    Sample Specification: s32le 10ch 48000Hz
    Channel Map: aux0,aux1,aux2,aux3,aux4,aux5,aux6,aux7,aux8,aux9
    ...
    Volume: aux0: 48287 /  74% / -7.96 dB,   aux1: 48287 /  74% / -7.96 dB,   aux2: 48287 /  74% / -7.96 dB,   aux3: 48287 /  74% / -7.96 dB,   aux4: 48287 /  74% / -7.96 dB,   aux5: 48287 /  74% / -7.96 dB,   aux6: 48287 /  74% / -7.96 dB,   aux7: 48287 /  74% / -7.96 dB,   aux8: 48287 /  74% / -7.96 dB,   aux9: 48287 /  74% / -7.96 dB
            balance 0.00
    ...
    Properties:
        ...
        audio.channels = "10"
        ...

很明顯它有 10 個輸入通道。

大膽同意,我可以將所有 10 個通道並行錄製到單獨的軌道中,沒有任何問題。另一邊的 ffmpeg 似乎不太明白我的音訊介面有兩個以上的通道,即使我指定了一個channel_layout(我使用的是 0x3ff,它是 1111111111 (10 個通道)的十六進位表示。

我嘗試像這樣運行它:

$ export SOURCE_NAME="alsa_input.usb-Behringer_FLOW_8_03-FF-02-11-55-44-00.Direct__hw_F8__source"
$ ffmpeg -f pulse -i "${SOURCE_NAME}" -c:a pcm_s32le -ar 48000 -ac 10 -channel_layout 0x3ff output.w64

我得到了這個輸出:

...
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, pulse, from 'alsa_input.usb-Behringer_FLOW_8_03-FF-02-11-55-44-00.Direct__hw_F8__source':
  Duration: N/A, start: 1689435887.317692, bitrate: 1536 kb/s
  Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s
Multiple -ac options specified for stream 0, only the last option '-ac 10' will be used.
Stream mapping:
  Stream #0:0 -> #0:0 (pcm_s16le (native) -> pcm_s32le (native))
Press [q] to stop, [?] for help
[pcm_s32le @ 0x5636967eb040] Channel layout '10 channels (FL+FR+FC+LFE+BL+BR+FLC+FRC+BC+SL)' with 10 channels does not match number of specified channels 2
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!

如果我指定hexadecagonal為channel_layout,它實際上會錄製,但它只錄製前兩個通道,創建一個包含 16 個通道的 w64 文件,並且僅記錄前 2 個包含任何音訊的通道。

$ ffmpeg -f pulse -i "${SOURCE_NAME}" -c:a pcm_s32le -ar 48000 -ac 10 -channel_layout hexadecagonal output.w64
...
Output #0, w64, to 'output.w64':
  Metadata:
    encoder         : Lavf58.76.100
  Stream #0:0: Audio: pcm_s32le ([1][0][0][0] / 0x0001), 48000 Hz, hexadecagonal, s32, 24576 kb/s
    Metadata:
      encoder         : Lavc58.134.100 pcm_s32le
size=   54000kB time=00:00:16.02 bitrate=27602.2kbits/s speed=1.07x    
video:0kB audio:54000kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000231%
Exiting normally, received signal 2.

有什麼線索我做錯了嗎?

相關內容