[FFmpeg-devel] [PATCH 3/5] ffmpeg: flush and drain video filters.

Michael Niedermayer michaelni at gmx.at
Mon Mar 12 21:11:31 CET 2012


On Sun, Mar 11, 2012 at 11:10:44AM +0100, Nicolas George wrote:
> Le duodi 22 ventôse, an CCXX, Michael Niedermayer a écrit :
> > avfilter was designed to handle multiple inputs and outputs from the
> > begin so iam certainly interrested to hear in what cases this doesnt
> > work currently
> 
> Consider the following command:
> 
> ./ffmpeg_g -i some_video -vf 'split [out], fifo, nullsink' some_output
> 
> but before you try it, make sure you have severely limited the memory
> consumption¹.
> 
> The problem is that as frames are requested on [out], split will send them
> to fifo too, but nullsink will never request them: they accumulate in fifo.
> 
> Of course, both fifo and nullsink are silly here, but it could be something
> useful, like stats_sink, and some piece of filters that needs to be
> protected by fifo.

this can easily be solved by requireing sinks to pull. Implementation
wise it could be that every time theres some activity on a filter graph
like a frame added, we would do
for all sinks
    while poll_frame()
        request_frame()



> 
> The same problem happens if nullsink is a second output: if we drain one
> output until it is exhausted, frames can accumulate in the other one, but if
> we drain non-recursively, we will not notice that fifo is blocking data.
> 
> The crux of the problem is that filters need to help regulating the traffic,
> and that is precisely the opposite of what fifo does. We need to make sure
> that fifo is never necessary, and make it go away. For that, we need to

fifos are necessary in some cases.


> observe very carefully all filters with several inputs to check that they
> will not recurse (vf_overlay, I am looking at you) indefinitely.
> 
> (Also, for that reason, I withdraw my proposal of adding a flag telling if a
> filter is safe to push a frame it has not requested: all filters need to be,
> or they will cause traffic jam.)

that would mean such filters would need internal fifos. Or to say it
differently any filter that cannot accept a arbitrary pushed in frame
needs a fifo, theres no way around that, you can implement the fifo
elsewhere but you need a fifo.
consider a split filter a filter that removes commercials and a
merge of the 2 so you mix 2 movies one with and one without commercials
in this case the point of this could be to vissually show how much time
is spend by the commercials in a movie. It needs a fifo and it needs
to buffer the frames that make up the delay between the 2 cases.


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 1
"Used only once"    - "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120312/eb2a06b4/attachment.asc>


More information about the ffmpeg-devel mailing list