[FFmpeg-devel] [PATCH] ffprobe: print error in main() rather than in probe_file()

Stefano Sabatini stefasab at gmail.com
Fri Jan 6 21:44:45 CET 2012


On date Friday 2012-01-06 21:18:53 +0100, Stefano Sabatini encoded:
> On date Friday 2012-01-06 20:44:56 +0100, Clément Bœsch encoded:
> > On Fri, Jan 06, 2012 at 07:14:13PM +0100, Stefano Sabatini wrote:
> > > Also move header and trailer print from probe_file() to main().
> > > 
> > > This allows to show print information also if there is no file
> > > information to show.
> > > ---
> > >  ffprobe.c |   10 ++++++----
> > >  1 files changed, 6 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/ffprobe.c b/ffprobe.c
> > > index dabbbc5..eea3d2c 100644
> > > --- a/ffprobe.c
> > > +++ b/ffprobe.c
> > [...]
> > > @@ -1528,6 +1526,10 @@ int main(int argc, char **argv)
> > >          } else
> > >              ret = probe_file(wctx, input_filename);
> > >  
> > > +        if (ret < 0)
> > > +            show_error(wctx, ret);
> > > +
> > 
> > do_show_error isn't used anymore?
> 
> Up.
> -- 
> FFmpeg = Faithless & Furious Moronic Pitiful Extroverse Gangster

> From b4b1274de7ed17bdc1b3be8360f3ac19ccb43315 Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefasab at gmail.com>
> Date: Fri, 6 Jan 2012 18:45:08 +0100
> Subject: [PATCH] ffprobe: print error in main() rather than in probe_file()
> 
> Also move header and trailer print from probe_file() to main().
> 
> This allows to show error information even if it was not possible to open
> the file.
> ---
>  ffprobe.c |   10 ++++++----
>  1 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/ffprobe.c b/ffprobe.c
> index 08dc2a4..2746630 100644
> --- a/ffprobe.c
> +++ b/ffprobe.c
> @@ -1397,17 +1397,13 @@ static int probe_file(WriterContext *wctx, const char *filename)
>      AVFormatContext *fmt_ctx;
>      int ret;
>  
> -    writer_print_header(wctx);
>      ret = open_input_file(&fmt_ctx, filename);
>      if (ret >= 0) {
>          PRINT_CHAPTER(packets);
>          PRINT_CHAPTER(streams);
>          PRINT_CHAPTER(format);
>          avformat_close_input(&fmt_ctx);
> -    } else if (do_show_error) {
> -        show_error(wctx, ret);
>      }
> -    writer_print_footer(wctx);
>  
>      return ret;
>  }
> @@ -1520,6 +1516,8 @@ int main(int argc, char **argv)
>      }
>  
>      if ((ret = writer_open(&wctx, w, w_args, NULL)) >= 0) {
> +        writer_print_header(wctx);
> +
>          if (!input_filename) {
>              show_usage();
>              av_log(NULL, AV_LOG_ERROR, "You have to specify one input file.\n");
> @@ -1528,6 +1526,10 @@ int main(int argc, char **argv)
>          } else
>              ret = probe_file(wctx, input_filename);
>  
> +        if (ret < 0 && do_show_error)
> +            show_error(wctx, ret);
> +
> +        writer_print_footer(wctx);

On the other hand I'm not so sure this is a good idea, possibly
-show_error should be used *only* for reporting probing file errors
(rather than - inconsistently - syntax errors), so this may be changed
to:

       else {
           ret = probe_file(wctx, input_filename);
           if (ret < 0 && do_show_error)
               show_error(wctx, ret);
       }

-- 
FFmpeg = Furious and Friendly Magic Problematic Excellent Geek


More information about the ffmpeg-devel mailing list