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