skip subtitle segments without duration, take 2

This commit is contained in:
simon 2022-04-18 11:52:13 +07:00
parent d086f63861
commit 3147df20da
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4

View File

@ -195,6 +195,11 @@ class SubtitleParser:
if flatten:
# fix overlapping retiming issue
if "dDurationMs" not in flatten[-1]:
# some events won't have a duration
print(f"failed to parse event without duration: {event}")
continue
last_end = flatten[-1]["tStartMs"] + flatten[-1]["dDurationMs"]
if event["tStartMs"] < last_end:
joined = flatten[-1]["segs"][0]["utf8"] + "\n" + text