[Libav-user] Channel mapping with amerge filter
louxkr at gmail.com
Fri May 29 17:19:58 EEST 2020
On Fri, May 29, 2020, 7:04 AM Paul B Mahol <onemda at gmail.com> wrote:
> 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
> >> of inputs and mixes/splits/merges as necessary to produce a single
> >> 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
> >> 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
> Libav-user mailing list
> Libav-user at ffmpeg.org
> To unsubscribe, visit link above, or email
> libav-user-request at ffmpeg.org with subject "unsubscribe".
Thanks Nicholas. I was able to get it to work using the method you
Actually, I had tried it earlier, but I struggled because I was passing
invalid channel layouts to my src buffer filters. My mistake was that I
expected av_get_channel_layout_string() to produce values suitable for
passing as a "channel_layout" option to my buffer filters.
I may also consider Paul's suggestion to use a join filter instead, but I'm
not sure that it will simplify anything for me since I'll likely still need
splits and mixes for a general solution.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libav-user