Index: libs/libmythtv/avformatdecoder.cpp =================================================================== --- libs/libmythtv/avformatdecoder.cpp (revision 23236) +++ libs/libmythtv/avformatdecoder.cpp (working copy) @@ -692,21 +692,15 @@ long double diff = (max(desiredFrame - frameseekadjust, 0LL)) * AV_TIME_BASE / fps; ts += (long long)diff; + VERBOSE(VB_IMPORTANT, "av_seek_frame -- start"); if (av_seek_frame(ic, -1, ts, AVSEEK_FLAG_BACKWARD) < 0) { VERBOSE(VB_IMPORTANT, LOC_ERR <<"av_seek_frame(ic, -1, "<start_time = 0; - } - int normalframes = 0; if (st->cur_dts != (int64_t)AV_NOPTS_VALUE) @@ -719,8 +713,13 @@ int64_t st1 = av_rescale(ic->start_time, st->time_base.den, AV_TIME_BASE * (int64_t)st->time_base.num); - adj_cur_dts = lsb3full(adj_cur_dts, st1, st->pts_wrap_bits); - + // If seeking near the start of stream sometimes the adjusted current dts time + // is less than the start time (possibly due to the AVSEEK_FLAG_BACKWARD flag ?). + // If so, set adjusted current dts to zero. + if (adj_cur_dts < st1) + adj_cur_dts = 0; + else + adj_cur_dts = lsb3full(adj_cur_dts, st1, st->pts_wrap_bits); } long long newts = av_rescale(adj_cur_dts, @@ -731,6 +730,8 @@ framesPlayed = lastKey; framesRead = lastKey; + VERBOSE(VB_IMPORTANT, LOC + QString("av_seek_frame returned frame %1") + .arg(lastKey)); normalframes = desiredFrame - framesPlayed; normalframes = max(normalframes, 0); no_dts_hack = false;