5

I am trying to read rtsp live stream using python opencv. I am getting the following errors:

[rtsp @ 000001f610c828a0] method SETUP failed: 461 Client error
 
warning: Error opening file (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:856)
warning: rtsp://192.168.1.18:8554/cam (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:857)

This is the code that I have tried:

cap = cv2.VideoCapture("rtsp://192.168.1.18:8554/cam",cv2.CAP_FFMPEG)
if cap.isOpened():
    cv2.namedWindow("demo", cv2.WINDOW_AUTOSIZE)
    while True:
            ret_val, img = cap.read();
            cv2.imshow('demo',img)
            cv2.waitKey(10)
else:
    print("camera open failed")

cv2.destroyAllWindows()

I am using python 3.5 and opencv 3.4.2

Dev Bhuyan
  • 541
  • 5
  • 19

1 Answers1

1

Try this one:

import os
os.environ["OPENCV_FFMPEG_CAPTURE_OPTIONS"] = "rtsp_transport;udp"

It may be caused by the network protocol difference: The client defaults to TCP but the server uses UDP.

LW001
  • 2,452
  • 6
  • 27
  • 36
Ei Shuu
  • 11
  • 1