From 3c5273ba5da478433ce576a13cac843e87cae2ff Mon Sep 17 00:00:00 2001 From: j Date: Sat, 28 Oct 2023 20:26:33 +0200 Subject: [PATCH] make sure full voice over fits --- render.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/render.py b/render.py index 9bc19cd..4af4449 100644 --- a/render.py +++ b/render.py @@ -81,12 +81,13 @@ def compose(clips, target=150, base=1024, voice_over=None): vo_min = sum([vo['duration'] for vo in voice_overs]) if vo_min > target: target = vo_min - if vo_min < target: + elif vo_min < target: offset = (target - vo_min) / 2 scene['audio']['A3'].append({ 'blank': True, 'duration': offset }) + vo_min += offset for vo in voice_overs: scene['audio']['A3'].append(vo) @@ -105,7 +106,8 @@ def compose(clips, target=150, base=1024, voice_over=None): clips = [c for c in all_clips if c != clip] if not clips: clips = all_clips.copy() - if length + clip['duration'] > target: + print(clip['duration'], clip['original'], target, length, len(clips)) + if length + clip['duration'] > target and length >= vo_min: break length += clip['duration']