[FFmpeg-devel] Writing filters

James Darnley james.darnley at gmail.com
Wed Jun 11 15:02:46 CEST 2014

While I appreciate the effort someone put into doc/writing_filters.txt
it still doesn't go far enough for me to understand enough for what I
want to do, namely an A->V filter.

It (doc/writing_filters.txt) is based on a one-in-one-out video filter
(edgedetect) so it doesn't need to explain some of the more
"interesting" functions.  It only has to explain filter_frame which, I
think, is fairly simple in concept: it is called by the previous filter
and itself calls the next filter's filter_frame, indirectly though
ff_filter_frame (I think).

While looking at some of the vsrc and other avf filters, I see that some
use filter_frame, some use request_frame, and some use both.

I believe request frame works in the other direction: it gets called
from the next filter, does whatever it needs to and then "returns".  I'm
sure you can see that I don't understand this quite as well.  Its use in
mandelbrot is obvious, it draws the picture then calls ff_filter_frame
to send the image along the chain.

What I don't understand is: why some filters use both; how they use both
and how data gets from the input to the output; and when I (or another
user) should use both.

I see that request_frame in showwaves and showspectrum run request_frame
in a loop until "something" happens (they actually set a var in their
context) but, their flow is obscured by an inline push_frame function
which calls ff_filter_frame.  This looks like it should result in the
same frame going to the next filter twice over.

What adds to my confusion is that avectorscope doesn't use both, it uses
only filter_frame.

I guess my ultimate questions are:

Is my understanding how filter_frame and request_frame correct?

If necessary, can someone explain in more detail the difference between
filter_frame and request_frame?

Why do some filters, particularly showwaves and showspectrum, use both
filter_frame and request_frame?  Why does avectorscope not?

How do frames flow though showwaves and showspectrum?

If not already explained, when should a filter use both or not use both
filter_frame and request_frame?

I appreciate any insights people can give.  Anything I learn, I will try
to add to existing docs.

One final thought, I hope my problems aren't coming from how I am trying
to run the filter:
> ffmpeg -f lavfi -i 'amovie=temp.flac,asplit[out0],jd=rate=60[out1]' -y tempabc.mkv

Which was largely copied from the existing docs here:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 683 bytes
Desc: OpenPGP digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140611/62f40c34/attachment.asc>

More information about the ffmpeg-devel mailing list