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

Stefano Sabatini stefasab at gmail.com
Fri Nov 20 13:30:50 CET 2015


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.
-- 
FFmpeg = Fast and Furious Magic Proud Eager Guide
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-ffprobe-Sleep-and-retry-when-the-demuxer-returns-AVE.patch
Type: text/x-diff
Size: 1544 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151120/fa2c39ae/attachment.patch>


More information about the ffmpeg-devel mailing list