Ticket #7397: mythtv_libav_seek_start_fix1.diff

File mythtv_libav_seek_start_fix1.diff, 1.4 KB (added by tralph11@…, 10 years ago)

update the start time if dts earlier than start time

  • libs/libmythtv/avformatdecoder.cpp

     
    621621        return false;
    622622    }
    623623
    624     // If seeking to start of stream force a DTS and start_time of zero as
    625     // libav sometimes returns the end of the stream instead.
    626     if (desiredFrame <= 1)
    627     {
    628         av_update_cur_dts(ic, st, 0);
    629         ic->start_time = 0;
    630     }
    631 
    632624    int normalframes = 0;
    633625
    634626    if (st->cur_dts != (int64_t)AV_NOPTS_VALUE)
     
    638630
    639631        if (ic->start_time != (int64_t)AV_NOPTS_VALUE)
    640632        {
     633            // If seeking near the start of stream sometimes the current dts time is less than
     634            // the start time (possibly due to the AVSEEK_FLAG_BACKWARD flag ?). If so, adjust
     635            // start time equal to current time.
     636            int64_t cur_time = av_rescale(st->cur_dts,
     637                                    (int64_t)AV_TIME_BASE * (int64_t)st->time_base.num,
     638                                    st->time_base.den);
     639            if (cur_time < ic->start_time)
     640                ic->start_time = cur_time;
     641
    641642            int64_t st1 = av_rescale(ic->start_time,
    642643                                    st->time_base.den,
    643644                                    AV_TIME_BASE * (int64_t)st->time_base.num);