Reputation: 7622
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()
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')
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')
Upvotes: 2
Views: 397
Reputation: 7622
I've found the problem: The numpy array should be 3D and what I had was 1D. Fixing this solved it.
Upvotes: 1