Assuming both inputs contain stereo audio you can use the
amerge audio filter to merge both stereo streams into a single four channel stream, then use the
pan audio filter to combine the appropriate channels into a single stereo stream:
ffmpeg -i video.flv -i audio.mp3 -filter_complex \ "[0:a][1:a]amerge,pan=stereo:c0<c0+c2:c1<c1+c3[a]" \ -map 0:v -map "[a]" -c:v copy -c:a aac -strict experimental -shortest out.mp4
The example uses the native FFmpeg AAC encoder which requires
-strict experimental(or the alias
-strict -2). See the FFmpeg and AAC Encoding Guide for information on other encoders.
-shortestwill finish encoding when the shortest input stream ends.
See Manipulating audio channels with
ffmpegfor more examples.
Make sure you're using a recent version of
ffmpeg. See the FFmpeg Download page for builds for Windows, OS X, and Linux.