Browse code

ffprobe: add csv writer

Stefano Sabatini authored on 2011/11/16 08:41:55
Showing 3 changed files
... ...
@@ -121,7 +121,7 @@ easier to use. The changes are:
121 121
 - Discworld II BMV decoding support
122 122
 - VBLE Decoder
123 123
 - OS X Video Decoder Acceleration (VDA) support
124
-- compact output in ffprobe
124
+- compact and csv output in ffprobe
125 125
 
126 126
 
127 127
 version 0.8:
... ...
@@ -199,6 +199,12 @@ Perform no escaping.
199 199
 
200 200
 @end table
201 201
 
202
+@section csv
203
+CSV format.
204
+
205
+This writer is equivalent to
206
+@code{compact=item_sep=,:nokey=1:escape=csv}.
207
+
202 208
 @section json
203 209
 JSON based format.
204 210
 
... ...
@@ -688,6 +688,26 @@ static Writer compact_writer = {
688 688
     .flags = WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS
689 689
 };
690 690
 
691
+/* CSV output */
692
+
693
+static av_cold int csv_init(WriterContext *wctx, const char *args, void *opaque)
694
+{
695
+    return compact_init(wctx, "item_sep=,:nokey=1:escape=csv", opaque);
696
+}
697
+
698
+static Writer csv_writer = {
699
+    .name                 = "csv",
700
+    .priv_size            = sizeof(CompactContext),
701
+    .init                 = csv_init,
702
+    .uninit               = compact_uninit,
703
+    .print_section_header = compact_print_section_header,
704
+    .print_section_footer = compact_print_section_footer,
705
+    .print_integer        = compact_print_int,
706
+    .print_string         = compact_print_str,
707
+    .show_tags            = compact_show_tags,
708
+    .flags = WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS,
709
+};
710
+
691 711
 /* JSON output */
692 712
 
693 713
 typedef struct {
... ...
@@ -857,6 +877,7 @@ static void writer_register_all(void)
857 857
 
858 858
     writer_register(&default_writer);
859 859
     writer_register(&compact_writer);
860
+    writer_register(&csv_writer);
860 861
     writer_register(&json_writer);
861 862
 }
862 863
 
... ...
@@ -1203,7 +1224,8 @@ static const OptionDef options[] = {
1203 1203
       "use sexagesimal format HOURS:MM:SS.MICROSECONDS for time units" },
1204 1204
     { "pretty", 0, {(void*)&opt_pretty},
1205 1205
       "prettify the format of displayed values, make it more human readable" },
1206
-    { "print_format", OPT_STRING | HAS_ARG, {(void*)&print_format}, "set the output printing format (available formats are: default, compact, json)", "format" },
1206
+    { "print_format", OPT_STRING | HAS_ARG, {(void*)&print_format},
1207
+      "set the output printing format (available formats are: default, compact, csv, json)", "format" },
1207 1208
     { "show_format",  OPT_BOOL, {(void*)&do_show_format} , "show format/container info" },
1208 1209
     { "show_packets", OPT_BOOL, {(void*)&do_show_packets}, "show packets info" },
1209 1210
     { "show_streams", OPT_BOOL, {(void*)&do_show_streams}, "show streams info" },