[FFmpeg-devel] [PATCH] ffprobe: implement -show_sections

Stefano Sabatini stefasab at gmail.com
Tue Nov 20 00:21:16 CET 2012


TODO: add Changelog entry for the new option
---
 doc/ffprobe.texi |    4 ++++
 ffprobe.c        |   31 +++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/doc/ffprobe.texi b/doc/ffprobe.texi
index 39322cd..127a80f 100644
--- a/doc/ffprobe.texi
+++ b/doc/ffprobe.texi
@@ -222,6 +222,10 @@ Show information related to library versions.
 Version information for each library is printed within a section with
 name "LIBRARY_VERSION".
 
+ at item show_sections
+Show sections structure and section information, and exit. The output
+is not meant to be parsed by a machine.
+
 @item -show_versions
 Show information related to program and library versions. This is the
 equivalent of setting both @option{-show_program_version} and
diff --git a/ffprobe.c b/ffprobe.c
index 5c3a47c..1777246 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -2098,6 +2098,36 @@ static int opt_pretty(void *optctx, const char *opt, const char *arg)
     return 0;
 }
 
+static void show_section(SectionID id, int level)
+{
+    const SectionID *pid;
+    const struct section *section = &sections[id];
+    printf("%c%c%c",
+           section->flags & SECTION_FLAG_IS_WRAPPER           ? 'W' : '.',
+           section->flags & SECTION_FLAG_IS_ARRAY             ? 'A' : '.',
+           section->flags & SECTION_FLAG_HAS_VARIABLE_FIELDS  ? 'V' : '.');
+    printf("%*c", level * 4, ' ');
+    printf("  %s", section->name);
+    if (section->unique_name)
+        printf("/%s", section->unique_name);
+    printf("\n");
+
+    for (pid = section->children_ids; *pid != -1; pid++)
+        show_section(*pid, level+1);
+}
+
+static int opt_show_sections(void *optctx, const char *opt, const char *arg)
+{
+    printf("Sections:\n"
+           "W.. = Section is a wrapper (contains other sections, no local entries)\n"
+           ".A. = Section contains an array of elements of the same type\n"
+           "..V = Section may contain a variable number of fields with variable keys\n"
+           "FLAGS NAME/UNIQUE_NAME\n"
+           "---\n");
+    show_section(SECTION_ID_ROOT, 0);
+    return 0;
+}
+
 static int opt_show_versions(const char *opt, const char *arg)
 {
     mark_section_show_entries(SECTION_ID_PROGRAM_VERSION, 1, NULL);
@@ -2144,6 +2174,7 @@ static const OptionDef real_options[] = {
     { "show_entries", HAS_ARG, {.func_arg = opt_show_entries},
       "show a set of specified entries", "entry_list" },
     { "show_packets", 0, {(void*)&opt_show_packets}, "show packets info" },
+    { "show_sections", OPT_EXIT, {.func_arg = opt_show_sections}, "show sections structure and section information, and exit" },
     { "show_streams", 0, {(void*)&opt_show_streams}, "show streams info" },
     { "count_frames", OPT_BOOL, {(void*)&do_count_frames}, "count the number of frames per stream" },
     { "count_packets", OPT_BOOL, {(void*)&do_count_packets}, "count the number of packets per stream" },
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list