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("电", "-","子", "=", "书")

相关推荐
饭饭大王66612 小时前
CANN 生态深度整合:使用 `pipeline-runner` 构建高吞吐视频分析流水线
人工智能·音视频
xmRao13 小时前
Qt+FFmpeg 实现 PCM 音频转 AAC 编码
qt·ffmpeg·pcm
xmRao13 小时前
Qt+FFmpeg 实现录音程序(pcm转wav)
qt·ffmpeg
晚霞的不甘14 小时前
CANN 编译器深度解析:TBE 自定义算子开发实战
人工智能·架构·开源·音视频
愚公搬代码14 小时前
【愚公系列】《AI短视频创作一本通》016-AI短视频的生成(AI短视频运镜方法)
人工智能·音视频
那个村的李富贵15 小时前
CANN赋能AIGC“数字人”革命:实时视频换脸与表情驱动实战
aigc·音视频
晚霞的不甘15 小时前
CANN 支持强化学习:从 Isaac Gym 仿真到机械臂真机控制
人工智能·神经网络·架构·开源·音视频
晚霞的不甘19 小时前
CANN 支持多模态大模型:Qwen-VL 与 LLaVA 的端侧部署实战
人工智能·神经网络·架构·开源·音视频
拾荒的小海螺1 天前
开源项目:LTX2 高效可控的开源视频生成模型
开源·音视频
EasyGBS1 天前
视频画面模糊、卡顿、丢失?EasyGBS新增“视频质量诊断”功能,告别人工盯屏
视觉检测·音视频·gb28181·花屏·视频质量诊断·蓝屏检测