[FFmpeg-devel] [PATCH] ffprobe: add print_section option to the compact writer

Stefano Sabatini stefasab at gmail.com
Mon Sep 10 13:40:45 CEST 2012


Allow to skip section name at the begin of each line. Possibly simplify
output.
---
 doc/ffprobe.texi |    4 ++++
 ffprobe.c        |    6 +++++-
 2 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/doc/ffprobe.texi b/doc/ffprobe.texi
index cb794aa..70a8860 100644
--- a/doc/ffprobe.texi
+++ b/doc/ffprobe.texi
@@ -303,6 +303,10 @@ containing a newline ('\n'), a carriage return ('\r'), a double quote
 Perform no escaping.
 @end table
 
+ at item print_section, s
+Print the section name at the begin of each line. Default value is
+ at code{1}, if set to @code{0} disable it.
+
 @end table
 
 @section csv
diff --git a/ffprobe.c b/ffprobe.c
index a46f3f0..8576599 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -623,6 +623,7 @@ typedef struct CompactContext {
     char *item_sep_str;
     char item_sep;
     int nokey;
+    int print_section;
     char *escape_mode_str;
     const char * (*escape_str)(AVBPrint *dst, const char *src, const char sep, void *log_ctx);
 } CompactContext;
@@ -637,6 +638,8 @@ static const AVOption compact_options[]= {
     {"nk",       "force no key printing", OFFSET(nokey),           AV_OPT_TYPE_INT,    {.i64=0},    0,        1        },
     {"escape",   "set escape mode",       OFFSET(escape_mode_str), AV_OPT_TYPE_STRING, {.str="c"},  CHAR_MIN, CHAR_MAX },
     {"e",        "set escape mode",       OFFSET(escape_mode_str), AV_OPT_TYPE_STRING, {.str="c"},  CHAR_MIN, CHAR_MAX },
+    {"print_section", "print section name", OFFSET(print_section), AV_OPT_TYPE_INT,    {.i64=1},    0,        1        },
+    {"s",             "print section name", OFFSET(print_section), AV_OPT_TYPE_INT,    {.i64=1},    0,        1        },
     {NULL},
 };
 
@@ -683,7 +686,8 @@ static void compact_print_section_header(WriterContext *wctx, const char *sectio
 {
     CompactContext *compact = wctx->priv;
 
-    printf("%s%c", section, compact->item_sep);
+    if (compact->print_section)
+        printf("%s%c", section, compact->item_sep);
 }
 
 static void compact_print_section_footer(WriterContext *wctx, const char *section)
-- 
1.7.5.4



More information about the ffmpeg-devel mailing list