diff --git a/render.py b/render.py index 4af4449..d603f04 100644 --- a/render.py +++ b/render.py @@ -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):