cv2.VideoCapture pull rtsp stream timeout problem

In python, when using cv2 to pull the rtsp video stream, if the rtsp stream is abnormal, either cv2.VideoCapture() or VideoCapture().read() may be blocked for a long time (many people say the default timeout is 30s), and cannot be found. At the place where the timeout setting is set, I tried to use thread processing, but the actual use is more troublesome, and the solution is found in stackoverflow.

os.environ["OPENCV_FFMPEG_CAPTURE_OPTIONS"] = "timeout;5000"
cap=cv2.VideoCapture(self.__rtsp_url,cv2.CAP_FFMPEG)

Guess you like

Origin blog.csdn.net/GoProLin/article/details/128255529