[Libav-user] Channel mapping with amerge filter

Paul B Mahol onemda at gmail.com
Fri May 29 14:04:14 EEST 2020


On 5/29/20, Nicolas George <george at nsup.org> wrote:
> 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
> unfounded.
>

Your explanation bellow proves otherwise.

amerge filter is of very limited functionality and should be
deprecated and ultimately removed.

> 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
> its inputs.
>
> 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:
> FL1+FR1+FC1+FL2+FR2+BL2+BR2).
>
> Of course, the same happens if one of the inputs has no specified
> channel layout.
>
> 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.
>
> Regards,
>
> --
>   Nicolas George
>


More information about the Libav-user mailing list