Skip to content

Instantly share code, notes, and snippets.

@akmamun
Created September 4, 2019 06:50
Show Gist options
  • Select an option

  • Save akmamun/c5fb7e7e104f907d36ff71637f91f083 to your computer and use it in GitHub Desktop.

Select an option

Save akmamun/c5fb7e7e104f907d36ff71637f91f083 to your computer and use it in GitHub Desktop.
Video Recording
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