[FFmpeg-devel] [PATCH] Make ffmpeg.c use print_error() when it can't read a ffserver stream

Stefano Sabatini stefano.sabatini-lala
Fri Jun 13 00:32:13 CEST 2008


On date Sunday 2008-06-08 12:57:06 +0200, Michael Niedermayer encoded:
> On Sat, Jun 07, 2008 at 11:48:18PM +0200, Stefano Sabatini wrote:
> > On date Saturday 2008-06-07 23:00:41 +0200, Michael Niedermayer encoded:
> > > On Sat, Jun 07, 2008 at 08:04:17PM +0200, Stefano Sabatini wrote:
> > > > Hi, as in subject.
> > > > 
> > > > This is more consistent with the other use of av_open_input_file() in
> > > > ffmpeg.c in opt_input_file, which is:
> > > > 
> > > >     /* open the input file with generic libav function */
> > > >     err = av_open_input_file(&ic, filename, file_iformat, 0, ap);
> > > >     if (err < 0) {
> > > >         print_error(filename, err);
> > > >         av_exit(1);
> > > >     }
> > > > 
> > > > also the error message reported by print_error() should be at least
> > > > theoretically more accurate than the generic one currently used in
> > > > read_ffserver_streams():
> > > > 
> > > > fprintf(stderr, "Could not read stream parameters from '%s'\n", filename);
> > > > 
> > > > This will lead to error messages of the kind:
> > > > stefano at geppetto ~/s/ffmpeg> ffmpeg -f video4linux -s 640x480 -r 25 -i /dev/video0 http://localhost:8090/feed1.ffm
> > > > [...]
> > > > Input #0, video4linux, from '/dev/video0':
> > > >   Duration: N/A, start: 1212861538.055957, bitrate: 92160 kb/s
> > > >     Stream #0.0: Video: rawvideo, yuv420p, 640x480, 92160 kb/s, 25.00 tb(r)
> > > > http://localhost:8090/feed1.ffm: I/O error occurred
> > > > Usually that means that input file is truncated and/or corrupted.
> > > > 
> > > > BTW, I also think that the EIO error code returned in this case when
> > > > we try to open a closed TCP port is still too vague, I'd like
> > > > something more meaningful, which leads to the old discussion about the
> > > > error codes managed by FFmpeg.
> > > > 
> > > > Do you have you any hint (maybe just another more specific error code
> > > > describing the current situation)?
> > > > 
> > > > Best regards.
> > > > -- 
> > > > FFmpeg = Frenzy & Fast MultiPurpose EnGine
> > > 
> > > > Index: ffmpeg.c
> > > > ===================================================================
> > > > --- ffmpeg.c	(revision 13687)
> > > > +++ ffmpeg.c	(working copy)
> > > > @@ -423,14 +423,16 @@
> > > >      return ret;
> > > >  }
> > > >  
> > > > -static int read_ffserver_streams(AVFormatContext *s, const char *filename)
> > > > +static void read_ffserver_streams_or_die(AVFormatContext *s, const char *filename)
> > > >  {
> > > >      int i, err;
> > > >      AVFormatContext *ic;
> > > >  
> > > >      err = av_open_input_file(&ic, filename, NULL, FFM_PACKET_SIZE, NULL);
> > > > -    if (err < 0)
> > > > -        return err;
> > > > +    if (err < 0) {
> > > > +        print_error(filename, err);
> > > > +        av_exit(1);
> > > > +    }
> > > 
> > > Wwen all else is equal (like here) i prefer 'return some error' over exit()
> > 
> > Mmh.., so what about this one? It still addresses my main concern
> > which is to use the print_error() rather than a generic error message.
> 
> ok

Applied, regards.
-- 
FFmpeg = Furious and Fantastic Mythic Pitiful EntanGlement




More information about the ffmpeg-devel mailing list