TransWikia.com

How to join two video frames into one, so the final video plays two frames as one simultenously

Super User Asked by Jakub on January 11, 2021

I want to connect two videos into one. Let’s take two videos from Youtube as an example.
I want my final video to have the height = height of first video + height of second video
and width = max(width of first video, width of second video).
In the upper part the first video is played whereas in the lower part the second video is played.

Do you know how to do it under Linux, the best possibility while using mencoder, ffmpeg or any other command line command?

3 Answers

If both videos have the same height, you can use hstack you can also do it 'vertically' with vstack, above Vfilter is faster than pad + overlay to produce same output:

ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex 
'[0:v][1:v]hstack[vid]' 
-map [vid] -c:v libx264 -crf 22 -preset veryfast output.mp4

Answered by yueqiw on January 11, 2021

This can be done with ffmpeg. If the videos are the same size:

ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex 
'[0:v]pad=iw:ih*2:0:0[intv];[intv][1:v]overlay=0:H/2[vid]' 
-map [vid] -c:v libx264 -crf 22 -preset veryfast output.mp4

If they're different sizes (where input1.mp4 has the higher resolution):

ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex 
'[0:v]pad=iw:ih*2:0:0[intv];[intv][1:v]overlay=(W-w)/2:H/2[vid]'
-map [vid] -c:v libx264 -crf 22 -preset veryfast output.mp4

If you know the resolutions of the videos, you can get a nicer output. Assuming input1.mp4 is larger (or at least the same resolution), and input2.mp4 has a height of 360:

ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex 
'[0:v]pad=iw:ih+360:0:0[intv];[intv][1:v]overlay=(W-w)/2:H-360[vid]'
-map [vid] -c:v libx264 -crf 22 -preset veryfast output.mp4

Answered by evilsoup on January 11, 2021

I think I found the answer here: https://stackoverflow.com/questions/575705/how-can-i-tile-videos-create-a-video-montage I will have a closer look into the solutions posted in that thread.

Answered by Jakub on January 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP