@@ -527,13 +527,30 @@ int avformat_open_input(AVFormatContext **ps, const char *filename, AVInputForma
if (fmt)
s->iformat = fmt;
- if (options)
+ if (options) {
+ static const char* early_set_options[] = {
+ "probesize", NULL
+ };
+ const char** ptr;
av_dict_copy(&tmp, *options, 0);
+ /* Set these options before calling init_input. We only set
+ * the options actually used by init_input, setting the rest
+ * of the options later after we've initialized them with
+ * demuxer specific defaults. */
+ for (ptr = early_set_options; *ptr; ptr++) {
+ AVDictionaryEntry* entry = av_dict_get(tmp, *ptr, NULL, 0);
+ if (entry) {
+ int ret = av_opt_set(s, entry->key, entry->value, 0);
+ if (ret == 0)
+ av_dict_set(&tmp, *ptr, NULL, 0);
+ }
+ }
+ }
- if ((ret = av_opt_set_dict(s, &tmp)) < 0)
+ if ((ret = init_input(s, filename, &tmp)) < 0)
goto fail;
- if ((ret = init_input(s, filename, &tmp)) < 0)
+ if ((ret = av_opt_set_dict(s, &tmp)) < 0)
goto fail;
/* check filename in case an image number is expected */