1
0
Fork 0

avformat/utils: Search harder for missing stream information in flv by default

Fixes Ticket4133

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2014-12-01 15:26:58 +01:00
parent b50e003e1c
commit 24fdf7334d
1 changed files with 10 additions and 5 deletions

View File

@ -2989,6 +2989,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
int orig_nb_streams = ic->nb_streams;
int flush_codecs;
int64_t max_analyze_duration = ic->max_analyze_duration2;
int64_t max_stream_analyze_duration;
int64_t probesize = ic->probesize2;
if (!max_analyze_duration)
@ -2999,11 +3000,12 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
av_opt_set(ic, "skip_clear", "1", AV_OPT_SEARCH_CHILDREN);
max_stream_analyze_duration = max_analyze_duration;
if (!max_analyze_duration) {
if (!strcmp(ic->iformat->name, "flv") && !(ic->ctx_flags & AVFMTCTX_NOHEADER)) {
max_analyze_duration = 10*AV_TIME_BASE;
} else
max_analyze_duration = 5*AV_TIME_BASE;
max_stream_analyze_duration =
max_analyze_duration = 5*AV_TIME_BASE;
if (!strcmp(ic->iformat->name, "flv"))
max_stream_analyze_duration = 30*AV_TIME_BASE;
}
if (ic->pb)
@ -3076,6 +3078,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
count = 0;
read_size = 0;
for (;;) {
int analyzed_all_streams;
if (ff_check_interrupt(&ic->interrupt_callback)) {
ret = AVERROR_EXIT;
av_log(ic, AV_LOG_DEBUG, "interrupted\n");
@ -3115,7 +3118,9 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
st->codec->codec_type == AVMEDIA_TYPE_AUDIO))
break;
}
analyzed_all_streams = 0;
if (i == ic->nb_streams) {
analyzed_all_streams = 1;
/* NOTE: If the format has no header, then we need to read some
* packets to get most of the streams, so we cannot stop here. */
if (!(ic->ctx_flags & AVFMTCTX_NOHEADER)) {
@ -3223,7 +3228,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
&& st->info->fps_last_dts != AV_NOPTS_VALUE)
t = FFMAX(t, av_rescale_q(st->info->fps_last_dts - st->info->fps_first_dts, st->time_base, AV_TIME_BASE_Q));
if (t >= max_analyze_duration) {
if (t >= (analyzed_all_streams ? max_analyze_duration : max_stream_analyze_duration)) {
av_log(ic, AV_LOG_VERBOSE, "max_analyze_duration %"PRId64" reached at %"PRId64" microseconds\n",
max_analyze_duration,
t);