diff options
author | Gaullier Nicolas <nicolas.gaullier@arkena.com> | 2014-06-19 17:26:31 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-06-19 20:48:46 +0200 |
commit | 650ef180787d9185c98950017e54285d1026eb0b (patch) | |
tree | 41a20c0cffea9ec7f4b7146a6731f8e08b04bf02 | |
parent | 5bf5e6b1c0fd1aa8f27242b603592ec28ed44cf5 (diff) | |
download | ffmpeg-streaming-650ef180787d9185c98950017e54285d1026eb0b.zip ffmpeg-streaming-650ef180787d9185c98950017e54285d1026eb0b.tar.gz |
avformat/utils: better probing for duration in estimate_timings_from_pts()
It seems it is more secure to simply duplicate the computing routine from compute_pkt_fields to estimate_timings_from_pts.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavformat/utils.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 517d919..b25576e 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2477,7 +2477,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) { AVPacket pkt1, *pkt = &pkt1; AVStream *st; - int read_size, i, ret; + int num, den, read_size, i, ret; int found_duration = 0; int is_end; int64_t filesize, offset, duration; @@ -2525,6 +2525,15 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) if (pkt->pts != AV_NOPTS_VALUE && (st->start_time != AV_NOPTS_VALUE || st->first_dts != AV_NOPTS_VALUE)) { + if (pkt->duration == 0) { + ff_compute_frame_duration(&num, &den, st, st->parser, pkt); + if (den && num) { + pkt->duration = av_rescale_rnd(1, + num * (int64_t) st->time_base.den, + den * (int64_t) st->time_base.num, + AV_ROUND_DOWN); + } + } duration = pkt->pts + pkt->duration; found_duration = 1; if (st->start_time != AV_NOPTS_VALUE) |