Browse Source

ffprobe: add print_section option to the compact writer

Allow to skip section name at the begin of each line. Possibly simplify
output.
tags/n1.0
Stefano Sabatini 12 years ago
parent
commit
0c71d5a077
2 changed files with 10 additions and 1 deletions
  1. +5
    -0
      doc/ffprobe.texi
  2. +5
    -1
      ffprobe.c

+ 5
- 0
doc/ffprobe.texi View File

@@ -268,6 +268,11 @@ containing a newline ('\n'), a carriage return ('\r'), a double quote
Perform no escaping. Perform no escaping.
@end table @end table


@item print_section, p
Print the section name at the begin of each line if the value is
@code{1}, disable it with value set to @code{0}. Default value is
@code{1}.

@end table @end table


@section csv @section csv


+ 5
- 1
ffprobe.c View File

@@ -593,6 +593,7 @@ typedef struct CompactContext {
char *item_sep_str; char *item_sep_str;
char item_sep; char item_sep;
int nokey; int nokey;
int print_section;
char *escape_mode_str; char *escape_mode_str;
const char * (*escape_str)(AVBPrint *dst, const char *src, const char sep, void *log_ctx); const char * (*escape_str)(AVBPrint *dst, const char *src, const char sep, void *log_ctx);
} CompactContext; } CompactContext;
@@ -607,6 +608,8 @@ static const AVOption compact_options[]= {
{"nk", "force no key printing", OFFSET(nokey), AV_OPT_TYPE_INT, {.i64=0}, 0, 1 }, {"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 }, {"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 }, {"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 },
{"p", "print section name", OFFSET(print_section), AV_OPT_TYPE_INT, {.i64=1}, 0, 1 },
{NULL}, {NULL},
}; };


@@ -653,7 +656,8 @@ static void compact_print_section_header(WriterContext *wctx, const char *sectio
{ {
CompactContext *compact = wctx->priv; 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) static void compact_print_section_footer(WriterContext *wctx, const char *section)


Loading…
Cancel
Save