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

Michael Niedermayer michaelni
Sat Jun 7 23:00:41 CEST 2008


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()

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080607/017ec3b2/attachment.pgp>



More information about the ffmpeg-devel mailing list