diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 08fe0aa7a0..7d9512b664 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -2501,7 +2501,7 @@ static int hls_init(AVFormatContext *s) /* Get one video stream to reference for split segments * so use the first video stream index. */ if ((vs->has_video == 1) && (vs->streams[j]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)) { - vs->reference_stream_index = j; + vs->reference_stream_index = vs->streams[j]->index; } vs->has_subtitle += vs->streams[j]->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE; }