I'm trying to connect to an IP Camera (Dahua) using OpenCV and Python using an RTSP URI. I added a sample code below (with the username, password and ip provided in separate variables), which results in [rtsp @ 0x55cc3715c600] method OPTIONS failed: 401 Unauthorized
. Using VLC, I'm able to connect, however only after entering the password in a separate dialog even though the password was already provided in the URI.
How should I continue?
address = f'rtsp://{username}:{password}@{ip}'
cap = cv2.VideoCapture(address)
cv2.VideoCapture()
. I'm also using a Dahua camera but the RTSP link will vary from camera to camera. Here's an example of minertsp://username:[email protected]/axis-media/media.amp
. If the link works in VLC it should work in OpenCVvc = cv2.VideoCapture(' rtspsrc location=rtsp://user:[email protected]:8554/play1.sdp ! decodebin ! videoconvert ! appsink ')
You should be able to test that this pipeline works outside of opencv with gst-launch as follows:gst-launch-1.0 rtspsrc location=rtsp://user:[email protected]:8554/play1.sdp ! decodebin ! videoconvert ! autovideosink
rtsp://username:[email protected]
Is the format I use, however, it leads to the prompt in VLC, where I have to enter the password again. Perhaps it has something to do with special characters in the password name:%
?gst-launch-1.0
command also results in anUnauthorized (401)
error.