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

Stefano Sabatini stefasab at gmail.com
Fri Jan 6 19:14:13 CET 2012


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
@@ -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)
+            show_error(wctx, ret);
+
+        writer_print_footer(wctx);
         writer_close(&wctx);
     }
 
-- 
1.7.5.4



More information about the ffmpeg-devel mailing list