The way to put 4 image streams would be:
ffmpeg -y -i input1.mp4 -i input2.mp4 -i input3.mp4 -i input4.mp4 -filter_complex "[0:0]pad=iw*2:ih*2[a];[a][1:0]overlay=w[x];[x][2:0]overlay=0:h[y];[y][3:0]overlay=w:h" -strict -2 output.mp4
This does not use any other filter, it uses the pad to decrease the size, and then the overlay filter to lay it on at four pixel positions. But in the filter chain it has to do this several times, combining the effects of the first 2 inputs, then overlaying on the third and then on the fourth.
I have used mp4
container but it can work for other containers. You will not need -strict -2
under most circumstances- here it is used because my ffmpeg defaults to aac
audio encoder for mp4.
If there is no audio which is very likely in your case, again you will not need the -strict -2
option. If you do have audio as an input but do not want to use it in the output, add the parameter -an
in the command.
Alternatively, and this is a good option, use the map
option:
ffmpeg -y -i input1.mp4 -i input2.mp4 -i input3.mp4 -i input4.mp4 -filter_complex "[0:0]pad=iw*2:ih*2[a];[a][1:0]overlay=w[x];[x][2:0]overlay=0:h[y];[y][3:0]overlay=w:h[v]" -map '[v]' output.mp4