from moviepy.editor import ColorClip, concatenate_videoclips
colors = [
(255, 0, 0), # Red
(0, 0, 255), # Blue
(0, 255, 0), # Green
(255, 255, 0) # Yellow
]
clip_duration = 0.5
num_repeats = int(15 / (clip_duration * len(colors)))
size = (720, 1280)
clips = [ColorClip(size=size, color=color, duration=clip_duration) for color in colors] * num_repeats
final_clip = concatenate_videoclips(clips, method="compose")
final_clip.write_videofile("color_swap_15s.mp4", fps=24)