cut down clips towards end to fit within limit

This commit is contained in:
j 2023-10-29 16:03:40 +01:00
parent 3c5273ba5d
commit 441ebfa05c

View file

@ -94,6 +94,12 @@ def compose(clips, target=150, base=1024, voice_over=None):
clip = None
while target - length > 0 and clips:
# coin flip which site is visible (50% chance)
if length:
remaining = target - length
remaining = remaining * 1.05 # allow for max of 10% over time
clips = [c for c in clips if c['duration'] <= remaining]
if not clips:
break
if clip:
if chance(seq, 0.5):
next_seqid = clip['seqid'] + 1
@ -106,9 +112,9 @@ 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()
print(clip['duration'], clip['original'], target, length, len(clips))
if length + clip['duration'] > target and length >= vo_min:
break
print('%06.3f %06.3f' % (length, clip['duration']), os.path.basename(clip['original']))
length += clip['duration']
if "foreground" not in clip and "animation" in clip:
@ -201,7 +207,7 @@ def compose(clips, target=150, base=1024, voice_over=None):
'duration': clip['duration'],
'src': foley,
})
print("scene duration %0.3f (target: %0.3f)" % (length, target))
return scene
def get_scene_duration(scene):