版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_36783046/article/details/86405469
前言
在FFmpeg开源工程中添加一个新的AVFilter包括6个基本步骤。下面以maskfun
为例进行说明。
1 在libavfilter目录下添加实现文件
如果是video filter,则文件名以vf_开头;如果是audio filter,则文件名以af_开头,本例中是 vf_maskfun.c。具体实现内容这里不展开。
2 在libavfilter/allfilters.c中添加外部声明
allfilters.c中包含所有AVFilter全局变量的外部声明。在合适的位置按字母排序添加新的AVFilter。
extern AVFilter ff_vf_maskedclamp;
extern AVFilter ff_vf_maskedmerge;
extern AVFilter ff_vf_maskfun;
extern AVFilter ff_vf_mcdeint;
3 在libavfilter/Makefile中添加相关指令
OBJS-$(CONFIG_MASKEDCLAMP_FILTER) += vf_maskedclamp.o framesync.o
OBJS-$(CONFIG_MASKEDMERGE_FILTER) += vf_maskedmerge.o framesync.o
OBJS-$(CONFIG_MASKFUN_FILTER) += vf_maskfun.o
OBJS-$(CONFIG_MCDEINT_FILTER) += vf_mcdeint.o
4 在libavfilter/version.h中修改版本号
将LIBAVFILTER_VERSION_MINOR
加1,LIBAVFILTER_VERSION_MICRO
重置为100
#define LIBAVFILTER_VERSION_MAJOR 7
#define LIBAVFILTER_VERSION_MINOR 48
#define LIBAVFILTER_VERSION_MICRO 100
5 在Changelog中增加一条记录
在Changelog
的version <next>:
区域的最下方增加新filter的记录
version <next>:
- tpad filter
- AV1 decoding support through libdav1d
- dedot filter
- chromashift and rgbashift filters
- freezedetect filter
- truehd_core bitstream filter
- dhav demuxer
- PCM-DVD encoder
- GIF parser
- vividas demuxer
- hymt decoder
- anlmdn filter
- maskfun filter
6 在doc/filters.texi中补充文档说明
@section maskfun
Create mask from input video.
For example it is useful to create motion masks after @code{tblend} filter.
This filter accepts the following options:
@table @option
@item low
Set low threshold. Any pixel component lower or exact than this value will be set to 0.
@item high
Set high threshold. Any pixel component higher than this value will be set to max value
allowed for current pixel format.
@item planes
Set planes to filter, by default all available planes are filtered.
@item fill
Fill all frame pixels with this value.
@item sum
Set max average pixel value for frame. If sum of all pixel components is higher that this
average, output frame will be completely filled with value set by @var{fill} option.
Typically useful for scene changes when used in combination with @code{tblend} filter.
@end table