Merging audio channels by FFmpeg libraries C++

C/C++ project. There are several audio tracks with an individual number of channels. Each is processed using a avresampler. The avresampler converts all tracks to the same format. At the output of the avresampler, we get a set of channels from all audio tracks. Do the FFmpeg libraries have any standard means to merge all these audio channels into another set of audio channels using AVFrame::ch_layout to form a single audio track? That is, no additional processing is required, except for copying channels buffers from several AVFrames of different audio tracks to new positions of one AVFrame according to the new layout and aligning the timestamps of different audio tracks, since different audio tracks can have audio frames of different sizes with different timestamps.

For example, 1 audio track with 2 channels and 2 audio tracks with 6 channels will be merged into 16 channels with silence in the “missing” channels. Or 4 audio tracks with 2 channels merged into 8 channels. Etc…

Is there a way to use a avresampler for this? Or a avfilter? Or something else?

Any source code or any reading source that can help me is welcome.

Read more here: Source link