[FFmpeg-devel] [PATCH] ffprobe: add "nokey" option to the default writer

Stefano Sabatini stefasab at gmail.com
Thu May 10 01:48:22 CEST 2012


Help simplifying parsing in certain cases.
---
 doc/ffprobe.texi |    4 ++++
 ffprobe.c        |   14 ++++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/doc/ffprobe.texi b/doc/ffprobe.texi
index 263bbe3..0e8586c 100644
--- a/doc/ffprobe.texi
+++ b/doc/ffprobe.texi
@@ -202,6 +202,10 @@ A description of the accepted options follows.
 
 @table @option
 
+ at item nokey, nk
+If set to 1 specify not to print the key of each field. Its default
+value is 0.
+
 @item print_wrappers, w
 If set to 1 specify to print the section header and footer, if set to
 0 it will not. Default value is 1.
diff --git a/ffprobe.c b/ffprobe.c
index e90d82a..60000b8 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -403,12 +403,15 @@ fail:
 
 typedef struct DefaultContext {
     const AVClass *class;
+    int nokey;
     int print_wrappers;
 } DefaultContext;
 
 #define OFFSET(x) offsetof(DefaultContext, x)
 
 static const AVOption default_options[] = {
+    { "nokey",          "force no key printing",     OFFSET(nokey),          AV_OPT_TYPE_INT, {.dbl=0}, 0, 1 },
+    { "nk",             "force no key printing",     OFFSET(nokey),          AV_OPT_TYPE_INT, {.dbl=0}, 0, 1 },
     { "print_wrappers", "print headers and footers", OFFSET(print_wrappers), AV_OPT_TYPE_INT, {.dbl=1}, 0, 1 },
     { "w",              "print headers and footers", OFFSET(print_wrappers), AV_OPT_TYPE_INT, {.dbl=1}, 0, 1 },
     {NULL},
@@ -490,12 +493,19 @@ static void default_print_section_footer(WriterContext *wctx, const char *sectio
 
 static void default_print_str(WriterContext *wctx, const char *key, const char *value)
 {
-    printf("%s=%s\n", key, value);
+    DefaultContext *def = wctx->priv;
+    if (!def->nokey)
+        printf("%s=", key);
+    printf("%s\n", value);
 }
 
 static void default_print_int(WriterContext *wctx, const char *key, long long int value)
 {
-    printf("%s=%lld\n", key, value);
+    DefaultContext *def = wctx->priv;
+
+    if (!def->nokey)
+        printf("%s=", key);
+    printf("%lld\n", value);
 }
 
 static void default_show_tags(WriterContext *wctx, AVDictionary *dict)
-- 
1.7.5.4



More information about the ffmpeg-devel mailing list