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

相关推荐
合尘猫1 天前
用 6GB 显卡搭短视频产线:MiniMax H3 + ffmpeg 全流程实录(55 秒片 / 40 分钟)
人工智能·音视频
JonaHu1 天前
博客转视频总返工?用章节清单、样片和 FFmpeg 搭一条可控流水线
ffmpeg·ai视频·内容创作·acedatacloud
the3clipse3 天前
Windows 11 26H2 声音与音频问题排查指南:没声音、麦克风不收音与蓝牙音频优化
音视频·le audio·windows 11 26h2·win11没声音·麦克风没声音·蓝牙耳机音质·音频服务修复
开开心心就好3 天前
PDF水印怎么去掉?勾选对象再点匹配
java·前端·mysql·支持向量机·pdf·音视频·模拟退火算法
RobinDevNotes4 天前
Claude Code 剪视频,不上传、不要 API Key
人工智能·python·音视频·开发工具·ipython
伯奥克客服4 天前
2026年视频综合一体机架构选型:从接口协议到流媒体底层的深度技术解析
架构·音视频
开开心心就好4 天前
两张表格数据对比工具,不用写函数也能查
算法·spring·智能手机·pdf·电脑·intellij-idea·音视频
FansAI_art4 天前
多角色 AIGC 短片的双模型分工:静态生图与图生视频怎么接
aigc·音视频
山顶夕景5 天前
【ECCV2026】流式视频理解Thinking in Streaming Video
音视频·vlm·视频理解·多模态理解·流式视频
StarsGreen6 天前
ffmpeg中常用结构体以及函数简介以及版本变化情况
ffmpeg