Join videos with split screen
With a recent version of ffmpeg (assuming both videos are the same resolution):
ffmpeg -i input1.mp4 -i input2.mp4 \
-filter_complex \
"[0:v]pad=iw*2:ih[int]; \
[int][1:v]overlay=W/2:0[vid]" \
-map "[vid]" \
-c:v libx264 -crf 23 \
output.mp4
This essentially doubles the size of input1.mp4 by padding the right side with black the same size as the original video, and then places input2.mp4 over the top of that black area with the overlay filter.
If one of your videos has an audio track that you need to add to the output, add the option -map 0:a
for the first file's audio, or -map 1:a
for the second file's audio.
If you have two audio tracks that you would like to mix, use the amix
filter:
ffmpeg -i input1.mp4 -i input2.mp4 \
-filter_complex \
"[0:v]pad=iw*2:ih[int]; \
[int][1:v]overlay=W/2:0[vid]; \
[0:a][1:a]amix=inputs=2:duration=longest[aud]" \
-map "[vid]" \
-map "[aud]" \
-c:v libx264 -crf 23 \
-c:a aac -b:a 192k \
output.mp4