make sure full voice over fits

This commit is contained in:
j 2023-10-28 20:26:33 +02:00
parent 35767b9105
commit 3c5273ba5d

View file

@ -81,12 +81,13 @@ def compose(clips, target=150, base=1024, voice_over=None):
vo_min = sum([vo['duration'] for vo in voice_overs]) vo_min = sum([vo['duration'] for vo in voice_overs])
if vo_min > target: if vo_min > target:
target = vo_min target = vo_min
if vo_min < target: elif vo_min < target:
offset = (target - vo_min) / 2 offset = (target - vo_min) / 2
scene['audio']['A3'].append({ scene['audio']['A3'].append({
'blank': True, 'blank': True,
'duration': offset 'duration': offset
}) })
vo_min += offset
for vo in voice_overs: for vo in voice_overs:
scene['audio']['A3'].append(vo) 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] clips = [c for c in all_clips if c != clip]
if not clips: if not clips:
clips = all_clips.copy() 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 break
length += clip['duration'] length += clip['duration']