I am trying to create a shell/ffmpeg script that can show multiple files after they have been processed using different filters in a side by side / tiled way. An example of desired output would be: https://www.youtube.com/watch?v=DoPuhMRYem4.
In order to create the desired output I need to crop off the right half of video1 and the left half of video2 and then join them back with [video1+video2] side by side. I have played around with a bunch of different ways of joining them, this does OK:
ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex "
nullsrc=size=800x400 [background];
[0:v] setpts=PTS-STARTPTS, scale=400x400 [left];
[1:v] setpts=PTS-STARTPTS, scale=400x400 [right];
[background][left] overlay=shortest=1 [background+left];
[background+left][right] overlay=shortest=1:x=400 [left+right]
" -map '[left+right]' joined.mp4
How can I modify this to detect the video width (they won't always be the same width), divide the width in half and crop either the left or right sides off?
ffmpeg -i input0 -i input1 -filter_complex \
"[0:v]crop=iw/2:ih:0:0[left]; \
[1:v]crop=iw/2:ih:ow:0[right]; \
[left][right]hstack" output
ffmpeg -i input0 -i input1 -filter_complex \
"[0:v]crop=iw:ih/2:0:0[top]; \
[1:v]crop=iw:ih/2:0:oh[bottom]; \
[top][bottom]vstack" output
ffmpeg -i input0 -i input1 -filter_complex \
"[1:v][0:v]blend=all_expr=if(gt(X\,Y*(W/H))\,A\,B)" output
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With