
You can do it all in one command using hstack and vstack .
ffmpeg -i top_l.mp4 -i top_r.mp4 -i bottom_l.mp4 -i bottom_r.mp4 -i audio.mp4 \ -filter_complex "[0:v][1:v]hstack[t];[2:v][3:v]hstack[b];[t][b]vstack[v]" \ -map "[v]" -map 4:a -c:a copy -shortest output.mp4
- Audio will stream copy from
audio.mp4
instead of being re-encoded.
If you want the audio from each input to be combined instead of a separate audio input, use the amerge filter. -ac 2
added to the down-mix in stereo; otherwise, the output will have a cumulative number of audio channels.
ffmpeg -i top_l.mp4 -i top_r.mp4 -i bottom_l.mp4 -i bottom_r.mp4 -filter_complex \ "[0:v][1:v]hstack[t];[2:v][3:v]hstack[b];[t][b]vstack[v]; \ [0:a][1:a][2:a][3:a]amerge=inputs=4[a]" \ -map "[v]" -map "[a]" -ac 2 -shortest output.mp4
source share