]> git.sesse.net Git - ffmpeg/blobdiff - ffprobe.c
lavu/opt: add AV_OPT_VIDEO_RATE option
[ffmpeg] / ffprobe.c
index 940e979848b77cb9690901b8872ec23e80ab42f4..4d2d3e1e47a9a219aed1a99b65f0d5c80c1522e8 100644 (file)
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -300,7 +300,7 @@ static int writer_open(WriterContext **wctx, const Writer *writer, const char *a
 {
     int i, ret = 0;
 
-    if (!(*wctx = av_malloc(sizeof(WriterContext)))) {
+    if (!(*wctx = av_mallocz(sizeof(WriterContext)))) {
         ret = AVERROR(ENOMEM);
         goto fail;
     }
@@ -1500,7 +1500,6 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream,
         print_int("interlaced_frame",       frame->interlaced_frame);
         print_int("top_field_first",        frame->top_field_first);
         print_int("repeat_pict",            frame->repeat_pict);
-        print_int("reference",              frame->reference);
         break;
 
     case AVMEDIA_TYPE_AUDIO:
@@ -1793,9 +1792,10 @@ static void show_error(WriterContext *w, int err)
 
 static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename)
 {
-    int err, i;
+    int err, i, orig_nb_streams;
     AVFormatContext *fmt_ctx = NULL;
     AVDictionaryEntry *t;
+    AVDictionary **opts;
 
     if ((err = avformat_open_input(&fmt_ctx, filename,
                                    iformat, &format_opts)) < 0) {
@@ -1807,12 +1807,17 @@ static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename)
         return AVERROR_OPTION_NOT_FOUND;
     }
 
-
     /* fill the streams in the format context */
-    if ((err = avformat_find_stream_info(fmt_ctx, NULL)) < 0) {
+    opts = setup_find_stream_info_opts(fmt_ctx, codec_opts);
+    orig_nb_streams = fmt_ctx->nb_streams;
+
+    if ((err = avformat_find_stream_info(fmt_ctx, opts)) < 0) {
         print_error(filename, err);
         return err;
     }
+    for (i = 0; i < orig_nb_streams; i++)
+        av_dict_free(&opts[i]);
+    av_freep(&opts);
 
     av_dump_format(fmt_ctx, 0, filename, 0);
 
@@ -1829,9 +1834,18 @@ static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename)
             av_log(NULL, AV_LOG_ERROR,
                     "Unsupported codec with id %d for input stream %d\n",
                     stream->codec->codec_id, stream->index);
-        } else if (avcodec_open2(stream->codec, codec, NULL) < 0) {
-            av_log(NULL, AV_LOG_ERROR, "Error while opening codec for input stream %d\n",
-                   stream->index);
+        } else {
+            AVDictionary *opts = filter_codec_opts(codec_opts, stream->codec->codec_id,
+                                                   fmt_ctx, stream, codec);
+            if (avcodec_open2(stream->codec, codec, &opts) < 0) {
+                av_log(NULL, AV_LOG_ERROR, "Error while opening codec for input stream %d\n",
+                       stream->index);
+            }
+            if ((t = av_dict_get(opts, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
+                av_log(NULL, AV_LOG_ERROR, "Option %s for input stream %d not found\n",
+                       t->key, stream->index);
+                return AVERROR_OPTION_NOT_FOUND;
+            }
         }
     }