Commit 729de963f9 for ffmpeg
commit 729de963f9063efb6d6cb04e8a29dccc809155b3
Author: Kacper Michajłow <kasper93@gmail.com>
Date: Sat Oct 17 01:37:54 2026 +0200
avformat/hls: keep the subtitle cues still shown at the seek target
Discard the cues of a subtitle playlist by their end time when seeking
or when the playlist is enabled during playback, so a cue that is on
screen at the target is delivered instead of the next one starting after
it.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
diff --git a/libavformat/hls.c b/libavformat/hls.c
index 8cc3511e5a..4c50cc65d1 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -3106,6 +3106,13 @@ retry:
pls->seek_timestamp = AV_NOPTS_VALUE;
break;
}
+ /* a cue still shown at the target is delivered, the cues
+ * after it may still have ended before the target */
+ if (pls->is_subtitle && pls->pkt->duration > 0 &&
+ av_rescale_q_rnd(pls->pkt->dts + pls->pkt->duration, tb,
+ AV_TIME_BASE_Q, AV_ROUND_DOWN) >
+ pls->seek_timestamp)
+ break;
}
av_packet_unref(pls->pkt);
}
diff --git a/tests/ref/fate/hls-webvtt-seek-demux b/tests/ref/fate/hls-webvtt-seek-demux
index b2742c8c66..5de0423fa5 100644
--- a/tests/ref/fate/hls-webvtt-seek-demux
+++ b/tests/ref/fate/hls-webvtt-seek-demux
@@ -1,4 +1,10 @@
WEBVTT
+00:11.000 --> 00:14.500 line:1
+long
+
+00:11.000 --> 00:14.500 line:1
+long
+
00:14.500 --> 00:15.500
third