[FFmpeg-devel] [PATCH] ffprobe: add show_entries option
Stefano Sabatini
stefasab at gmail.com
Mon Sep 10 14:53:22 CEST 2012
On date Sunday 2012-09-09 15:10:40 +0200, Stefano Sabatini encoded:
[...]
> From 1f9ce45fdbc0bd77898b5926274c3c40368c296a Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefasab at gmail.com>
> Date: Sat, 8 Sep 2012 17:50:06 +0200
> Subject: [PATCH] ffprobe: add show_entries option
>
> Generalize show_format_entry option.
> ---
> doc/ffprobe.texi | 35 +++++++++++++++
> ffprobe.c | 128 ++++++++++++++++++++++++++++++++++++++++++++++-------
> 2 files changed, 146 insertions(+), 17 deletions(-)
>
> diff --git a/doc/ffprobe.texi b/doc/ffprobe.texi
> index cbe48a7..cb794aa 100644
> --- a/doc/ffprobe.texi
> +++ b/doc/ffprobe.texi
> @@ -118,6 +118,41 @@ 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_ENTRIES_SEP} ::= "="|"/"
> + at var{GENERIC_ENTRIES} ::= @var{ENTRY}[, at var{GENERIC_ENTRIES}]
> + at var{SECTION_ENTRIES} ::= @var{SECTION}[@var{SECTION_ENTRIES_SEP}[@var{GENERIC_ENTRIES}]]
> + at var{ENTRIES} ::= @var{SECTION_ENTRIES}[:@var{ENTRIES}]
> + at end example
> +
> + at var{SECTION} specifies the name of the section where an entry
> +has to be found, @var{ENTRY} the name of the entry in that specific
> +section.
> +
> +If @var{SECTION} is specified but is followed by no
> + at var{SECTION_ENTRIES_SEP}, all entries are printed to
> +output. Otherwise only the entries specified in @var{GENERIC_ENTRIES}
> +are printed.
> +
> +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
> +the argument:
> + at example
> +"packet=pts_time,duration_time,stream_index : stream=index,codec_type"
> + at end example
> +
> +To show all the entries in the section "format", but only the codec
> +type in the section "stream", specify the argument:
> + at example
> +"format : stream=codec_type"
> + at end example
> +
> @item -show_packets
> Show information about each packet contained in the input multimedia
> stream.
> diff --git a/ffprobe.c b/ffprobe.c
> index fdff907..6c63486 100644
> --- a/ffprobe.c
> +++ b/ffprobe.c
> @@ -51,13 +51,31 @@ static int do_read_packets = 0;
> static int do_show_error = 0;
> static int do_show_format = 0;
> static int do_show_frames = 0;
> -static AVDictionary *fmt_entries_to_show = NULL;
> static int do_show_packets = 0;
> static int do_show_streams = 0;
> static int do_show_data = 0;
> static int do_show_program_version = 0;
> static int do_show_library_versions = 0;
>
> +struct section_map_entry {
> + const char *section; ///< section name
> + int show_all_entries; ///< show all section entries
> + AVDictionary *entries_to_show; ///< section entries to show
> + int *do_show_section_ptr; ///< pointer to the int which enables section printing
> +};
> +
> +static struct section_map_entry section_map_entries[] = {
> + { "data", 0, NULL, &do_show_data },
> + { "error", 0, NULL, &do_show_error },
> + { "format", 0, NULL, &do_show_format },
> + { "frame", 0, NULL, &do_show_frames },
> + { "library_version", 0, NULL, &do_show_library_versions },
> + { "packet", 0, NULL, &do_show_packets },
> + { "program_version", 0, NULL, &do_show_program_version },
> + { "stream", 0, NULL, &do_show_streams },
> + { NULL },
> +};
[...]
Just noticed that this can't work with the usual -show_* options,
since they will need to set show_all_entries to 1, so I'll need to set
them in the opt_show_* callbacks (which also need to be defined).
Also we may want to deprecate them in favor or -show_entries.
As for what regards streams, I wonder if we should somehow support
stream specifiers, at least for what concerns options which affect a
particular stream (-show_packet, -show_streams).
A possible idea:
-select_streams v:0,a:1
or
-select_stream v:0 -select_stream a:0
or alternatively we could extend -show_entries:
-show_entries frame:v:1=pts
which should be feasible assuming that sections cannot contain the ":"
character (but this really belongs to a different change/patch).
Another possible problem: if "/" is acceptable in a section name, then
I can't use it like a section/entries separator.
Comments are welcome.
--
FFmpeg = Funny Fabulous Mysterious Pure Entertaining Ghost
More information about the ffmpeg-devel
mailing list