Open eladg opened 2 years ago
This can also be achieved with:
ffmpeg -i input1.mp4 -i input2.mp4 -lavfi "[0:v]scale=1280x720[1];[1:v]scale=1280x720[2];[1][2]hstack" output.mp4
indeed @g-l-i-t-c-h-o-r-s-e, hstack
is a great way to do it. However, Simply's solution is more general and not limited to 720p or 16:9 videos.
https://www.ffmpegbyexample.com/examples/k1u2p6i9/stitch_two_video_files_side_by_side/
Stitch yoga.mp4 and sharks.mp4 side-by-side and output to
output.mp4
The following example assumes the two videos are of the same width. The 2nd video will be overlay'ed to the right of the first video.
[0:v]pad=iw+iw:ih[v1];
using the pad filter, add space to the right of the first input, to make space for the second video. The pad size is the size of the input video width (which is set in theiw
parameter to the filter).[v1][1:v]overlay=overlay_w:0[vid]
overlay the second input on top of the padded input (set as[v1]
), starting at coordinates overlay_w:0 i.e.: X:size of the overlay, Y:0, this aligns the second input on the black space we just padded.-an
ignores any audio that was set to either inputs.-map [vid]
maps the complex stream named 'vid' to the output file.