[FFmpeg-cvslog] avformat_find_stream_info: use fps_dts as last resort to determine duration

Michael Niedermayer git at videolan.org
Sun Jul 7 16:25:24 CEST 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Jul  7 15:03:12 2013 +0200| [c7cfd4cce98a858c08e880ac7075737c78f98be8] | committer: Michael Niedermayer

avformat_find_stream_info: use fps_dts as last resort to determine duration

Fixes long delay with some hardware generated h264 in ts

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c7cfd4cce98a858c08e880ac7075737c78f98be8
---

 libavformat/utils.c |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 6acc7c8..c6aa87b 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2829,6 +2829,15 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
             if (st->avg_frame_rate.num > 0)
                 t = FFMAX(t, av_rescale_q(st->codec_info_nb_frames, av_inv_q(st->avg_frame_rate), AV_TIME_BASE_Q));
 
+            if (   t==0
+                && st->codec_info_nb_frames>15
+                && st->codec->codec_type == AVMEDIA_TYPE_VIDEO
+                && (   !strcmp(ic->iformat->name, "mpeg") // this breaks some flvs thus use only for mpegps/ts for now (for ts we have a sample that needs it)
+                    || !strcmp(ic->iformat->name, "mpegts"))
+                && st->info->fps_first_dts != AV_NOPTS_VALUE
+                && 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 >= ic->max_analyze_duration) {
                 av_log(ic, AV_LOG_VERBOSE, "max_analyze_duration %d reached at %"PRId64" microseconds\n", ic->max_analyze_duration, t);
                 break;



More information about the ffmpeg-cvslog mailing list