fix(subtitle): rebase live-clock dash webvtt cues by presentationTimeOffset

Live-to-VOD replays carry cue times on the live media clock, which overflowed the SRT conversion and dropped every cue.
This commit is contained in:
imSp4rky
2026-10-25 13:15:34 -06:00
parent cb2ffdb55a
commit 2dc458f8b4
3 changed files with 43 additions and 3 deletions
+9 -1
View File
@@ -27,7 +27,7 @@ from unshackle.core.config import config
from unshackle.core.tracks.track import Track
from unshackle.core.utilities import try_ensure_utf8, with_script
from unshackle.core.utils.subprocess import log_tool_run
from unshackle.core.utils.webvtt import merge_segmented_webvtt
from unshackle.core.utils.webvtt import merge_segmented_webvtt, rebase_webvtt
# silence srt library INFO logging
logging.getLogger("srt").setLevel(logging.ERROR)
@@ -280,6 +280,14 @@ class Subtitle(Track):
text = self.path.read_text("utf8")
text = Subtitle.strip_webvtt_timestamp_map(text)
if self.descriptor == Track.Descriptor.DASH:
from unshackle.core.manifests import DASH
template = DASH.merge_segment_templates(
self.data["dash"]["adaptation_set"], self.data["dash"]["representation"]
)
if template is not None:
offset = template.get("presentationTimeOffset", "0")
text = rebase_webvtt(text, int(offset) * 1000 // int(template.get("timescale", "1")))
if len(self.data["dash"]["segment_durations"]) > 1:
text = merge_segmented_webvtt(
text,