How do I combine videos and include blank space with ffmpeg?

Suppose I have a series of video files to combine with non-overlapping times:

  1. 1.mp4 [0:00-0:45]
  2. 2.mp4 [1:00-2:00]
  3. 3.mp4 [2:10-3:00]

This example has three segments, but in general, there may be more.

Assuming these are the same aspect ratio but not necessarily the same size, I would like to use a complex filter to combine these into one video file of 3:00 length, with blank spaces when there is no video. I actually want a more complex filter outcome with this as one part, but this is the part I do not understand how to produce.

ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -filter_complex "
[0:v] scale=640x480 [one];
[1:v] scale=640x480 [two];
[2:v] scale=640x480 [three];
???
[out]" -map '[out]' out.mp4

I am looking for the filter function(s) to apply after scaling the input video streams. I have looked at:

  1. concat - This does not seem to allow time padding
  2. streamselect and sendcmd - This seems to get horribly complicated if there are many streams

This question is similar to FFmpeg - Concenating audio files with spacing, but with video instead of audio.

I am only looking for help with the video; I already have the audio functioning the way I want.


You could do this using the color filter.

ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -filter_complex "
[0:v]scale=640x480[one];
color=black:s=640x480:d=15[b0];
[1:v]scale=640x480[two];
color=black:s=640x480:d=10[b1];
[2:v]scale=640x480[three];
[0:v][b0][1:v][b1][2:v]concat=n=5:v=1:a=0[out]"
-map '[out]' out.mp4

I assume that you want the entire clips 1,2 and 3 to be included.