I have four videos that I would like to tile in a 2x2 fashion to make a new video. Is there a way I can do this easily, preferably free and under Linux? I am willing to program a moderate amount, perhaps in order to interact with some library, but unwilling to write an entire video-processing program myself. You may assume that the input and output videos are in whatever commonly-occurring format is most convenient.
An analogue of the gm montage command (for images) would be fantastic.
The following ffmpeg command will do exactly what the questioner wanted:
ffmpeg -i input1.mp4 -i input2.mp4 -i input3.mp4 -i input4.mp4 -filter_complex \
'[0:v]pad=iw*2:ih*2:0:0[int2];[int2][1:v]overlay=0:H/2[int3];[int3][2:v]overlay=W/2:0[int4];[int4][3:v]overlay=W/2:H/2[out]' \
-map [out] -c:v libx264 -crf 23 -preset veryfast output.mp4
First, the pad filter doubles the size of the first input video, leaving the original video in the top-left corner. The serial overlay filters then place the other inputs over the the black padding added by the pad filter.
If the videos are of different resolutions, the command will require some modification.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With