From 4058ac84c12965f5420922cc5ab1915fb758d8af Mon Sep 17 00:00:00 2001 From: j Date: Sat, 28 Oct 2023 11:58:07 +0200 Subject: [PATCH] 50% change try to continue with next clip in sequence --- render.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/render.py b/render.py index a655d1b..aa0c491 100644 --- a/render.py +++ b/render.py @@ -35,6 +35,16 @@ def random_choice(seq, items, pop=False): def chance(seq, chance): return (seq() / 10) >= chance +def get_clip_by_seqid(clips, seqid): + selected = None + for i, clip in enumerate(clips): + if clip['seqid'] == seqid: + selected = i + break + if selected is not None: + return clips.pop(i) + return None + def compose(clips, target=150, base=1024, voice_over=None): length = 0 @@ -80,8 +90,17 @@ def compose(clips, target=150, base=1024, voice_over=None): for vo in voice_overs: scene['audio']['A3'].append(vo) + clip = None while target - length > 0 and clips: - clip = random_choice(seq, clips, True) + # coin flip which site is visible (50% chance) + if clip: + if chance(seq, 0.5): + next_seqid = clip['seqid'] + 1 + clip = get_clip_by_seqid(clips, next_seqid) + else: + clip = None + if not clip: + clip = random_choice(seq, clips, True) if not clips: clips = [c for c in all_clips if c != clip] if not clips: