How should I record multichannel (quad) with ffmpeg?

0

I recently got a four-channel USB input device (Behringer UMC404HD). The device is working and Linux sees it; I know this because I can record four independent channels using Audacity. However, I can't work out how to ask ffmpeg to do the same thing.

If I configure ALSA and issue this command:

ffmpeg -f alsa -i pulse  test.flac

I get a stereo file that contains sound from the multichannel device that is all four channels mixed down to stereo (it's treating it as a front and rear quadraphonic source).

ffprobe on that file reports (among the mass of other info):

Stream #0:0: Audio: flac, 48000 Hz, stereo, s16

Try as I might I cannot seem to determine how to put this thing into quad mode, rather than stereo. This page looked promising, but I couldn't make any of it work for my (surely much simpler!?) case: https://trac.ffmpeg.org/wiki/AudioChannelManipulation

Anyone know how I should do this? It seems like it should be a trivial thing, and I'm probably just using the wrong words in my searches.

Toby Eggitt

Posted 2018-10-13T16:16:32.013

Reputation: 107

I don't know for certain, but in this day & age quad audio is so rare that you might be better trying to format it as 5.1 with 2 empty channels. – Tetsujin – 2018-10-13T16:36:53.877

2

The issue here has to be addressed on the input side; rematrixing the input to 4 channels won't get you your input if ffmpeg hasn't ingested them in the first place. See the docs for alsa options.

– Gyan – 2018-10-13T16:49:13.787

Tetsujin, I don't care what format it is, so long as it has four independent channels (they're not positional, they're effectively independent instruments/voices anyway). So, if you can tell me how to build a command line that does what you suggest, that'd be perfectly useful. – Toby Eggitt – 2018-10-14T04:02:56.837

Gyan, thanks, that eventually led me to a solution. It took a few tries to work out how to use the channels feature, and where to put it, and then to discover that a flac container isn't suitable for four channels (or at least ffmpeg says so) But in the end, this worked: ffmpeg -f alsa -channels 4 -i pulse test.wav It seems to be important that the -channels comes before -i pulse, and a wav container seems like it wastes disk space, but at least it holds four channels without a problem. Many thanks. – Toby Eggitt – 2018-10-14T04:14:18.103

Answers

1

You should signal the correct number of channels on the input side, and for storing in FLAC, you will need to set a supported channel layout. So,

ffmpeg -f alsa -channels 4 -i pulse -channel_layout quad test.flac

Gyan

Posted 2018-10-13T16:16:32.013

Reputation: 21 016

Thanks, one of the things I find hardest to discover about ffmpeg is the syntax of the commands. It seems to be critically order sensitive, and I've not yet found (in the huge pile of docs!) the part where that's described in general terms. Anyway, your input has clarified nicely. – Toby Eggitt – 2018-10-15T15:54:29.503

See last two paras of this section: http://ffmpeg.org/ffmpeg.html#Description

– Gyan – 2018-10-15T16:03:33.863