diff mbox series

[FFmpeg-devel,v3] ffprobe: Allow unknown format private AVOptions

Message ID 20200701153432.762460-1-derek.buitenhuis@gmail.com
State Accepted
Commit f43a8112ddf0388421dc7a264ee9ae12d2185b17
Headers show
Series [FFmpeg-devel,v3] ffprobe: Allow unknown format private AVOptions | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Derek Buitenhuis July 1, 2020, 3:34 p.m. UTC
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@gmail.com>
---
It now iterates over the missing keys as Marton requested.
---
 fftools/ffprobe.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Marton Balint July 1, 2020, 5:54 p.m. UTC | #1
On Wed, 1 Jul 2020, Derek Buitenhuis wrote:

> 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@gmail.com>
> ---
> It now iterates over the missing keys as Marton requested.

LGTM.

Maybe unknown codec options should also be allowed?

Regards,
Marton

> ---
> fftools/ffprobe.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
> index 5515e1b31b..d4e494f11f 100644
> --- a/fftools/ffprobe.c
> +++ b/fftools/ffprobe.c
> @@ -2854,7 +2854,7 @@ static int open_input_file(InputFile *ifile, const char *filename,
> {
>     int err, i;
>     AVFormatContext *fmt_ctx = NULL;
> -    AVDictionaryEntry *t;
> +    AVDictionaryEntry *t = NULL;
>     int scan_all_pmts_set = 0;
>
>     fmt_ctx = avformat_alloc_context();
> @@ -2879,10 +2879,8 @@ static int open_input_file(InputFile *ifile, const char *filename,
>     ifile->fmt_ctx = fmt_ctx;
>     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;
> -    }
> +    while ((t = av_dict_get(format_opts, "", t, AV_DICT_IGNORE_SUFFIX)))
> +        av_log(NULL, AV_LOG_WARNING, "Option %s skipped - not known to demuxer.\n", t->key);
>
>     if (find_stream_info) {
>         AVDictionary **opts = setup_find_stream_info_opts(fmt_ctx, codec_opts);
> -- 
> 2.27.0.rc2
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 5515e1b31b..d4e494f11f 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2854,7 +2854,7 @@  static int open_input_file(InputFile *ifile, const char *filename,
 {
     int err, i;
     AVFormatContext *fmt_ctx = NULL;
-    AVDictionaryEntry *t;
+    AVDictionaryEntry *t = NULL;
     int scan_all_pmts_set = 0;
 
     fmt_ctx = avformat_alloc_context();
@@ -2879,10 +2879,8 @@  static int open_input_file(InputFile *ifile, const char *filename,
     ifile->fmt_ctx = fmt_ctx;
     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;
-    }
+    while ((t = av_dict_get(format_opts, "", t, AV_DICT_IGNORE_SUFFIX)))
+        av_log(NULL, AV_LOG_WARNING, "Option %s skipped - not known to demuxer.\n", t->key);
 
     if (find_stream_info) {
         AVDictionary **opts = setup_find_stream_info_opts(fmt_ctx, codec_opts);