From 52f57568d5ed036aca5ee4259c69e7c1476b6d66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 20 Jun 2024 16:33:18 +0300 Subject: [PATCH] hlsenc: Fix setting vs->start_pos when not using HLS_SINGLE_FILE or hls_segment_size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When not using HLS_SINGLE_FILE or hls_segment_size, we're writing each segment into a separate file. In that case, the file start pos for each segment will be zero. This matches the case in (hls->max_seg_size > 0) above, where we decide to switch to a new file. This fixes the calculation of "vs->size = new_start_pos - vs->start_pos" at the start of hls_write_packet; previously, start_pos would refer to the byte size of the previous segment file, giving vs->size entirely bogus values here. Signed-off-by: Martin Storsjö --- libavformat/hlsenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 3d5eb47e84..0c72774e29 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -2659,7 +2659,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt) vs->start_pos = new_start_pos; } } else { - vs->start_pos = new_start_pos; + vs->start_pos = 0; sls_flag_file_rename(hls, vs, old_filename); ret = hls_start(s, vs); }