Spaces:
Runtime error
Runtime error
File size: 661 Bytes
95e4531 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
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
|