[FFmpeg-devel] [PATCH v2, 2/2] avformat/hls: fix start time seek error

wm4 nfxjfg at googlemail.com
Wed Jan 3 10:40:15 EET 2018


On Tue,  2 Jan 2018 22:44:47 -0500
mymoeyard at gmail.com wrote:

> From: Wu Zhiqiang <mymoeyard at gmail.com>
> 
> Calculate first_timestamp based on first packet timestamp.
> Some m3u8 have streams that second one has smaller timestamp
> in first packet of this stream.
> Start/seek from start time may fail due to EIO error.
> It should be based on start_time of AvFormatContext.
> 
> Signed-off-by: Wu Zhiqiang <mymoeyard at gmail.com>
> ---
>  libavformat/hls.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/libavformat/hls.c b/libavformat/hls.c
> index 069e7b06e9..125f68ca4e 100644
> --- a/libavformat/hls.c
> +++ b/libavformat/hls.c
> @@ -2110,10 +2110,8 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
>                          pkt_ts = AV_NOPTS_VALUE;
>  
>  
> -                    if (c->first_timestamp == AV_NOPTS_VALUE &&
> -                        pkt_ts       != AV_NOPTS_VALUE)
> -                        c->first_timestamp = av_rescale_q(pkt_ts,
> -                            get_timebase(pls), AV_TIME_BASE_Q);
> +                    c->first_timestamp = s->start_time != AV_NOPTS_VALUE ? s->start_time : 0;
> +
>                  }
>  
>                  if (pls->seek_timestamp == AV_NOPTS_VALUE)

Not sure if I agree with this. AFAIK start_time is set by
avformat_find_stream_info(), so calling that would be required. But
that call also adds a lot of startup latency.


More information about the ffmpeg-devel mailing list