RTSPS stream is not updating in real time

I am trying to classify if a door is open or closed on a live camera feed. the camera feed is an RTSP stream. However, the RTSP stream is not updating in real time(it is stuck to where it first opens up when I start the program).
Here’s my code:

import cv2
cap=cv2.VideoCapture('stream link is here ')
live=window=cv2.namedWindow('live')
while  cap.isOpened()==True:
    ret,frame=cap.read()
    while ret:
        cv2.imshow(live,frame)
        key=cv2.waitKey(4)
        if key==27:
            break
cap.release()
cv2.destroyAllWindows

Also, I am using an ethernet connection so there’s surely no chance of any network speed issues.

beginner error :


if ret:

May be this would be helpful OpenCV: Getting Started with Videos

1 Like