'When I receive vlc file streaming using Python's video capture, error occured

opencv version : 3.4.1

ffmpeg version : 3.4.8-0ubuntu0.2

os : ubuntu 18.04

streaming code

vlc -vvv /my/video/path.mp4 --play-and-exit :sout=#rtp{sdp=rtsp://127.0.0.1:8554/} :sout-keep

python code(receiver)

frame_buffer = None
def receiver(stream_uri):
    global frame_buffer
    while True:
        rtsp = cv2.VideoCapture(stream_uri, cv2.CAP_FFMPEG)
        if rtsp.isOpened():
            while True:
                connect, frame = rtsp.read()
                if not connect:
                    break
                frame_buffer = frame

def consumer():
    global frame_buffer
    while True:
        frame = frame_buffer

def main():
    os.environ["OPENCV_FFMPEG_CAPTURE_OPTIONS"] = "rtsp_transport;udp"

    receiver_thread = threading.Thread(target=receiver, args=(stream_uri,))
    consumer_thread = threading.Thread(target=consumer)

    receiver_thread.start()
    consumer_thread.start()

    receiver_thread.join()
    consumer_thread.join()

if __name__ == '__main__':
    main()
    

console log(error)

enter image description here

I've tried many things, but I keep getting errors.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source