Commit 609972d4cc for ffmpeg
commit 609972d4ccab4f2c9a80b70135139c2edc357a91
Author: Kacper Michajłow <kasper93@gmail.com>
Date: Sat Oct 17 01:37:53 2026 +0200
avformat/hls: keep subtitle playlists on the shared timeline
The cue times of a subtitle playlist are on the MPEG-TS timeline, and
the first cue of a segment says nothing about where the segment starts,
so use an offset of 0 instead of deriving one from the first cue, which
made a seek skip the cues within that offset.
Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
diff --git a/libavformat/hls.c b/libavformat/hls.c
index f4d519a093..8cc3511e5a 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -3024,7 +3024,11 @@ retry:
fill_timing_for_id3_timestamped_stream(pls);
}
- if (pls->pkt->dts != AV_NOPTS_VALUE &&
+ if (pls->is_subtitle) {
+ /* the cues are on the shared timeline */
+ if (pls->ts_offset == AV_NOPTS_VALUE)
+ pls->ts_offset = 0;
+ } else if (pls->pkt->dts != AV_NOPTS_VALUE &&
(pls->ts_offset == AV_NOPTS_VALUE ||
(!c->first_timestamp_locked &&
c->first_timestamp_pls == pls &&
@@ -3053,7 +3057,8 @@ retry:
if (delta > 0 && delta <= pls->target_duration) {
c->first_timestamp = ts;
for (int k = 0; k < c->n_playlists; k++)
- if (c->playlists[k]->ts_offset != AV_NOPTS_VALUE)
+ if (c->playlists[k]->ts_offset != AV_NOPTS_VALUE &&
+ !c->playlists[k]->is_subtitle)
c->playlists[k]->ts_offset = av_sat_add64(c->playlists[k]->ts_offset, delta);
adjusted = 1;
}