diff --git a/render.py b/render.py index cdb9719..952f23c 100644 --- a/render.py +++ b/render.py @@ -313,6 +313,7 @@ def render(root, scene, prefix=''): for timeline, data in scene.items(): if timeline == "subtitles": path = os.path.join(root, prefix + "front.srt") + data = fix_overlaps(data) srt = ox.srt.encode(data) write_if_new(path, srt, 'b') continue @@ -560,6 +561,17 @@ def get_srt(sub, offset=0): sdata["out"] += offset return sdata +def fix_overlaps(data): + previous = None + for sub in data: + if previous is None: + previous = sub + else: + if sub['in'] < previous['out']: + previous['out'] = sub['in'] - 0.001 + previous = sub + return data + def update_subtitles(options): import item.models @@ -592,6 +604,7 @@ def update_subtitles(options): print("could not find vo for %s" % clip['src']) offset += clip['duration'] path = folder / "front.srt" + data = fix_overlaps(subs) srt = ox.srt.encode(subs) write_if_new(str(path), srt, 'b')