[FFmpeg-devel] [PATCH] ffprobe: add csv writer
Stefano Sabatini
stefasab at gmail.com
Wed Nov 16 18:44:55 CET 2011
On date Wednesday 2011-11-16 07:35:53 +0100, Clément Bœsch encoded:
> On Wed, Nov 16, 2011 at 12:44:09AM +0100, Stefano Sabatini wrote:
> > ---
> > doc/ffprobe.texi | 6 ++++++
> > ffprobe.c | 25 ++++++++++++++++++++++++-
> > 2 files changed, 30 insertions(+), 1 deletions(-)
> >
> > diff --git a/doc/ffprobe.texi b/doc/ffprobe.texi
> > index 172e35d..cd68304 100644
> > --- a/doc/ffprobe.texi
> > +++ b/doc/ffprobe.texi
> > @@ -199,6 +199,12 @@ Perform no escaping.
> >
> > @end table
> >
> > + at section csv
> > +CSV format.
> > +
> > +This format is equivalent to
> > + at code{compact=nokey=1:item_sep=,:escape=csv"}.
> ^
> copy pasta trailing quote?
> > +
> > @section json
> > JSON based format.
> >
> > diff --git a/ffprobe.c b/ffprobe.c
> > index 3aeb271..382c142 100644
> > --- a/ffprobe.c
> > +++ b/ffprobe.c
> > @@ -685,6 +685,27 @@ static Writer compact_writer = {
> > .flags = WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS
> > };
> >
> > +/* CSV output */
> > +
> > +static av_cold int csv_init(WriterContext *wctx, const char *args, void *opaque)
> > +{
> > + return compact_init(wctx, "s=,:nk=1:escape=csv", opaque);
> > +}
> > +
> > +static Writer csv_writer = {
> > + .name = "csv",
> > + .priv_size = sizeof(CompactContext),
> > +
> > + .init = csv_init,
> > + .uninit = compact_uninit,
> > + .print_section_header = compact_print_section_header,
> > + .print_section_footer = compact_print_section_footer,
> > + .print_integer = compact_print_int,
> > + .print_string = compact_print_str,
> > + .show_tags = compact_show_tags,
> > + .flags = WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS
> > +};
> > +
>
> Note: I think those writers should be made constant to differentiate them
> with the context structs (that's not blocking for this patch obviously).
Yes, patch is welcome, or feel free to commit the change yourself.
> > /* JSON output */
> >
> > typedef struct {
> > @@ -854,6 +875,7 @@ static void writer_register_all(void)
> >
> > writer_register(&default_writer);
> > writer_register(&compact_writer);
> > + writer_register(&csv_writer);
> > writer_register(&json_writer);
> > }
> >
> > @@ -1200,7 +1222,8 @@ static const OptionDef options[] = {
> > "use sexagesimal format HOURS:MM:SS.MICROSECONDS for time units" },
> > { "pretty", 0, {(void*)&opt_pretty},
> > "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, json)", "format" },
> > + { "print_format", OPT_STRING | HAS_ARG, {(void*)&print_format},
> > + "set the output printing format (available formats are: default, compact, csv, json)", "format" },
>
> Maybe also add it to the Changelog (maybe by refactoring the JSON entry,
> no need for a new entry).
Done in a slightly different way, and pushed.
--
FFmpeg = Fundamentalist Friendly Multimedia Philosophical Ecumenical Game
More information about the ffmpeg-devel
mailing list