# HG changeset patch # User michael # Date 1264959798 0 # Node ID f50eb231b06a2b39a46ad27e343fab3fe3ed8b03 # Parent 9a624037cf06f9e6325d7087ff60c0c7a9c906ac Increase search range if no end timestamp could be found for the duration calculation. diff -r 9a624037cf06 -r f50eb231b06a utils.c --- a/utils.c Sun Jan 31 16:21:49 2010 +0000 +++ b/utils.c Sun Jan 31 17:43:18 2010 +0000 @@ -1771,6 +1771,7 @@ } #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 @@ 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 @@ /* 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<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 @@ } av_free_packet(pkt); } + }while( end_time==AV_NOPTS_VALUE + && filesize > (DURATION_MAX_READ_SIZE<