[FFmpeg-devel] [PATCH] ffmpeg: handle the case when get_filtered_frame() fails

Michael Niedermayer michaelni at gmx.at
Fri May 20 18:31:29 CEST 2011


On Fri, May 20, 2011 at 09:11:40AM +0200, Stefano Sabatini wrote:
> On date Friday 2011-05-20 02:38:26 +0200, Michael Niedermayer encoded:
> > On Fri, May 20, 2011 at 01:02:26AM +0200, Stefano Sabatini wrote:
> > > ---
> > >  ffmpeg.c |    3 ++-
> > >  1 files changed, 2 insertions(+), 1 deletions(-)
> > > 
> > > diff --git a/ffmpeg.c b/ffmpeg.c
> > > index fb644ad..b6ee7e3 100644
> > > --- a/ffmpeg.c
> > > +++ b/ffmpeg.c
> > > @@ -1690,7 +1690,8 @@ static int output_packet(AVInputStream *ist, int ist_index,
> > >                  while (frame_available) {
> > >                      AVRational ist_pts_tb;
> > >                      if (ist->st->codec->codec_type == AVMEDIA_TYPE_VIDEO && ost->output_video_filter)
> > > -                        get_filtered_video_frame(ost->output_video_filter, &picture, &ost->picref, &ist_pts_tb);
> > > +                        if (get_filtered_video_frame(ost->output_video_filter, &picture, &ost->picref, &ist_pts_tb) < 0)
> > > +                            goto cont;
> > >                      if (ost->picref)
> > 
> > Can you elaborate when such failure happens ?
> > frame_available inplicates poll_frame() so request shouldnt fail i
> > think
> 
> Indeed this needs some explanation, as the failure I was experiencing
> comes from a pending select filter.
> 
> The filter works by selecting a frame according to an expression
> evaluated on the frame properties. poll() is propagated to the source,
> so we could have this situation:
> buffer tells that there is a frame, but when the frame is requested
> and is not selected request_frame() will fail. I tried other buffering
> methods but I concluded that this model was the cleaner/simpler.

I think thats problematic.

With a filter graph with multiple outputs one needs to know where
frames are available to pull them out
otherwise a split filter followed by a frame duplication filter on
one side could quickly eat up all memory as frames are pulled out of
one side while more and more accumulate on the other.

also its problematic inside the graph
a filter that combined n inputs might check with poll_frame if
they are all available before requesting all and combining.
if now one fails this makes buffering requirements for it more complex.

either way, this would require changing the documented API:
   /**
     * Frame poll callback. This returns the number of immediately available
     * samples. It should return a positive value if the next request_frame()
     * is guaranteed to return one frame (with no delay).
     *
     * Defaults to just calling the source poll_frame() method.
     *
     * Output video pads only.
     */
    int (*poll_frame)(AVFilterLink *link);




[...]
-- 
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/20110520/ce756969/attachment.asc>


More information about the ffmpeg-devel mailing list