PR #24773 opened by xiujunwang-dev
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24773
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24773.patch

Fixes #24603

The HLS demuxer did not advance the read pointer after reading an init section.
For large fragmented MP4 init sections, subsequent reads could start at the
wrong offset and fail with errors such as "moov atom not found".

Advance the init section read pointer after the section has been consumed.


>From bdd0aafb5b54f6614d692f42e851743a1e26e238 Mon Sep 17 00:00:00 2001
From: Xiujun Wang <[email protected]>
Date: Tue, 29 Sep 2026 21:15:55 +0800
Subject: [PATCH] avformat/hls: advance the init section read pointer

The init section is read through a fixed-size AVIO buffer. When it
needs more than one read, copying from the start again duplicates the
first chunk and corrupts the data that follows. Copy from the current
read offset instead.

Fixes: #24603
Signed-off-by: Xiujun Wang <[email protected]>
---
 libavformat/hls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index daca226f67..b6a89f3d09 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1848,7 +1848,7 @@ restart:
     if (v->init_sec_buf_read_offset < v->init_sec_data_len) {
         /* Push init section out first before first actual segment */
         int copy_size = FFMIN(v->init_sec_data_len - 
v->init_sec_buf_read_offset, buf_size);
-        memcpy(buf, v->init_sec_buf, copy_size);
+        memcpy(buf, v->init_sec_buf + v->init_sec_buf_read_offset, copy_size);
         v->init_sec_buf_read_offset += copy_size;
         return copy_size;
     }
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to