Last active
August 7, 2019 04:00
-
-
Save uotw/878d04974566b78433759422af17368c to your computer and use it in GitHub Desktop.
combine 4 clips into one 2 x 2 grid video mosaic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
finalwidth=$(ffprobe -v error -select_streams v:0 -show_entries stream=width -of csv=p=0 $1) | |
finalheight=$(ffprobe -v error -select_streams v:0 -show_entries stream=height -of csv=p=0 $1) | |
halfwidth=$(echo "$finalwidth/2" | bc) | |
halfheight=$(echo "$finalheight/2" | bc) | |
x="x" | |
ffmpeg -i $1 -i $2 -i $3 -i $4 -filter_complex "nullsrc=size=$finalwidth$x$finalheight [base]; [0:v] setpts=PTS-STARTPTS, scale=$halfwidth$x$halfheight [upperleft]; [1:v] setpts=PTS-STARTPTS, scale=$halfwidth$x$halfheight [upperright]; [2:v] setpts=PTS-STARTPTS, scale=$halfwidth$x$halfheight [lowerleft]; [3:v] setpts=PTS-STARTPTS, scale=$halfwidth$x$halfheight [lowerright]; [base][upperleft] overlay=shortest=1 [tmp1]; [tmp1][upperright] overlay=shortest=1:x=$halfwidth [tmp2]; [tmp2][lowerleft] overlay=shortest=1:y=$halfheight [tmp3]; [tmp3][lowerright] overlay=shortest=1:x=$halfwidth:y=$halfheight" -c:v libx264 quad_vid.mp4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's an online version of the tool
https://sonoclipshare.com/quad_video/