Spaces:
Runtime error
Runtime error
import cv2 | |
def check_video_resolution(video_path): | |
vid = cv2.VideoCapture(video_path) | |
height = vid.get(cv2.CAP_PROP_FRAME_HEIGHT) | |
width = vid.get(cv2.CAP_PROP_FRAME_WIDTH) | |
return height,width | |
def read_video(video_path): | |
cap = cv2.VideoCapture(video_path) | |
frames = [] | |
while True: | |
ret, frame = cap.read() | |
if not ret: | |
break | |
frame = cv2.resize(frame,(1280,720)) | |
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() |