这个命令行满足了我的需要,但是有点棘手......
ffmpeg -i left.jpg -i right.jpg -filter_complex "[0]scale=iw:ih*2[grande],[grande][0]overlay=x=0:y=0[base],[base][1]overlay=x=0:y=h" -y top-bottom.jpg
- -i left.jpg Left image
- -i right.jpg Right image
- -filter_complex
- "[0]scale=iw:ih*2[grande],
enlarge vertically image 1 to double its height, and create stream "grande"
(i.e. just create a base image twice high the input image)
- [grande][0]overlay=x=0:y=0[base],
Overlay image 1 to stream "grande", i.e. put left image in upper part of main image;
the results goes into "base" stream
- [base][1]overlay=x=0:y=h"
Overlay image 2 to bottom part of "base" stream, which already contains upper (left) image
是否存在更直接的方法?我看到它们存在“in_stereo”和“out_stereo”选项,以及“2d”和“tb”(Top-Bottom)选项,但我不明白它们是否是我需要的,而且我找不到任何文档。
示例图片:
1:
2:
答案1
这一行:
ffmpeg -i left.jpg -i right.jpg -filter_complex "[0]scale=iw:ih*2[grande],[grande][0]overlay=x=0:y=0[base],[base][1]overlay=x=0:y=h" -y top-bottom.jpg
可以简化为:
ffmpeg -i left.jpg -i right.jpg -filter_complex vstack=inputs=2 -y top-bottom.jpg