Cv2.imshow() taking too long

I am trying to get video from an rstps stream and then display it using opencv. However, with the cv2.imshow() method it is taking too long for the window to be created and then launched. Also, even though the strem is working perfectly fine, opencv is not reading and displaying the video in time.
Here’s my code:

import cv2
cap=cv2.VideoCapture('stream link goes here ')
ret,frame=cap.read()
win=cv2.namedWindow('Window')
while ret:
    cv2.imshow(win,frame)

cap.release()
cv2.destroyAllWindows

please read tutorial

https://docs.opencv.org/4.x/dd/d43/tutorial_py_video_display.html