fix retiming issue for auto subtitles

This commit is contained in:
simon 2022-03-11 17:47:04 +07:00
parent d3e9646fb6
commit aff0cfb794
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4

View File

@ -178,6 +178,14 @@ class SubtitleParser:
if not text.strip(): if not text.strip():
continue 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}]}) event.update({"segs": [{"utf8": text}]})
flatten.append(event) flatten.append(event)