Created
September 4, 2019 06:50
-
-
Save akmamun/c5fb7e7e104f907d36ff71637f91f083 to your computer and use it in GitHub Desktop.
Video Recording
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import cv2 | |
| url = "rtsp camera url" | |
| cap = cv2.VideoCapture(url) | |
| fourcc = cv2.VideoWriter_fourcc(*'vp80') | |
| fps = cap.get(cv2.CAP_PROP_FPS) | |
| width, height = int(cap.get(3)), int(cap.get(4)) | |
| print(fps,width, height) | |
| counter = 0 | |
| out = cv2.VideoWriter("test.webm", fourcc, fps, (width, height)) | |
| while True: | |
| read, image = cap.read() | |
| counter += 1 | |
| print(counter) | |
| if read: | |
| k = cv2.waitKey(1) | |
| if cv2.waitKey(32) == ord(' '): | |
| out.release() | |
| cap.release() | |
| break | |
| out.write(image) | |
| else: | |
| cap = cv2.VideoCapture(url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment