ffmpeg视频滤镜:缓入缓出-fade

滤镜描述

fade

官网链接 => FFmpeg Filters Documentation

这个滤镜可以给视频加上一个缓入或者缓出的特效。

滤镜的使用

参数
复制代码
   type              <int>        ..FV....... set the fade direction (from 0 to 1) (default in)
     in              0            ..FV....... fade-in
     out             1            ..FV....... fade-out
   t                 <int>        ..FV....... set the fade direction (from 0 to 1) (default in)
     in              0            ..FV....... fade-in
     out             1            ..FV....... fade-out
   start_frame       <int>        ..FV....... Number of the first frame to which to apply the effect. (from 0 to INT_MAX) (default 0)
   s                 <int>        ..FV....... Number of the first frame to which to apply the effect. (from 0 to INT_MAX) (default 0)
   nb_frames         <int>        ..FV....... Number of frames to which the effect should be applied. (from 1 to INT_MAX) (default 25)
   n                 <int>        ..FV....... Number of frames to which the effect should be applied. (from 1 to INT_MAX) (default 25)
   alpha             <boolean>    ..FV....... fade alpha if it is available on the input (default false)
   start_time        <duration>   ..FV....... Number of seconds of the beginning of the effect. (default 0)
   st                <duration>   ..FV....... Number of seconds of the beginning of the effect. (default 0)
   duration          <duration>   ..FV....... Duration of the effect in seconds. (default 0)
   d                 <duration>   ..FV....... Duration of the effect in seconds. (default 0)
   color             <color>      ..FV....... set color (default "black")
   c                 <color>      ..FV....... set color (default "black")
  • type, 选择in(换入)或者out(缓出)。t 是type的简写
  • start_frame, 从第几帧开始使用这个特效,(s)是start_frame的缩写
  • nb_frames, 特效持续多帧。 如果你使用了out特效,并且start_frame设置的比较小,比如0。nb_frames如果设置的比较小的话,比如30,那么视频就会显示30帧了,因为30帧以后就是退出了。
  • alpha, 是不是启用遮罩,以缓入为例,启用遮罩的效果-> 纯黑-> 纯黑慢慢褪去->显示视频。 不启用的话就和正常播放没有区别。
  • start_time (st), 从第几秒开始应用特效。
  • duration(d), 特效持续的时间。当然start_time也可以和nb_frames进行搭配。
  • color(c), 遮罩的颜色。
案例
复制代码
ffmpeg -y -i ffm_media/short_dancer.mp4 -filter_complex "fade=in:0:30" result/fade/fade_test_001.mp4

从第0秒开始持续30帧,应用缓入效果。

复制代码
ffmpeg -y -i ffm_media/short_dancer.mp4 -filter_complex "fade=out:0:30" result/fade/fade_test_002.mp4

从第0秒开始,持续30帧,应用退出效果,30帧以后就剩下黑屏了

复制代码
ffmpeg -y -i ffm_media/short_dancer.mp4 -filter_complex "fade=out:start_time=4:duration=2" result/fade/fade_test_003.mp4

从第4秒开始,应用缓出效果,持续两秒

复制代码
ffmpeg -y -i ffm_media/short_dancer.mp4 -filter_complex "fade=out:start_time=4:duration=2:color=green" result/fade/fade_test_004.mp4

将缓出的遮罩应用为绿色

复制代码
ffmpeg -y -i ffm_media/short_dancer.mp4 -filter_complex "fade=in:5:20:color=yellow" result/fade/fade_test_005.mp4

将缓入的遮罩应用为黄色

复制代码
## 祝你好运
 
hope("大神多多指点")
topic("有问题可以交流呀")
concat("球球QUN", "61480", "9646")
include("电", "-","子", "=", "书")

相关推荐
阿酷tony2 小时前
如何做视频课程的报名观看?实现报名后,才能观看视频?
音视频
福大大架构师每日一题2 小时前
ollama v0.20.0 更新:Gemma 4 全家桶发布,音频、视觉、MoE、BPE 支持全面升级
音视频·ollama
Flamingˢ1 天前
ZYNQ + OV5640 + HDMI 视频系统调试记录:一次 RGB888 与 RGB565 引发的黑屏问题
arm开发·嵌入式硬件·fpga开发·vim·音视频
Flamingˢ1 天前
YNQ + OV5640 视频系统开发(二):OV5640_Data IP 核源码解析
arm开发·嵌入式硬件·网络协议·tcp/ip·fpga开发·vim·音视频
Flamingˢ1 天前
ZYNQ + OV5640 视频系统开发(三):AXI VDMA 帧缓存原理
arm开发·嵌入式硬件·fpga开发·vim·音视频
Hello World . .1 天前
Linux:Linux命令行音视频播放器
linux·音视频
飞翔的SA1 天前
MLX‑VLM :Mac本地跑通多模态大模型的开源项目!让图片、音频、视频理解一键上手
人工智能·python·macos·音视频
愚公搬代码2 天前
【愚公系列】《剪映+DeepSeek+即梦:短视频制作》046-转场:短视频一气呵成的秘密(什么是转场)
人工智能·音视频
PiaoShiSun2 天前
小米手机浏览器缓存视频如何导出
缓存·智能手机·音视频
艾为电子2 天前
【新品发布】攻克音频切换痛点|艾为 AW35331FDR 高保真音频开关全新登场
音视频