FFMPEG : overlay image on video and retain size

ぃ、小莉子 提交于 2019-12-02 21:12:20

问题


I'm trying to overlay an image (transparent background with shape in the middle) "on top" of the video and get the image back. The image size is bigger then the video. Here is the command that I'm using:

"-i", video.mp4, "-i", image.mp4, "-filter_complex", "[1:v][0:v]scale2ref=iw:ih[ovr][base];[ovr]colorchannelmixer=aa=1.0[ovrl];[base][ovrl]overlay[v]", "-map", "[v]", "-q:v", "2", directoryToStore + "/" + ImageName + ".jpeg"

The above scales the image to the size of the video.

I want the image and the video to retain their size and output an image of the 2 overlaid.

Can someone please give me advice on how I can do this?


回答1:


Skip the scale2ref.

"-i", video.mp4, "-i", image.mp4, "-filter_complex", "[0:v]pad=iw:2*trunc(iw*16/9/2):(ow-iw)/2:(oh-ih)/2[v0];[1:v][v0]scale2ref[v1][v0];[v0][v1]overlay=x=(W-w)/2:y=(H-h)/2[v]", "-map", "[v]", "-q:v", "2", directoryToStore + "/" + ImageName + ".jpeg"



来源:https://stackoverflow.com/questions/55332539/ffmpeg-overlay-image-on-video-and-retain-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!