I need to mix the first audio-track into left channel and the second into right. When audio-tracks are stereo, this does the job.
ffmpeg -i 1.mkv -filter_complex "[0:a:0][0:a:1]amerge=inputs=2,pan=stereo|c0<c0+c1|c1<c2+c3[aout]" -map "[aout]" 1.mka
But when there are more channels - how can I do it? Without manually checking number of channels and inserting them myself.