已解决
FFMpeg zoompan 镜头聚焦和移动走位
来自网友在路上 168868提问 提问时间:2023-09-19 15:21:26阅读次数: 68
最佳答案 问答题库688位专家为你答疑解惑
案例
原始图片
# 输出帧数,默认25帧/秒,25*4 代表4秒
# s=1280x80 # 输出视频比例,可以设置和输入图片大小一致
# zoom+0.002 表示每帧放大的倍数,下面代码是25帧/每秒 * 4秒,共1000帧
# 最终是 0.002*25*4 = 0.2,最终是放大1.2倍
ffmpeg -i "./sdout/1.jpg" \
-filter_complex \
"zoompan=z='zoom+0.002':d=25*4:s=600x380" \
out.gif
只是改变Z坐标的话,图片将会从左上角开始变化
也可以指定x,y,(默认值是0)
如果想缩放到图片右边,可以指定 x=iw-iw/zoom
,图片的宽-缩放后的宽
如果想缩放到图片底部,指定 y=ih-ih/zoom
如果想缩小图片,需要初始化图片尺寸,比如 z='if(eq(on,1),1.2,zoom-0.002)
ffmpeg -i "./sdout/1.jpg" \
-filter_complex \
"zoompan=x='iw-iw/zoom':y='ih-ih/zoom':z='if(eq(on,1),1.2,zoom-0.002)':d=25*4:s=600x338" \
out1.gif
# 如果zoom <= 1.0, z=1.5 否则 z= (1.001 和 zoom-0.0015)中大的
# 最终效果就是: 从 1.5 倍数缩小到 1.001ffmpeg -i "./sdout/1.jpg" \
-filter_complex \
"zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=25*4:s=600x380" \
out2.gif
聚焦中心点
# 聚焦到图片center中心点,时长4秒
ffmpeg -i "./sdout/1.jpg" \
-filter_complex \
"zoompan=x='iw/2*(1-1/zoom)':y='ih/2*(1-1/zoom)':z='zoom+0.002':d=25*4:s=600x338" \
out3.gif# zoompan拆解
zoompan=x='iw/2*(1-1/zoom)': # iw/2 代表要聚焦的x轴,zoom = 下面放大的比例y='ih/2*(1-1/zoom)': # ih/2 代表要聚焦的y轴z='2': # 聚焦放大的比例,这里代表2倍d=25*4: # 输出帧数,默认25帧/秒,25*4 代表4秒s=640x360 # 输出视频比例,可以设置和输入图片大小一致
参数
# 以下是命令参数
zoom, z 放大倍数,1到10,默认1
x,y 坐标,默认0
d 总帧数,默认90
s 输出图片尺寸,默认hd720
fps 帧率,默认25# 以下是参数里的常量
in_w, iw 输入宽
in_h, ih 输入高
out_w, ow 输出宽
out_h, oh 输出高
in 输入帧数
on 输出帧数
in_time, it The input timestamp expressed in seconds. It’s NAN if the input timestamp is unknown.
out_time, time, ot The output timestamp expressed in seconds.
x,y Last calculated ’x’ and ’y’ position from ’x’ and ’y’ expression for current input frame.
px,py ’x’ and ’y’ of last output frame of previous input frame or 0 when there was not yet such frame (first input frame).
zoom 上一帧 z 值
pzoom Last calculated zoom of last output frame of previous input frame.
duration Number of output frames for current input frame. Calculated from ’d’ expression for each input frame.
pduration number of output frames created for previous input frame
a Rational number: input width / input height
sar sample aspect ratio
dar display aspect ratio
表达式
Expression Evaluation - FFmpeg
# x,y 中取大值
max(x, y)# x <= y 返回 1, 否则返回 0
lte(x, y)
参考:
FFmpeg滤镜效果--镜头聚焦和移动走位 - 知乎
FFmpeg Filters Documentation
Ken Burns Effect Slideshows with FFMPeg | mko.re
查看全文
99%的人还看了
相似问题
猜你感兴趣
版权申明
本文"FFMpeg zoompan 镜头聚焦和移动走位":http://eshow365.cn/6-9369-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!
- 上一篇: 企业架构LNMP学习笔记48
- 下一篇: AIGC入门 - LLM 信息概览