[Libav-user] Channel mapping with amerge filter
george at nsup.org
Fri May 29 13:56:58 EEST 2020
Kerry Loux (12020-05-28):
> I'm trying to create an audio filter graph (in C/C++) that takes a number
> of inputs and mixes/splits/merges as necessary to produce a single stream
> with multiple channels.
> I would like to be able to control which amerge input is mapped to which
> channel in the output stream. For example, if I'm merging two inputs, I
> want to control which is the left and which is the right channel.
> Similarly, for cases with more than two inputs, I'd like to know/control
> which output layout is being created and how each input is mapped.
> Currently, I have an implementation that generates a stream with the
> correct individual channels, but mapped incorrectly. When I call
> av_filter_graph_config(), I get a message stating "Input channel layouts
> overlap; output layout will be determined by the number of distinct input
> channels," which seems like a clue.
Ignore the reply that tells you it is not possible, it is wrong and
To make this work, you need to understand what channels layout are. If
you do not already, read the doc before trying further.
amerge has two modes of operation, depending on the channel layout of
If the inputs have channel layouts with completely different channels
(for example FL+FR+BL+BR on one input and FC+LF on the other), then the
output will be made of these combined channels. The channels will be
reordered to match the standard channel order of FFmpeg (with the given
example: FL+FR+FC+LF+BL+BR: notice that the two channels of the second
inputs were inserted between the channels of the first input).
If the inputs have channel layouts with the same channel in both (for
example FL+FR+FC merged with FL+FR+BL+BR), this cannot work, and amerge
falls back to ignoring the channel layout. In that case, amerge will
output all the channels in order: first the channels from the first
input, then the channels of the second input (in the example:
Of course, the same happens if one of the inputs has no specified
It may happen that a latter filter will slap a channel layout on the
result. That channel layout would be random and irrelevant.
Hope this helped.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 833 bytes
Desc: not available
More information about the Libav-user