Browse Source

deps-libff: set master clock sync type based on default stream

John Bradley 10 years ago
parent
commit
a5e0462a88
1 changed files with 13 additions and 0 deletions
  1. 13 0
      deps/libff/libff/ff-demuxer.c

+ 13 - 0
deps/libff/libff/ff-demuxer.c

@@ -360,6 +360,19 @@ static bool find_and_initialize_stream_decoders(struct ff_demuxer *demuxer)
 			audio_stream = format_context->streams[i];
 			audio_stream = format_context->streams[i];
 	}
 	}
 
 
+	int default_stream_index = av_find_default_stream_index(
+			demuxer->format_context);
+
+	if (default_stream_index >= 0) {
+		AVStream *stream =
+				format_context->streams[default_stream_index];
+
+		if (stream->codec->codec_type == AVMEDIA_TYPE_AUDIO)
+			demuxer->clock.sync_type = AV_SYNC_AUDIO_MASTER;
+		else if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO)
+			demuxer->clock.sync_type = AV_SYNC_VIDEO_MASTER;
+	}
+
 	if (video_stream != NULL)
 	if (video_stream != NULL)
 		find_decoder(demuxer, video_stream);
 		find_decoder(demuxer, video_stream);