E
E
Eugene2018-07-19 21:37:19
fmpeg
Eugene, 2018-07-19 21:37:19

How to combine 2 videos of different frame sizes via ffmpeg?

Tell me how to glue 2 horizontal videos like in the image?

spoiler
5b50da3644d01005234185.png
ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex "[0:v][1:v]vstack[v];[0:a][1:a]amerge=inputs=2[a]" -map "[v]" -map "[a]" -ac 2 output.mp4

This option merges videos of the same size only.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2018-07-19
@forumrulez

You can use the overlay filter , which will overlay the first source on the empty video of the final frame size and then the second one with an offset of y=280.

Working example
ffmpeg \
-f lavfi -i testsrc=size=640x280 \
-f lavfi -i color=c=#ff9900:size=640x360 \
-t 5 \
-filter_complex "
nullsrc=size=640x640 [background];
[0:v] setpts=PTS-STARTPTS [top];
[1:v] setpts=PTS-STARTPTS [bottom];
[background][top]       overlay=shortest=1       [background+top];
[background+top][bottom] overlay=shortest=1:y=280
" \
-y  -t 5 test.avi
Result
5b50e49134f23765570400.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question