Croolman
Croolman

Reputation: 1123

How to add a new filter to ffmpeg library

I am trying to add functionality to FFmpeg library. The issue is that in developer guide there are just general instruction on how to do it. I know that when I want to add something to ffmpeg I need to register the new functionality and rebuild the library so I can then call it somehow like so:

ffmpeg -i input.avi -vf "myfilter" out.avi

I do not want to officialy contribute. I would like to try to create the extra functionality and test it. The question is - is there any scelet file where the basic structure would be ready and you would just get a pointer to a new frame and processed it? Some directions or anything, because the source files are kinda hard to read without understanding its functions it calls inside.

Upvotes: 2

Views: 6157

Answers (2)

andrew pate
andrew pate

Reputation: 4297

The document in the repo is worth a read: ffmpeg\doc\writing_filters.txt

The steps are:

  1. Add an appropriate line to the: ffmpeg\libavfilter\Makefile

    OBJS-$(CONFIG_MCSCALE_CUDA_FILTER) += vf_mcscale_cuda.o vf_mcscale_cuda.ptx.o scale_eval.o

  2. Add an appropriate line to the: ffmpeg\libacfilter\allfilters.c

    extern AVFilter ff_vf_mcscale_cuda;

  3. The change in (2) does not become recognized until ./configure scans the files again to configure the build, so run Configure and when you next run make the filter should be generated. Happy days.

Upvotes: 2

Shevach Riabtsev
Shevach Riabtsev

Reputation: 495

i was faced with a problem to add transform_v1 filter (see details on transform 360 filters at https://www.diycode.cc/projects/facebook/transform360 ) to ffmpeg with the version N-91732-g1124df0. i did exactly according to writing_filters.txt but transform_v1.o is not linked?

i added the object file (vf_transform_v1.o) in Makefile of libavfilter. OBJS-$(CONFIG_TRANSFORM_V1_FILTER)+= vf_transform_v1.o

i checked that the define CONFIG_TRANSFORM_V1_FILTER=1 is present in config.h . However, after the compilation transform_v1 is still not recognized. i resolved this issue in an awkward way, i added explicitly vf_transform_v1.o in OBJ-list without conditioning by the global define CONFIG_TRANSFORM_V1_FILTER:

OBJS+= vf_transform_v1.o 

Upvotes: 1

Related Questions