The discard needs to be checked on a stream even after the first packet is read. The first packet has already been read as part of calling avformat_find_stream_info. This means that setting AVStream->discard on a stream after having determined the stream info for the HLS package had no effect and unwanted packets were returned by subsequent calls to hls_read_packet.
Signed-off-by: vectronic <hello.vectro...@gmail.com> --- libavformat/hls.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/hls.c b/libavformat/hls.c index fc45719d1c..0740e9c546 100644 --- a/libavformat/hls.c +++ b/libavformat/hls.c @@ -2014,7 +2014,7 @@ fail: return ret; } -static int recheck_discard_flags(AVFormatContext *s, int first) +static int recheck_discard_flags(AVFormatContext *s) { HLSContext *c = s->priv_data; int i, changed = 0; @@ -2041,7 +2041,7 @@ static int recheck_discard_flags(AVFormatContext *s, int first) pls->seek_stream_index = -1; } av_log(s, AV_LOG_INFO, "Now receiving playlist %d, segment %d\n", i, pls->cur_seq_no); - } else if (first && !cur_needed && pls->needed) { + } else if (!cur_needed && pls->needed) { ff_format_io_close(pls->parent, &pls->input); pls->input_read_done = 0; ff_format_io_close(pls->parent, &pls->input_next); @@ -2101,7 +2101,7 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt) HLSContext *c = s->priv_data; int ret, i, minplaylist = -1; - recheck_discard_flags(s, c->first_packet); + recheck_discard_flags(s); c->first_packet = 0; for (i = 0; i < c->n_playlists; i++) { -- 2.24.2 (Apple Git-127) _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".