Merge two audio streams into a single multi-channel stream.
This filter does not need any argument.
If the channel layouts of the inputs are disjoint, and therefore compatible, the channel layout of the output will be set accordingly and the channels will be reordered as necessary. If the channel layouts of the inputs are not disjoint, the output will have all the channels of the first input then all the channels of the second input, in that order, and the channel layout of the output will be the default value corresponding to the total number of channels.
For example, if the first input is in 2.1 (FL+FR+LF) and the second input is FC+BL+BR, then the output will be in 5.1, with the channels in the following order: a1, a2, b1, a3, b2, b3 (a1 is the first channel of the first input, b1 is the first channel of the second input).
On the other hand, if both input are in stereo, the output channels will be in the default order: a1, a2, b1, b2, and the channel layout will be arbitrarily set to 4.0, which may or may not be the expected value.
Both inputs must have the same sample rate, and format.
If inputs do not have the same duration, the output will stop with the shortest.
Example: merge two mono files into a stereo stream:
amovie=left.wav [l] ; amovie=right.mp3 [r] ; [l] [r] amerge
If you need to do multiple merges (for instance multiple mono audio streams in a single video media), you can do:
ffmpeg -f lavfi -i " amovie=input.mkv:si=0 [a0]; amovie=input.mkv:si=1 [a1]; amovie=input.mkv:si=2 [a2]; amovie=input.mkv:si=3 [a3]; amovie=input.mkv:si=4 [a4]; amovie=input.mkv:si=5 [a5]; [a0][a1] amerge [x0]; [x0][a2] amerge [x1]; [x1][a3] amerge [x2]; [x2][a4] amerge [x3]; [x3][a5] amerge" -c:a pcm_s16le output.mkv