[FFmpeg-devel] [PATCH] ffprobe: do not exit in case the demuxer returns AVERROR(EAGAIN)

wm4 nfxjfg at gmail.com
Tue Nov 17 17:12:46 CET 2015


On Tue, 17 Nov 2015 17:00:29 +0100
Stefano Sabatini <stefasab at gmail.com> wrote:

> On date Tuesday 2015-11-17 15:20:32 +0100, wm4 encoded:
> > On Tue, 17 Nov 2015 15:13:02 +0100
> > Stefano Sabatini <stefasab at gmail.com> wrote:
> >   
> > > Fix demuxing of files for which the demuxer returns AVERROR(EAGAIN) at
> > > some point. Also returns error code to the caller in case of different
> > > non EOF error.
> > > ---
> > >  ffprobe.c | 11 ++++++++++-
> > >  1 file changed, 10 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/ffprobe.c b/ffprobe.c
> > > index c304a6d..481ff0b 100644
> > > --- a/ffprobe.c
> > > +++ b/ffprobe.c
> > > @@ -2027,7 +2027,16 @@ static int read_interval_packets(WriterContext *w, AVFormatContext *fmt_ctx,
> > >          ret = AVERROR(ENOMEM);
> > >          goto end;
> > >      }
> > > -    while (!av_read_frame(fmt_ctx, &pkt)) {
> > > +    while (1) {
> > > +        ret = av_read_frame(fmt_ctx, &pkt);
> > > +        if (ret == AVERROR(EAGAIN))
> > > +            continue;
> > > +        if (ret < 0) {
> > > +            if (ret == AVERROR_EOF)
> > > +                ret = 0;
> > > +            break;
> > > +        }
> > > +
> > >          if (fmt_ctx->nb_streams > nb_streams) {
> > >              REALLOCZ_ARRAY_STREAM(nb_streams_frames,  nb_streams, fmt_ctx->nb_streams);
> > >              REALLOCZ_ARRAY_STREAM(nb_streams_packets, nb_streams, fmt_ctx->nb_streams);  
> >   
> 
> > Couldn't this get stuck forever if the API just keeps returning a
> > demuxer error without making progress?  
> 
> No, just in case ret == AVERROR(EAGAIN), in all other failure cases it
> will exit the loop immediately.
> 
> BTW, the same problem affects some API usage examples.

Yeah, I got that wrong - but even with EAGAIN, is there a guarantee?


More information about the ffmpeg-devel mailing list