kadirnar's picture
update
95e4531
raw
history blame
661 Bytes
import numpy as np
import cv2
def write_video(file_path, frames, fps):
"""
Writes frames to an mp4 video file
:param file_path: Path to output video, must end with .mp4
:param frames: List of PIL.Image objects
:param fps: Desired frame rate
"""
w, h = frames[0].size
fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')
writer = cv2.VideoWriter(file_path, fourcc, fps, (w, h))
for frame in frames:
np_frame = np.array(frame.convert('RGB'))
cv_frame = cv2.cvtColor(np_frame, cv2.COLOR_RGB2BGR)
writer.write(cv_frame)
writer.release()
def dummy(images, **kwargs):
return images, False