aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtem Smorodin <artem.smorodin@dacast.com>2025-07-26 19:09:54 +0300
committerMichael Niedermayer <michael@niedermayer.cc>2025-07-28 17:27:51 +0200
commit0a108a37e15732ee61ee1f4be18553865f10bde4 (patch)
treeecbda022b5333715ad212cb3b92d156892ff981e
parent4b6f6af384a76b8ca1cbb4fdde734ffaf111a934 (diff)
downloadffmpeg-0a108a37e15732ee61ee1f4be18553865f10bde4.tar.gz
avformat/hlsenc: limit segments count to search duplicated segments filenames
This linear search has a complexity of O(n). When ffmpeg attempts to parse a playlist containing approximately 100,000 segments, it effectively causes a hang for several minutes. This patch limits the allowed size for duplicate searches to a reasonable value. Now it takes between 0.5 and a few seconds (tested on different devices) instead of several minutes. Signed-off-by: Artem Smorodin <artem.smorodin@dacast.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/hlsenc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index a93d35ab75..d3db83093c 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1172,7 +1172,7 @@ static int hls_append_segment(struct AVFormatContext *s, HLSContext *hls,
if (hls->use_localtime_mkdir) {
filename = vs->avf->url;
}
- if ((find_segment_by_filename(vs->segments, filename) || find_segment_by_filename(vs->old_segments, filename))
+ if (vs->nb_entries <= 5000 && (find_segment_by_filename(vs->segments, filename) || find_segment_by_filename(vs->old_segments, filename))
&& !byterange_mode) {
av_log(hls, AV_LOG_WARNING, "Duplicated segment filename detected: %s\n", filename);
}