[FFmpeg-devel] [PATCH 2/4] hlsenc: Fix setting vs->start_pos when not using HLS_SINGLE_FILE or hls_segment_size

Martin Storsjö martin at martin.st
Mon Jun 24 11:49:42 EEST 2024


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.
---
 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);
         }
-- 
2.39.3 (Apple Git-146)



More information about the ffmpeg-devel mailing list