summaryrefslogtreecommitdiff
path: root/fftools
diff options
context:
space:
mode:
authorGyan Doshi <ffmpeg@gyani.pro>2021-05-01 17:37:34 +0530
committerGyan Doshi <ffmpeg@gyani.pro>2021-05-05 15:04:54 +0530
commit7c451b609c267462de152895634902f14c3ea60a (patch)
tree976c59a64e88d619684e44ed48f3ae0c4dafa38a /fftools
parentd055af5e7ba96b7d2c72a2ff0d7b7d614c2b46a7 (diff)
ffprobe: add option to control optional fields display
Diffstat (limited to 'fftools')
-rw-r--r--fftools/ffprobe.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 7b28f6b3ce..b07032bd88 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -117,6 +117,11 @@ static int use_byte_value_binary_prefix = 0;
static int use_value_sexagesimal_format = 0;
static int show_private_data = 1;
+#define SHOW_OPTIONAL_FIELDS_AUTO -1
+#define SHOW_OPTIONAL_FIELDS_NEVER 0
+#define SHOW_OPTIONAL_FIELDS_ALWAYS 1
+static int show_optional_fields = SHOW_OPTIONAL_FIELDS_AUTO;
+
static char *print_format;
static char *stream_specifier;
static char *show_data_hash;
@@ -745,8 +750,10 @@ static inline int writer_print_string(WriterContext *wctx,
const struct section *section = wctx->section[wctx->level];
int ret = 0;
- if ((flags & PRINT_STRING_OPT)
- && !(wctx->writer->flags & WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS))
+ if (show_optional_fields == SHOW_OPTIONAL_FIELDS_NEVER ||
+ (show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO
+ && (flags & PRINT_STRING_OPT)
+ && !(wctx->writer->flags & WRITER_FLAG_DISPLAY_OPTIONAL_FIELDS)))
return 0;
if (section->show_all_entries || av_dict_get(section->entries_to_show, key, NULL, 0)) {
@@ -3244,6 +3251,17 @@ static void ffprobe_show_pixel_formats(WriterContext *w)
writer_print_section_footer(w);
}
+static int opt_show_optional_fields(void *optctx, const char *opt, const char *arg)
+{
+ if (!av_strcasecmp(arg, "always")) show_optional_fields = SHOW_OPTIONAL_FIELDS_ALWAYS;
+ else if (!av_strcasecmp(arg, "never")) show_optional_fields = SHOW_OPTIONAL_FIELDS_NEVER;
+ else if (!av_strcasecmp(arg, "auto")) show_optional_fields = SHOW_OPTIONAL_FIELDS_AUTO;
+
+ if (show_optional_fields == SHOW_OPTIONAL_FIELDS_AUTO && av_strcasecmp(arg, "auto"))
+ show_optional_fields = parse_number_or_die("show_optional_fields", arg, OPT_INT, SHOW_OPTIONAL_FIELDS_AUTO, SHOW_OPTIONAL_FIELDS_ALWAYS);
+ return 0;
+}
+
static int opt_format(void *optctx, const char *opt, const char *arg)
{
iformat = av_find_input_format(arg);
@@ -3631,6 +3649,7 @@ static const OptionDef real_options[] = {
{ "show_library_versions", 0, { .func_arg = &opt_show_library_versions }, "show library versions" },
{ "show_versions", 0, { .func_arg = &opt_show_versions }, "show program and library versions" },
{ "show_pixel_formats", 0, { .func_arg = &opt_show_pixel_formats }, "show pixel format descriptions" },
+ { "show_optional_fields", HAS_ARG, { .func_arg = &opt_show_optional_fields }, "show optional fields" },
{ "show_private_data", OPT_BOOL, { &show_private_data }, "show private data" },
{ "private", OPT_BOOL, { &show_private_data }, "same as show_private_data" },
{ "bitexact", OPT_BOOL, {&do_bitexact}, "force bitexact output" },