[FFmpeg-devel] obseve PTS overflow when seeking

Rainer Hochecker fernetmenta at xboxmediacenter.com
Sat Aug 18 11:12:19 CEST 2012


Hi,

I have tracked down a problem where seeking did not work because PTS 
overflow in mpegts file. The following would fix it but I am not sure 
whether it's entirely correct. Could you have a look at this?

Cheers,
Rainer

diff --git a/lib/ffmpeg/libavformat/utils.c b/lib/ffmpeg/libavformat/utils.c
index a28bcbb..63f89dd 100644
--- a/lib/ffmpeg/libavformat/utils.c
+++ b/lib/ffmpeg/libavformat/utils.c
@@ -1711,20 +1711,11 @@ int64_t ff_gen_search(AVFormatContext *s, int 
stream_index, int64_t target_ts,
          if (ts_max == AV_NOPTS_VALUE)
              return -1;

-        if ((s->streams[stream_index]->start_time != AV_NOPTS_VALUE) &&
-            (ts_max < s->streams[stream_index]->start_time)) {
-              ts_max += 1LL<<(s->streams[stream_index]->pts_wrap_bits);
-        }
-
          for(;;){
              int64_t tmp_pos= pos_max + 1;
              int64_t tmp_ts= read_timestamp(s, stream_index, &tmp_pos, 
INT64_MAX);
              if(tmp_ts == AV_NOPTS_VALUE)
                  break;
-            if ((s->streams[stream_index]->start_time != AV_NOPTS_VALUE) &&
-                (tmp_ts < s->streams[stream_index]->start_time)) {
-                  tmp_ts += 1LL<<(s->streams[stream_index]->pts_wrap_bits);
-            }
              ts_max= tmp_ts;
              pos_max= tmp_pos;
              if(tmp_pos >= filesize)
@@ -1781,11 +1772,6 @@ int64_t ff_gen_search(AVFormatContext *s, int 
stream_index, int64_t target_ts,
              av_log(s, AV_LOG_ERROR, "read_timestamp() failed in the 
middle\n");
              return -1;
          }
-        if ((s->streams[stream_index]->start_time != AV_NOPTS_VALUE) &&
-            (ts < s->streams[stream_index]->start_time)) {
-              ts += 1LL<<(s->streams[stream_index]->pts_wrap_bits);
-        }
-
          assert(ts != AV_NOPTS_VALUE);
          if (target_ts <= ts) {
              pos_limit = start_pos - 1;


More information about the ffmpeg-devel mailing list