Skip to content

Instantly share code, notes, and snippets.

@vherolf
Last active April 4, 2018 21:33
Show Gist options
  • Save vherolf/f14d9267453377e0660004fe0cdad107 to your computer and use it in GitHub Desktop.
Save vherolf/f14d9267453377e0660004fe0cdad107 to your computer and use it in GitHub Desktop.
put videos side by side with ffmpeg with filter_complex
#!/bin/bash
##################################
## vertical 2 way sidebyside merge
##################################
ffmpeg -i 1.mp4 -i 2.mp4 -filter_complex "[0:0]pad=iw*1:ih*2[out1];[out1][1:0]overlay=x=0:y=h" -c:a copy -c:v libx264 output.mp4
####################################
## horizontal 2 way sidebyside merge
####################################
ffmpeg -i 1.mp4 -i 2.mp4 -filter_complex "[0:0]pad=iw*2:ih*1[out1];[out1][1:0]overlay=x=w:y=0" -c:a copy -c:v libx264 output.mp4
##############################
## quadlayout sidebyside merge
##############################
ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -i 4.mp4 -filter_complex "[0:0]pad=iw*2:ih*2[out1];[out1][1:0]overlay=x=w:y=0[out2];[out2][2:0]overlay=x=0:y=h[out3];[out3][3:0]overlay=x=w:y=h" -c:a copy -c:v libx264 output.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment