write_videofile() produces an index error when I try to download a video with a loop
Author: LuccaMasoCreated Jan 13, 2026Updated Jul 14, 2026
Labelsbugvideo
I have a 15 seconds video and I want to use moviepy to loop it until it reaches 198 seconds. However I'm given the error "IndexError: index 0 is out of bounds for axis 0 with size 0". This is the current code:
from moviepy import *
clip = VideoFileClip("path_to_the_clip.mp4")
duration_loop = vfx.Loop(duration=198)
clip_with_loop = duration_loop.apply(clip)
clip_with_loop.write_videofile("final.mp4")Expected Behavior
The code should produce a clip repeting my video until it reached 198 seconds.
Actual Behavior
When I try to use "write_videofile" it produces an index error.
I tried this code with different durations and it works perfectly until 64. After that, any duration longer produces this error.
Specifications
- Python Version: 3.13.9
- MoviePy Version: 2.2.1
- Platform Name: Windows 11 Pro
- Platform Version: 25H2
Source: Zulko/moviepy