[FFmpeg-devel] [PATCH] ffprobe: add show_entries option

Stefano Sabatini stefasab at gmail.com
Sun Sep 9 13:37:48 CEST 2012


On date Sunday 2012-09-09 12:06:36 +0200, Clément Bœsch encoded:
> On Sat, Sep 08, 2012 at 05:51:37PM +0200, Stefano Sabatini wrote:
> > Generalize show_format_entry option.
> > ---
> >  doc/ffprobe.texi |   21 +++++++++
> >  ffprobe.c        |  129 ++++++++++++++++++++++++++++++++++++++++++++++-------
> >  2 files changed, 133 insertions(+), 17 deletions(-)
> > 
> > diff --git a/doc/ffprobe.texi b/doc/ffprobe.texi
> > index cbe48a7..4b693d7 100644
> > --- a/doc/ffprobe.texi
> > +++ b/doc/ffprobe.texi
> > @@ -118,6 +118,27 @@ Like @option{-show_format}, but only prints the specified entry of the
> >  container format information, rather than all. This option may be given more
> >  than once, then all specified entries will be shown.
> >  
> > +This option is deprecated, use @code{show_entries} instead.
> > +
> > + at item -show_entries @var{entry_list}
> > +Set list of entries to show.
> > +
> > +Entries are specified according to the following syntax:
> > + at example
> > + at var{SECTION}  ::= @var{SECTION_NAME} "=" | "/" @var{ENTRY}[, at var{ENTRY}]
> > + at var{SECTIONS} ::= @var{SECTION}[:@var{SECTIONS}]
> > + at end example
> > +
> > + at var{SECTION_NAME} specifies the name of the section where an entry has
> > +to be found, and @var{ENTRY} the name of the entry in that specific
> > +section.
> > +
> > +For example, to show only the index and type of each stream, and
> > +packet PTS time, duration time, and stream index, you can specify:
> 
> Maybe easier to parse for a human mind that way?:
> 
>     For example, to show only the index and type of each stream, and the
>     PTS time, duration time, and stream index of the packets, you can
>     specify:

Changed:

[...]
> > -static int opt_show_format_entry(void *optctx, const char *opt, const char *arg)
> > +static int opt_show_entries(void *optctx, const char *opt, const char *arg)
> >  {
> > -    do_show_format = 1;
> > -    av_dict_set(&fmt_entries_to_show, arg, "", 0);
> > +    struct section_dictionary_map_entry *e;
> > +    const char *p = arg;
> > +
> > +    while (*p) {
> > +        char *section = av_get_token(&p, "/=");
> > +
> > +        if (!section) {
> > +            av_log(NULL, AV_LOG_ERROR,
> 
> > +                   "Missing section to specify for option '%s'\n",
> > +                   opt);
> 
> nit: you could merge those two lines

Done.

[...]
> > +static int opt_show_format_entry(void *optctx, const char *opt, const char *arg)
> > +{
> > +    AVBPrint buf;
> > +    int ret;
> > +
> > +    av_log(NULL, AV_LOG_WARNING,
> > +           "Option '%s' is deprecated, use '-show_entries format=%s' instead.\n",
> > +           opt, arg);
> > +    av_bprint_init(&buf, 0, AV_BPRINT_SIZE_AUTOMATIC);
> > +    av_bprintf(&buf, "format=%s", arg);
> > +
> > +    ret = opt_show_entries(optctx, opt, buf.str);
> > +    av_bprint_finalize(&buf, NULL);
> 
> Might be simpler to rely on av_asprintf() like we did in some ffmpeg
> options.

True, changed.

[...] 
> Looks OK but I didn't test it. Nice feature.
> 
> Note: wouldn't FATE needs some update to avoid the deprecated message?

Yes I'll do in a subsequent commit, to test that the deprecated
option still work as expected.

Updated with other minor fixes.
-- 
FFmpeg = Funny Furious Marvellous Picky Enigmatic Gadget
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0006-ffprobe-add-show_entries-option.patch
Type: text/x-diff
Size: 11261 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120909/e9d5b4f4/attachment.bin>


More information about the ffmpeg-devel mailing list