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

wm4 nfxjfg at googlemail.com
Fri Nov 20 13:50:16 CET 2015


On Fri, 20 Nov 2015 13:30:50 +0100
Stefano Sabatini <stefasab at gmail.com> wrote:

> On date Wednesday 2015-11-18 15:21:15 +0100, Nicolas George encoded:
> > Le septidi 27 brumaire, an CCXXIV, Stefano Sabatini a écrit :  
> > > 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;  
> > 
> > This is a busy wait, this is one of the evilest constructions possible.
> >   
> 
> > For real EAGAIN cases, a sleep would be needed, until we have a real event
> > loop. Other cases are bugs in the demuxers.  
> 
> Yes, updated patch with EAGAIN (if this is fine, I'll send patches to
> fix the examples).
> 
> In my case the EAGAIN is triggered by the flv demuxer code in
> flvdec.c:935:
> 
>         /* skip empty data packets */
>         if (!size) {
>             ret = AVERROR(EAGAIN);
>             goto leave;
>         }
> 
> introduced in 527c2e64295671bfcd9c86ca2cfd75e0f4d79f73.
> 
> Not sure if this is a defect.

Isn't it actually fcb4228c863ec80c9498a6c5e815d79ee9f89a7f and
a308737bd66a1c669b9be71a1b834d8419fe70ca?


More information about the ffmpeg-devel mailing list