I'm trying to read a video as an image array using moviepy so that I can edit the data and save it back to a video file, but I'm running into an issue when saving a video file from an array of images data.
Here is my code:
from moviepy.editor import *
# read video
path = "path/to/video.mp4"
clip = VideoFileClip(path)
# get video as an array of images:
nframes = clip.reader.nframes
frames = []
for i in range(nframes):
frames.append(clip.get_frame(i))
fps = clip.fps
# save video
save_path = "save/path/video.mp4"
clip = ImageSequenceClip(frames, fps=fps)
clip.write_videofile(save_path, fps=fps)
This produces a video file at the save path containing all the video frames, but it plays ridiculously fast, like the fps is much higher than the actual fps. Calling for the fps value with print(fps) returns 30.
What is going wrong here? Thank you in advance you all your kind help!