I have an RTSP URL for streaming from a CCTV camera, but I get the following error:
[ WARN:0@30.061] global cap_ffmpeg_impl.hpp:453 _opencv_ffmpeg_interrupt_callback Stream timeout triggered after 30046.359055 ms
When I test the same URL in VLC by opening the network stream, the live feed works perfectly.
What could be causing this issue, and how can I fix it?
Can you share your code, are you entering in a username and password or using any form of authorization when streaming with VLC?
I directly pass the username & password in RTSP url both VLC & Opencv also
Ex : rtsp://xxx:yyyy@x.x.x.x:yyyy/1/profile3/media.smp
My code :
def multiple_camera(camera_event):
main_instance = Main(camera_event=camera_event)
try:
cap = cv2.VideoCapture(camera_event[“uri”])
if not cap.isOpened():
LOGGER.error(“Cannot open camera”)
sys.exit()
LOGGER.info(f"{camera_event[‘device_name’]} Camera is online now with FPS of {cap.get(cv2.CAP_PROP_FPS)}")
while True:
FRAME_NUMBER = int(cap.get(cv2.CAP_PROP_POS_FRAMES))
ret, frame = cap.read()
if not ret:
LOGGER.error(f"Can't receive frame (stream end?). trying to reconnect ... {camera_event['uri']}")
cap = cv2.VideoCapture(camera_event["uri"])
continue
if FRAME_NUMBER % 6 == 0:
frame = main_instance.main_operation(
image=frame, current_frame_number=FRAME_NUMBER
)
# cv2.imwrite('base_test.png',frame)
cv2.namedWindow("Combined Frame", cv2.WINDOW_NORMAL)
cv2.imshow("Combined Frame", frame)
if cv2.waitKey(1) == ord("q"):
break
finally:
cv2.destroyAllWindows()
main_instance.disconnect_inference()
LOGGER.info(f"{camera_event['device_name']} Camera is exit now")