import cv2 | |
camera = cv2.VideoCapture(0) | |
fps = cv2.CAP_PROP_FPS | |
video = cv2.VideoWriter('video.mp4', cv2.VideoWriter_fourcc(*'mp4v'), 30, (640, 480)) | |
while True: | |
_, frame = camera.read() | |
video.write(frame) | |
cv2.imshow("Frame", frame) | |
c = cv2.waitKey(1) | |
if c == ord('q'): | |
break | |
video.release() | |
camera.release() | |