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

ffmpeglinuxmencodervideo

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?

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

ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex \
-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 \

ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex \