ffmpeg -loop 1 -i hinh1.jpg -i 2.mp4 \
-filter_complex "[1]scale=iw/2.5:-1[ovrl]; \
[0][ovrl]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2:shortest=1[v],\
pan=stereo|c0<c0+0*c1|c1<c0+0*c1,aeval=val(0)|-val(1)" \
-map "[v]" -vcodec libx264 -pix_fmt yuv420p -r 30 -g 60 -b:v 2500k \
-acodec libmp3lame -b:a 128k -ar 44100 -preset ultrafast tap2.mp4
电流输出:
我需要插入 -filter:v "crop=in_w:in_h-360",所以它看起来像这样
期望输出:
答案1
背景图像在用于叠加之前必须进行裁剪
ffmpeg -loop 1 -i hinh1.jpg -i 2.mp4 \
-filter_complex "[1]scale=iw/2.5:-1[ovrl]; \
[0]crop=in_w:in_h-360[bg]; \
[bg][ovrl]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2:shortest=1[v],\
[1]pan=stereo|c0<c0+0*c1|c1<c0+0*c1,aeval=val(0)|-val(1)[a]" \
-map "[v]" -map "[a]" -vcodec libx264 -pix_fmt yuv420p -r 30 -g 60 -b:v 2500k \
-acodec libmp3lame -b:a 128k -ar 44100 -preset ultrafast tap2.mp4
如果需要将图像恢复到其原始高度,请使用
ffmpeg -loop 1 -i hinh1.jpg -i 2.mp4 \
-filter_complex "[1]scale=iw/2.5:-1[ovrl]; \
[0]crop=in_w:in_h-360,pad=iw:ih+360:0:180[bg]; \
[bg][ovrl]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2:shortest=1[v],\
[1]pan=stereo|c0<c0+0*c1|c1<c0+0*c1,aeval=val(0)|-val(1)[a]" \
-map "[v]" -map "[a]" -vcodec libx264 -pix_fmt yuv420p -r 30 -g 60 -b:v 2500k \
-acodec libmp3lame -b:a 128k -ar 44100 -preset ultrafast tap2.mp4