forked from HarshRangwala/Interview-Problems
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStreamSave.py
37 lines (29 loc) · 844 Bytes
/
StreamSave.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-
"""
Created on Sun Dec 15 16:53:30 2019
@author: Anuj
"""
import cv2
if __name__ == "__main__":
# find the webcam
capture = cv2.VideoCapture(0)
# video recorder
# fourcc = cv2.VideoWriter_fourcc(*'XVID') <<--This is for .avi format
fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')
videoOut = cv2.VideoWriter("output.mp4", fourcc, 10.0, (640, 480))
# record video
while (capture.isOpened()):
ret, frame = capture.read()
if ret:
videoOut.write(frame)
cv2.imshow('Video Stream', frame)
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
else:
break
# Tiny Pause
key = cv2.waitKey(1)
capture.release()
videoOut.release()
cv2.destroyAllWindows()