Irpan
init commit
7fa2fcb
raw
history blame
531 Bytes
import cv2
def read_video(video_path):
cap = cv2.VideoCapture(video_path)
frames = []
while True:
ret, frame = cap.read()
if not ret:
break
frames.append(frame)
return frames
def save_video(ouput_video_frames,output_video_path):
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter(output_video_path, fourcc, 24, (ouput_video_frames[0].shape[1], ouput_video_frames[0].shape[0]))
for frame in ouput_video_frames:
out.write(frame)
out.release()