반응형
기본이지만, 기록용으로 rtsp 아이디, 비번을 포함해서 읽어오는 방법.
rtsp 주소 안에 아이디, 비번을 안넣으면 "method DESCRIBE failed: 401 Unauthorized" 에러 발생.
[rtsp @ 0000024df57d9540] method DESCRIBE failed: 401 Unauthorized
import cv2
# RTSP stream URL
rtsp_url = "rtsp://admin:1234@192.168.100.83:554/StdCh1" #이부분만 수정
# Create a VideoCapture object
cap = cv2.VideoCapture(rtsp_url)
# Check if the stream is opened successfully
if not cap.isOpened():
print("Error opening stream")
# Read frames from the stream
while True:
ret, frame = cap.read()
# Break the loop if the frame is not read successfully
if not ret:
break
# Display the frame
cv2.imshow("RTSP Stream", frame)
# Break the loop if the 'q' key is pressed
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# Release the VideoCapture object
cap.release()
# Close all OpenCV windows
cv2.destroyAllWindows()
반응형
댓글