• FFMpeg zoompan 镜头聚焦和移动走位


    案例 

    原始图片

    1. # 输出帧数,默认25帧/秒,25*4 代表4秒
    2. # s=1280x80 # 输出视频比例,可以设置和输入图片大小一致
    3. # zoom+0.002 表示每帧放大的倍数,下面代码是25帧/每秒 * 4秒,共1000帧
    4. # 最终是 0.002*25*4 = 0.2,最终是放大1.2倍
    5. ffmpeg -i "./sdout/1.jpg" \
    6. -filter_complex \
    7. "zoompan=z='zoom+0.002':d=25*4:s=600x380" \
    8. out.gif

    只是改变Z坐标的话,图片将会从左上角开始变化

    也可以指定x,y,(默认值是0)

    如果想缩放到图片右边,可以指定 x=iw-iw/zoom ,图片的宽-缩放后的宽

    如果想缩放到图片底部,指定 y=ih-ih/zoom

    如果想缩小图片,需要初始化图片尺寸,比如 z='if(eq(on,1),1.2,zoom-0.002) 

    1. ffmpeg -i "./sdout/1.jpg" \
    2. -filter_complex \
    3. "zoompan=x='iw-iw/zoom':y='ih-ih/zoom':z='if(eq(on,1),1.2,zoom-0.002)':d=25*4:s=600x338" \
    4. out1.gif

    1. # 如果zoom <= 1.0, z=1.5 否则 z= (1.001 和 zoom-0.0015)中大的
    2. # 最终效果就是: 从 1.5 倍数缩小到 1.001
    3. ffmpeg -i "./sdout/1.jpg" \
    4. -filter_complex \
    5. "zoompan=z='if(lte(zoom,1.0),1.5,max(1.001,zoom-0.0015))':d=25*4:s=600x380" \
    6. out2.gif

    聚焦中心点

    1. # 聚焦到图片center中心点,时长4秒
    2. ffmpeg -i "./sdout/1.jpg" \
    3. -filter_complex \
    4. "zoompan=x='iw/2*(1-1/zoom)':y='ih/2*(1-1/zoom)':z='zoom+0.002':d=25*4:s=600x338" \
    5. out3.gif
    6. # zoompan拆解
    7. zoompan=
    8. x='iw/2*(1-1/zoom)': # iw/2 代表要聚焦的x轴,zoom = 下面放大的比例
    9. y='ih/2*(1-1/zoom)': # ih/2 代表要聚焦的y轴
    10. z='2': # 聚焦放大的比例,这里代表2倍
    11. d=25*4: # 输出帧数,默认25帧/秒,25*4 代表4秒
    12. s=640x360 # 输出视频比例,可以设置和输入图片大小一致

    参数

    1. # 以下是命令参数
    2. zoom, z 放大倍数,1到10,默认1
    3. x,y 坐标,默认0
    4. d 总帧数,默认90
    5. s 输出图片尺寸,默认hd720
    6. fps 帧率,默认25
    7. # 以下是参数里的常量
    8. in_w, iw 输入宽
    9. in_h, ih 输入高
    10. out_w, ow 输出宽
    11. out_h, oh 输出高
    12. in 输入帧数
    13. on 输出帧数
    14. in_time, it The input timestamp expressed in seconds. It’s NAN if the input timestamp is unknown.
    15. out_time, time, ot The output timestamp expressed in seconds.
    16. x,y Last calculated ’x’ and ’y’ position from ’x’ and ’y’ expression for current input frame.
    17. 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).
    18. zoom 上一帧 z 值
    19. pzoom Last calculated zoom of last output frame of previous input frame.
    20. duration Number of output frames for current input frame. Calculated from ’d’ expression for each input frame.
    21. pduration number of output frames created for previous input frame
    22. a Rational number: input width / input height
    23. sar sample aspect ratio
    24. dar display aspect ratio

    表达式

    Expression Evaluation - FFmpeg

    1. # x,y 中取大值
    2. max(x, y)
    3. # x <= y 返回 1, 否则返回 0
    4. lte(x, y)

    参考:

    FFmpeg滤镜效果--镜头聚焦和移动走位 - 知乎

    FFmpeg Filters Documentation

    Ken Burns Effect Slideshows with FFMPeg | mko.re 

  • 相关阅读:
    使用 Gradle 命令了解项目构建信息
    2024免费MAC苹果电脑系统优化软件CleanMyMac X
    精品基于Java的社区团购系统SSM
    1.稀疏数组
    荧光纳米/多肽/聚合物纳米AIE微球/正电荷/pH响应性AIE荧光纳米微球的相关研究
    Pytest----什么是实时标准输出和捕获标准输出
    C++工资管理系统
    超长时间序列数据可视化的6个技巧
    网络安全技能差距的高成本
    SpringMVC(JSR303和拦截器)
  • 原文地址:https://blog.csdn.net/linzhiji/article/details/133020028