lbw_drs_app_new / utils.py
dschandra's picture
Update utils.py
698479c verified
raw
history blame
552 Bytes
import cv2
def save_video(frames, output_path, fps=30):
if not frames:
return
height, width = frames[0].shape[:2]
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
out = cv2.VideoWriter(output_path, fourcc, fps, (width, height))
for frame in frames:
out.write(frame)
out.release()
def extract_frames(video_path):
cap = cv2.VideoCapture(video_path)
frames = []
while True:
ret, frame = cap.read()
if not ret:
break
frames.append(frame)
cap.release()
return frames