ffmpeg 合并视频到一个画布

#!/bin/bash

#video1='/Users/wangguisen/Documents/work_space/python/LSCQ/wav2motion/wav2motion/data2_demo/xiangsheng_nsm.mp4'
#video2='/Users/wangguisen/Documents/work_space/python/LSCQ/wav2motion/wav2motion/data2_demo/xiangsheng_sm.mp4'

video1='/Users/wangguisen/Documents/work_space/python/LSCQ/wav2motion/wav2motion/data2_demo/3_nsm.mp4'
video2='/Users/wangguisen/Documents/work_space/python/LSCQ/wav2motion/wav2motion/data2_demo/3_sm.mp4'
video3='/Users/wangguisen/Documents/work_space/python/LSCQ/wav2motion/wav2motion/data2_demo/rec_3.mp4'
video4='/Users/wangguisen/Documents/work_space/python/LSCQ/wav2motion/wav2motion/data2_demo/3_vis.mp4'
out='/Users/wangguisen/Documents/work_space/python/LSCQ/wav2motion/wav2motion/data2_demo/mer_3_out.mp4'

# 两个
#ffmpeg -i $video1 -i $video2 -filter_complex "[0:v]pad=iw*2:ih*1[a];[a][1:v]overlay=w" $out -y
# pad是将合成的视频宽高,这里iw代表第一个视频的宽,iw*2代表合成后的视频宽度加倍,ih为第一个视频的高,合成的两个视频最好分辨率一致。overlay是覆盖,[a][1:v]overlay=w,后面代表是覆盖位置w:0

# 三个
#ffmpeg -i $video1 -i $video2 -i $video3 -filter_complex "[0:v]pad=iw*3:ih*1[a];[a][1:v]overlay=w[b];[b][2:v]overlay=2.0*w" $out -y

# 四个
ffmpeg -i $video1 -i $video2 -i $video3 -i $video4 -filter_complex "[0:v]pad=iw*2:ih*2[a];[a][1:v]overlay=w[b];[b][2:v]overlay=0:h[c];[c][3:v]overlay=w:h" $out -y


ref: https://blog.csdn.net/Gary__123456/article/details/88742705

你可能感兴趣的:(#,tools,ffmpeg,音视频)