lavf/utils: avoid giving up probing early with long subtitle events
authorRodger Combs <rodger.combs@gmail.com>
Sat, 3 Oct 2015 03:39:24 +0000 (22:39 -0500)
committerMichael Niedermayer <michael@niedermayer.cc>
Sat, 3 Oct 2015 10:10:03 +0000 (12:10 +0200)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/utils.c

index dc83608..689473e 100644 (file)
@@ -3347,7 +3347,10 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
                 break;
             }
             if (pkt->duration) {
-                st->info->codec_info_duration        += pkt->duration;
+                if (st->codec->codec_type == AVMEDIA_TYPE_SUBTITLE && pkt->pts != AV_NOPTS_VALUE && pkt->pts >= st->start_time) {
+                    st->info->codec_info_duration = FFMIN(pkt->pts - st->start_time, st->info->codec_info_duration + pkt->duration);
+                } else
+                    st->info->codec_info_duration += pkt->duration;
                 st->info->codec_info_duration_fields += st->parser && st->need_parsing && st->codec->ticks_per_frame ==2 ? st->parser->repeat_pict + 1 : 2;
             }
         }