Capture and Save IP Camera in Python OpenCV

import cv2

#print("Before URL")
cap = cv2.VideoCapture('rtsp://[email protected]:554/cam/realmonitor?channel=1&subtype=1')
#print("After URL")

(grabbed, frame) = cap.read()
fshape = frame.shape
fheight = fshape[0]
fwidth = fshape[1]
fourcc = cv2.VideoWriter_fourcc(*'XVID')
out = cv2.VideoWriter('output.avi',fourcc, 20.0, (fwidth,fheight))

while True:

    #print('About to start the Read command')
    ret, frame = cap.read()
    #print('About to show frame of Video.')
    cv2.imshow("Capturing",frame)
    #print('Running..')

    out.write(frame)

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()

References
https://pupli.net/2021/01/access-ip-camera-in-python-opencv/
https://stackoverflow.com/questions/29317262/opencv-video-saving-in-python

Access IP Camera in Python OpenCV

import cv2

#print("Before URL")
cap = cv2.VideoCapture('rtsp://admin:[email protected]/H264?ch=1&subtype=0')
#print("After URL")

while True:

    #print('About to start the Read command')
    ret, frame = cap.read()
    #print('About to show frame of Video.')
    cv2.imshow("Capturing",frame)
    #print('Running..')

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()

References
https://stackoverflow.com/questions/49978705/access-ip-camera-in-python-opencv
https://dahuawiki.com/Remote_Access/RTSP_via_VLC