[FFmpeg-cvslog] estimate_timings_from_pts: Try to get the duration for all streams
Gaullier Nicolas
git at videolan.org
Fri May 16 16:59:09 CEST 2014
ffmpeg | branch: master | Gaullier Nicolas <nicolas.gaullier at arkena.com> | Wed May 14 16:25:13 2014 +0000| [68cea1bc8eb194b682eb1dcef04a97d6dfc4ca0d] | committer: Michael Niedermayer
estimate_timings_from_pts: Try to get the duration for all streams
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=68cea1bc8eb194b682eb1dcef04a97d6dfc4ca0d
---
libavformat/utils.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 4248c8c..604408f 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -2469,7 +2469,7 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
AVPacket pkt1, *pkt = &pkt1;
AVStream *st;
int read_size, i, ret;
- int64_t end_time;
+ int all_duration_valid = 0;
int64_t filesize, offset, duration;
int retry = 0;
@@ -2493,7 +2493,6 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
/* estimate the end time (duration) */
/* XXX: may need to support wrapping */
filesize = ic->pb ? avio_size(ic->pb) : 0;
- end_time = AV_NOPTS_VALUE;
do {
offset = filesize - (DURATION_MAX_READ_SIZE << retry);
if (offset < 0)
@@ -2515,7 +2514,7 @@ 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)) {
- duration = end_time = pkt->pts + pkt->duration;
+ duration = pkt->pts + pkt->duration;
if (st->start_time != AV_NOPTS_VALUE)
duration -= st->start_time;
else
@@ -2529,7 +2528,19 @@ static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
}
av_free_packet(pkt);
}
- } while (end_time == AV_NOPTS_VALUE &&
+
+ /* check if all audio/video streams have valid duration */
+ all_duration_valid = 1;
+ for (i = 0; i < ic->nb_streams; i++) {
+ st = ic->streams[i];
+ switch (st->codec->codec_type) {
+ case AVMEDIA_TYPE_VIDEO:
+ case AVMEDIA_TYPE_AUDIO:
+ if (st->duration == AV_NOPTS_VALUE)
+ all_duration_valid = 0;
+ }
+ }
+ } while (!all_duration_valid &&
offset &&
++retry <= DURATION_MAX_RETRY);
More information about the ffmpeg-cvslog
mailing list