[FFmpeg-devel] [PATCH] ffprobe: Add option to allow unknown format private AVOptions

Derek Buitenhuis derek.buitenhuis at gmail.com
Fri Jun 26 16:15:00 EEST 2020


This useful, because by ffprobe's very nature, you use it to probe
a file and find out what it is. Requiring every format private option
to be known to the demuxer forces one to run ffprobe twice, if one
wants to use ffprobe in a generic way.

For example, say one wants to probe all user-uploaded files, while
also ignoring edit lists for any MP4s that are uploaded. Currently,
you'd have to run ffprobe twice: once to identify the format, and
once again to actually probe the metadata you want. After this
patch, you could set -ignore_editlist 1 on every call and only
probe once.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>
---
 fftools/ffprobe.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 5515e1b31b..cf66e5b0a2 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -115,6 +115,7 @@ static int use_value_prefix             = 0;
 static int use_byte_value_binary_prefix = 0;
 static int use_value_sexagesimal_format = 0;
 static int show_private_data            = 1;
+static int allow_unknown_format_opts    = 0;
 
 static char *print_format;
 static char *stream_specifier;
@@ -2880,8 +2881,12 @@ static int open_input_file(InputFile *ifile, const char *filename,
     if (scan_all_pmts_set)
         av_dict_set(&format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
     if ((t = av_dict_get(format_opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
-        av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key);
-        return AVERROR_OPTION_NOT_FOUND;
+        if (allow_unknown_format_opts) {
+            av_log(NULL, AV_LOG_WARNING, "Option %s skipped - not known to demuxer.\n", t->key);
+        } else {
+            av_log(NULL, AV_LOG_ERROR, "Option %s not found.\n", t->key);
+            return AVERROR_OPTION_NOT_FOUND;
+        }
     }
 
     if (find_stream_info) {
@@ -3573,6 +3578,8 @@ static const OptionDef real_options[] = {
     { "print_filename", HAS_ARG, {.func_arg = opt_print_filename}, "override the printed input filename", "print_file"},
     { "find_stream_info", OPT_BOOL | OPT_INPUT | OPT_EXPERT, { &find_stream_info },
         "read and decode the streams to fill missing information with heuristics" },
+    { "allow_unknown_format_opts", OPT_BOOL, { &allow_unknown_format_opts },
+        "allow unknown format options to be set without failing" },
     { NULL, },
 };
 
-- 
2.27.0.rc2



More information about the ffmpeg-devel mailing list