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
| import cv2
url = "rtsp://admin:qwer1234!.@192.168.1.65:554"
cap = cv2.VideoCapture(url) width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
fourcc = cv2.VideoWriter_fourcc(*"mp4v") out = cv2.VideoWriter('test.mp4', fourcc, 20, (width, height))
while True: ret, frame = cap.read() if ret: out.write(frame) cv2.imshow('capture', frame) if cv2.waitKey(25) & 0xFF == ord('q'): break else: continue cap.release() out.release() cv2.destroyAllWindows()
|