ffmpeg -loop 1 -i image0.png -i video1.m4v -i video2.m4v -filter_complex \
"[0:v]scale=1280:-2[bg]; \
[1:v]scale=140:-1,setpts=PTS-STARTPTS[fg1]; \
[2:v]scale=100:-1,setpts=PTS-STARTPTS[fg2]; \
[bg][fg1]overlay=70:70[ol];70:shortest=1[ol]; \
[ol][fg2]overlay=300:70,format=yuv420p[v]" \
-map "[v]" -movflags +faststart output.mp4
The
movie
multimedia source filter is not required.setpts
will reset the timestamp so it works better withoverlay
.Note the
shortest=1
in one of the overlay filters. Otherwise the image input will loop forever. Alternatively you could use thetrim
filter on the image input.The "end of file" action of
overlay
can be changed witheof_action
.The
format
filter will set compatible chroma subsampling for QuickTime and other crappy players.When encoding is finished
-movflags +faststart
will relocate some data to the beginning of the file. This is useful, for example, if you are outputting to MP4 and your viewers will watch via progressive download such as from a browser.
ffmpeg -loop 1 -i image0.png -i video1.m4v -i video2.m4v -filter_complex \
"[0:v]scale=1280:-2[bg]; \
[1:v]scale=140:-1,setpts=PTS-STARTPTS[fg1]; \
[2:v]scale=100:-1,setpts=PTS-STARTPTS[fg2]; \
[bg][fg1]overlay=70:70[ol];70:shortest=1[ol]; \
[ol][fg2]overlay=300:70,format=yuv420p[v]; \
[1:a][2:a]amerge[a]" \
-map "[v]" -map "[a]" -ac 2 -movflags +faststart output.mp4
ffmpeg -loop 1 -i image0.png -i video1.m4v -i video2.m4v -filter_complex \
"[0:v]scale=1280:-2[bg]; \
[1:v]scale=140:-1,setpts=PTS-STARTPTS[fg1]; \
[2:v]scale=100:-1,setpts=PTS-STARTPTS[fg2]; \
[bg][fg1]overlay=70:70[ol];70:shortest=1[ol]; \
[ol][fg2]overlay=300:70,format=yuv420p[v]; \
[1:a][2:a]amerge,pan=stereo|c0<c0+c2|c1<c1+c3[a]" \
-map "[v]" -map "[a]" -movflags +faststart output.mp4