image - How to add image in a video at particular location of the frame using ffmpeg
问题描述
I need to add a image overlay in a video using ffmpeg. ffmpeg -i test.mp4 -i logo.png -filter_complex "[0:v][1:v] overlay=10:10:enable='between(t,1,10)'" output.mp4
I tried the above code but the overlay image size is very hight and it showing on the top possition of the frame.
Image1 The image1 showing the result what i get after running the above code. I need the output like image2.image2
解决方案
ffmpeg test.mp4 -i logo.png -filter_complex "\
[1][0]scale2ref=w=oh*mdar:h=ih/10[logo][input0];\
[input0][logo]overlay=x=main_w*0.05:(main_h-overlay_h)-(main_h *
0.1):enable='between(t,1,10)'" output.mp4
Line Description:
- Make Logo-height 10% of video-height
x=main_w*0.05
-> position Logo 5% away from the left edge of the screen;(main_h-overlay_h)-(main_h * 0.1)
-> position Logo 10% away from the bottom edge of the screen;
If you prefer a fade-in of the logo rather than a sudden appearance use this:
ffmpeg -i test.mp4 -loop 1 -i logo.png -filter_complex "\
[1][0]scale2ref=w=oh*mdar:h=ih/10[logo][input0];\
[logo]format=rgba,\
fade=in:\
st=1:\
d=0.5:\
alpha=1\
,fade=out:st=6:d=0.5:alpha=1\
[logo2];\
[input0][logo2]overlay=x=main_w*0.05:(main_h-overlay_h)-(main_h * 0.1):" output.mp4
(You can delete Line 8
if you don't want to fade out.)
推荐阅读
- python - 在python中搜索列表的最快方法
- java - java - 如何从Java中的CSV文件数据计算BMI(身体质量指数)?
- c - 将二维数组保存在指针数组中
- python - 调用另一个函数时函数出错
- ios - 与 gmail 应用程序共享文件 - 没有附加文件
- python - 在拼接期间修剪图像
- java - 带有模态的舞台隐藏最大化按钮
- oracle-apex - 是否可以在其他数据库服务器上运行 Apex?
- node.js - 在 apache 服务器上托管带有 hello world 的简单快速应用程序
- c# - 在 vb.net 或 c# 中获取 sharepoint 的 listitem 中的列表文件夹