On Tue, Jan 2, 2018 at 3:05 AM Steven Liu <lingjiujia...@gmail.com> wrote:
> 2018-01-02 18:28 GMT+08:00 <mymoey...@gmail.com>: > > From: Wu Zhiqiang <mymoey...@gmail.com> > > > > HLS demuxer seeking use dts instead of pts. > > Demuxer skip some frame when dts is before pts in special case. > > And it is impossible to re-seek back to start time after playing. > > --- > > libavformat/hls.c | 18 ++++++++++++++---- > > 1 file changed, 14 insertions(+), 4 deletions(-) > > > > diff --git a/libavformat/hls.c b/libavformat/hls.c > > index 950cc4c3bd..069e7b06e9 100644 > > --- a/libavformat/hls.c > > +++ b/libavformat/hls.c > > @@ -2086,6 +2086,7 @@ static int hls_read_packet(AVFormatContext *s, > AVPacket *pkt) > > * stream */ > > if (pls->needed && !pls->pkt.data) { > > while (1) { > > + int64_t pkt_ts; > > int64_t ts_diff; > > AVRational tb; > > ret = av_read_frame(pls->ctx, &pls->pkt); > > @@ -2101,9 +2102,17 @@ static int hls_read_packet(AVFormatContext *s, > AVPacket *pkt) > > fill_timing_for_id3_timestamped_stream(pls); > > } > > > > + if (pls->pkt.pts != AV_NOPTS_VALUE) > > + pkt_ts = pls->pkt.pts; > > + else if (pls->pkt.dts != AV_NOPTS_VALUE) > > + pkt_ts = pls->pkt.dts; > > + else > > + pkt_ts = AV_NOPTS_VALUE; > > + > > + > > if (c->first_timestamp == AV_NOPTS_VALUE && > > - pls->pkt.dts != AV_NOPTS_VALUE) > > - c->first_timestamp = av_rescale_q(pls->pkt.dts, > > + pkt_ts != AV_NOPTS_VALUE) > > + c->first_timestamp = av_rescale_q(pkt_ts, > > get_timebase(pls), AV_TIME_BASE_Q); > > } > > > > @@ -2113,15 +2122,16 @@ static int hls_read_packet(AVFormatContext *s, > AVPacket *pkt) > > if (pls->seek_stream_index < 0 || > > pls->seek_stream_index == pls->pkt.stream_index) { > > > > - if (pls->pkt.dts == AV_NOPTS_VALUE) { > > + if (pkt_ts == AV_NOPTS_VALUE) { > > pls->seek_timestamp = AV_NOPTS_VALUE; > > break; > > } > > > > tb = get_timebase(pls); > > - ts_diff = av_rescale_rnd(pls->pkt.dts, AV_TIME_BASE, > > + ts_diff = av_rescale_rnd(pkt_ts, AV_TIME_BASE, > > tb.den, AV_ROUND_DOWN) - > > pls->seek_timestamp; > > + > > if (ts_diff >= 0 && (pls->seek_flags & > AVSEEK_FLAG_ANY || > > pls->pkt.flags & > AV_PKT_FLAG_KEY)) { > > pls->seek_timestamp = AV_NOPTS_VALUE; > > -- > > 2.15.0 > > > > > LGTM , This patch can fix ticket : https://trac.ffmpeg.org/ticket/6850 > LGTM, I've experienced this bug also. > > Thanks > > Steven > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel