I’m trying to access an RTSP camera in Python and get frame information from it.
One of the camera options is RTSP authentication, and when I include it, VLC asks for login information. (‘[rtsp @ ] method DESCRIBE failed: 401 Unauthorized’)
If I turn it off, I can access it regardless of ID or PW, but if I turn it on, I can’t access it from Python.
I verified that it works by putting the same RTSP address, ID, and PW in VLC, and it doesn’t contain any symbols like ‘@’ which is a common problem.
I used several libraries, including Opencv, ffmpeg, and others, and got the same
‘[rtsp @ ] method DESCRIBE failed: 401 Unauthorized’ and only this error appears
What could be the cause,,, please help…
import cv2
url = "rtsp://username:password@camera_ip:554/stream_path"
cap = cv2.VideoCapture(url)
if not cap.isOpened():
print("Failed to open RTSP stream.")
exit()
while True:
ret, frame = cap.read()
if not ret:
print("Failed to read frame.")
break
cv2.imshow('RTSP Stream', frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
I tried running the above code and debugging it using the ffmpeg library.
9