diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2010-01-31 17:43:18 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2010-01-31 17:43:18 +0000 |
commit | 411ff3225febb9760fc8223584920b2cb9251302 (patch) | |
tree | e53f025212172cc6f3745a09bf9c6ba04a3aabbf | |
parent | 351aff72a4018cd2c133daf44e6052fe15bf5cb4 (diff) | |
download | ffmpeg-411ff3225febb9760fc8223584920b2cb9251302.tar.gz |
Increase search range if no end timestamp could be found for the duration
calculation.
Originally committed as revision 21577 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r-- | libavformat/utils.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 260dc7641c..8295f704ee 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1771,6 +1771,7 @@ static void av_estimate_timings_from_bit_rate(AVFormatContext *ic) } #define DURATION_MAX_READ_SIZE 250000 +#define DURATION_MAX_RETRY 3 /* only usable for MPEG-PS streams */ static void av_estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset) @@ -1780,6 +1781,7 @@ static void av_estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset int read_size, i, ret; int64_t end_time, start_time[MAX_STREAMS]; int64_t filesize, offset, duration; + int retry=0; ic->cur_st = NULL; @@ -1805,14 +1807,16 @@ static void av_estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset /* estimate the end time (duration) */ /* XXX: may need to support wrapping */ filesize = ic->file_size; - offset = filesize - DURATION_MAX_READ_SIZE; + end_time = AV_NOPTS_VALUE; + do{ + offset = filesize - (DURATION_MAX_READ_SIZE<<retry); if (offset < 0) offset = 0; url_fseek(ic->pb, offset, SEEK_SET); read_size = 0; for(;;) { - if (read_size >= DURATION_MAX_READ_SIZE) + if (read_size >= DURATION_MAX_READ_SIZE<<(FFMAX(retry-1,0))) break; do{ @@ -1836,6 +1840,9 @@ static void av_estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset } av_free_packet(pkt); } + }while( end_time==AV_NOPTS_VALUE + && filesize > (DURATION_MAX_READ_SIZE<<retry) + && ++retry <= DURATION_MAX_RETRY); fill_all_stream_timings(ic); |