From aff0cfb794c09d900a18782e332de35787ae04b5 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 11 Mar 2022 17:47:04 +0700 Subject: [PATCH] fix retiming issue for auto subtitles --- tubearchivist/home/src/index/video.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tubearchivist/home/src/index/video.py b/tubearchivist/home/src/index/video.py index a840ea8..9968cc7 100644 --- a/tubearchivist/home/src/index/video.py +++ b/tubearchivist/home/src/index/video.py @@ -178,6 +178,14 @@ class SubtitleParser: if not text.strip(): continue + if flatten: + # fix overlapping retiming issue + last_end = flatten[-1]["tStartMs"] + flatten[-1]["dDurationMs"] + if event["tStartMs"] < last_end: + joined = flatten[-1]["segs"][0]["utf8"] + "\n" + text + flatten[-1]["segs"][0]["utf8"] = joined + continue + event.update({"segs": [{"utf8": text}]}) flatten.append(event)