import cv2 # make sure you have open-cv installed
# credit to http://www.learningaboutelectronics.com
# slightly edited by WoefulDeveloper (me)
cap = cv2.VideoCapture(1)
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
video_speed = 50 # higher number means faster frame rate
video_name = "Video.mp4"
writer = cv2.VideoWriter(video_name,cv2.VideoWriter_fourcc(*'DIVX'), video_speed, (width,height))
while True:
ret,frame = cap.read()
writer.write(frame)
cv2.imshow('frame', frame) # not necessary you can comment this out
if cv2.waitKey(1) & 0xFF == 27: # waits for the "esc" key to stop the video
break
cap.release()
writer.release()
cv2.destroyAllWindows()