[FFmpeg-cvslog] ffprobe: add support to option -show_error

Stefano Sabatini git at videolan.org
Wed Jan 4 01:09:19 CET 2012


ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Thu Dec 29 13:24:59 2011 +0100| [d6da16dca5a64ed7ab2db54710a0c703f179d3ba] | committer: Stefano Sabatini

ffprobe: add support to option -show_error

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d6da16dca5a64ed7ab2db54710a0c703f179d3ba
---

 Changelog        |    1 +
 doc/ffprobe.texi |    5 +++++
 doc/ffprobe.xsd  |    6 ++++++
 ffprobe.c        |   20 ++++++++++++++++++++
 4 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/Changelog b/Changelog
index 09e44d4..1543562 100644
--- a/Changelog
+++ b/Changelog
@@ -15,6 +15,7 @@ version next:
 - amerge audio filter
 - Automatic thread count based on detection number of (available) CPU cores
 - y41p Brooktree Uncompressed 4:1:1 12-bit encoder and decoder
+- ffprobe -show_error option
 
 
 version 0.9:
diff --git a/doc/ffprobe.texi b/doc/ffprobe.texi
index 736c7f0..002f91e 100644
--- a/doc/ffprobe.texi
+++ b/doc/ffprobe.texi
@@ -94,6 +94,11 @@ For example for printing the output in JSON format, specify:
 For more details on the available output printing formats, see the
 Writers section below.
 
+ at item -show_error
+Show information about the error found when trying to probe the input.
+
+The error information is printed within a section with name "ERROR".
+
 @item -show_format
 Show information about the container format of the input multimedia
 stream.
diff --git a/doc/ffprobe.xsd b/doc/ffprobe.xsd
index 92bc2b1..93da1d4 100644
--- a/doc/ffprobe.xsd
+++ b/doc/ffprobe.xsd
@@ -11,6 +11,7 @@
             <xsd:element name="packets"  type="ffprobe:packetsType" minOccurs="0" maxOccurs="1" />
             <xsd:element name="streams"  type="ffprobe:streamsType" minOccurs="0" maxOccurs="1" />
             <xsd:element name="format"   type="ffprobe:formatType"  minOccurs="0" maxOccurs="1" />
+            <xsd:element name="error"    type="ffprobe:errorType"   minOccurs="0" maxOccurs="1" />
         </xsd:sequence>
     </xsd:complexType>
 
@@ -93,4 +94,9 @@
       <xsd:attribute name="key"   type="xsd:string" use="required"/>
       <xsd:attribute name="value" type="xsd:string" use="required"/>
     </xsd:complexType>
+
+    <xsd:complexType name="errorType">
+      <xsd:attribute name="code"   type="xsd:int"    use="required"/>
+      <xsd:attribute name="string" type="xsd:string" use="required"/>
+    </xsd:complexType>
 </xsd:schema>
diff --git a/ffprobe.c b/ffprobe.c
index 0c1e3d0..ee3c899 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -37,6 +37,7 @@
 const char program_name[] = "ffprobe";
 const int program_birth_year = 2007;
 
+static int do_show_error   = 0;
 static int do_show_format  = 0;
 static int do_show_packets = 0;
 static int do_show_streams = 0;
@@ -1322,6 +1323,22 @@ static void show_format(WriterContext *w, AVFormatContext *fmt_ctx)
     fflush(stdout);
 }
 
+static void show_error(WriterContext *w, int err)
+{
+    char errbuf[128];
+    const char *errbuf_ptr = errbuf;
+
+    if (av_strerror(err, errbuf, sizeof(errbuf)) < 0)
+        errbuf_ptr = strerror(AVUNERROR(err));
+
+    writer_print_chapter_header(w, "error");
+    print_section_header("error");
+    print_int("code", err);
+    print_str("string", errbuf_ptr);
+    print_section_footer("error");
+    writer_print_chapter_footer(w, "error");
+}
+
 static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename)
 {
     int err, i;
@@ -1405,6 +1422,8 @@ static int probe_file(const char *filename)
         PRINT_CHAPTER(streams);
         PRINT_CHAPTER(format);
         avformat_close_input(&fmt_ctx);
+    } else if (do_show_error) {
+        show_error(wctx, ret);
     }
     writer_print_footer(wctx);
     writer_close(&wctx);
@@ -1478,6 +1497,7 @@ static const OptionDef options[] = {
       "prettify the format of displayed values, make it more human readable" },
     { "print_format", OPT_STRING | HAS_ARG, {(void*)&print_format},
       "set the output printing format (available formats are: default, compact, csv, json, xml)", "format" },
+    { "show_error",   OPT_BOOL, {(void*)&do_show_error} ,  "show probing error" },
     { "show_format",  OPT_BOOL, {(void*)&do_show_format} , "show format/container info" },
     { "show_packets", OPT_BOOL, {(void*)&do_show_packets}, "show packets info" },
     { "show_streams", OPT_BOOL, {(void*)&do_show_streams}, "show streams info" },



More information about the ffmpeg-cvslog mailing list