如何在ffmpeg中将图像叠加/放置在视频上
问题描述:
嘿伙计们我试图在ffmpeg的视频中覆盖图像,如下所示:
Hey guys I am trying to overlay an image at the cntre of a video in ffmpeg like this:
ffmpeg -i video.mp4 -i image.png -filter_complex "[0:v][1:v] overlay=25:25:enable='between(t,0,20)'" -pix_fmt yuv420p -c:a copy output.mp4
但图像位于视频的左上角。如何将图像调整到中心?
But the image get placed on the top-left side of the video. How can I adjust the image to the centre?
答
使用
ffmpeg -i video.mp4 -i image.png -filter_complex "[0:v][1:v] overlay=(W-w)/2:(H-h)/2:enable='between(t,0,20)'" -pix_fmt yuv420p -c:a copy output.mp4
W
amd H
是基本视频的尺寸。并且 w
和 h
叠加视频。
W
amd H
are the base video's dimensions. And w
and h
the overlay video's.