Skip to content

Instantly share code, notes, and snippets.

@justinruggles
Created October 21, 2012 22:40
Show Gist options
  • Save justinruggles/3928797 to your computer and use it in GitHub Desktop.
Save justinruggles/3928797 to your computer and use it in GitHub Desktop.
diff --git a/libavformat/utils.c b/libavformat/utils.c
index b992923..87052af 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2483,6 +2483,23 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
count++;
}
+ /* try to open decoders for all streams if not opened already */
+ for (i = 0; i < ic->nb_streams; i++) {
+ st = ic->streams[i];
+ if (!has_codec_parameters(st) &&
+ !avcodec_is_open(st->codec) && !st->info->found_decoder) {
+ pkt1.size = 0;
+ pkt1.data = NULL;
+ av_init_packet(&pkt1);
+ try_decode_frame(st, &pkt1,
+ (options && i < orig_nb_streams) ? &options[i] : NULL);
+ }
+ if (!has_codec_parameters(st)) {
+ av_log(ic, AV_LOG_WARNING,
+ "codec parameters not found for stream %d\n", i);
+ }
+ }
+
// close codecs which were opened in try_decode_frame()
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment