Нужно использовать библиотеку av:
def get_image_from_stream(stream_url: str) -> np.ndarray:
'''
Get last frame from stream using av modul.
'''
container = None
try:
container = av.open(stream_url) # sadad
except Exception:
# quit
raise Exception("ERROR! Stream not working!")
video_stream = next(s for s in container.streams if s.type == 'video')
image_pil = None
for packet in container.demux(video_stream):
for frame in packet.decode():
image_pil = frame.to_image()
if image_pil:
break
if image_pil:
break
image = np.asarray(image_pil)
return image
stream_url у вас уже есть. А функцию просто запускайте в бесконечном цикле.