有些filter是支持enable参数的。比如drawtext,对于这些支持enable参数的filter,这个参数通过判断一些逻辑问题,来判断当帧是否进入这个filter。
如果逻辑是零,那就不改变帧的信息,把帧传入filtergraph中当前filter 的下一个filter中;
如果逻辑是非零,那当前帧就进入该filter,接受这个filter的处理,处理完该帧后再传给下一个filter
enable
option支持的逻辑表达式中的值有:
- ‘t’
timestamp expressed in seconds, NAN if the input timestamp is unknown - ‘n’
sequential number of the input frame, starting from 0 - ‘pos’
the position in the file of the input frame, NAN if unknown - ‘w’
- ‘h’
width and height of the input frame if video
和其他filter的option一样,enable
option遵循一些原则。如下:
eg1:使用drawtext filter 在第3秒到第5秒之间加入文字:
drawtext=enable='between(t,3,5)'
eg2:使用curves filter从第三秒开始:
curves = enable='gte(t,3)' : preset=cross_process
想要知道哪些filter支持enable
option,可以使用:ffmpeg -filters
命令,凡是filter有 T的都支持timeline editing