MoviePy将帧显示为跨视频的图块

MoviePy shows frames as tiles across video

I have this weird bug with moviePy. I'm creating a video using VideoClip where frames are defined using numpy arrays.

For the example, I'm using a single frame that looks like this (when printed with matplotlib)

plt.imshow(frame)
plt.show()

enter image description here

When I create a video using only this frame, it looks like this:

def get_frame(t):
    return frame

animation = VideoClip(get_frame, duration=3)
animation.ipython_display(fps=3, codec='mpeg4')

enter image description here

Why does moviepy repeat the frame instead of stretching it?

I've tried playing with the video size etc, but nothing changed.


Here's the whole code:

from moviepy.editor import VideoClip
import numpy as np

frame = np.zeros([400, 400])
frame[10:40,50:80] = 100

plt.imshow(frame)
plt.show()

def get_frame(t):
    return frame

animation = VideoClip(get_frame, duration=3)
animation.ipython_display(fps=3, codec='mpeg4')

I've found the problem: The numpy array should be 3D and what I had was 1D. Fixing this solved it.