FFMPEG裁剪并排合并 [英] FFMPEG Crop with side by side merge
问题描述
我正在尝试创建一个shell/ffmpeg脚本,该脚本可以在使用不同的过滤器并排/平铺方式处理多个文件后显示多个文件.所需输出的示例为:
ffmpeg -i输入0 -i输入1 -filter_complex \"[0:v] crop = iw/2:ih:0:0 [left]; \[1:v] crop = iw/2:ih:ow:0 [right];\[left] [right] hstack输出
顶部和底部
ffmpeg -i输入0 -i输入1 -filter_complex \"[0:v] crop = iw:ih/2:0:0 [top]; \[1:v] crop = iw:ih/2:0:oh [bottom];\[顶部] [底部] vstack输出
对角线
<代码> ffmpeg -i输入0 -i输入1 -filter_complex \"[1:v] [0:v] blend = all_expr = if(gt(X \,Y *(W/H))\ ,, A \,B)"输出
另请参见
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?
Split screen
left and right
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
top and bottom
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
diagonal
ffmpeg -i input0 -i input1 -filter_complex \
"[1:v][0:v]blend=all_expr=if(gt(X\,Y*(W/H))\,A\,B)" output
Also see
这篇关于FFMPEG裁剪并排合并的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!