Sending OpenCV output to VLC stream

后端 未结 2 757
心在旅途
心在旅途 2020-12-15 08:06

This has been keeping me busy for a good part of the afternoon and I haven\'t been able to get it to work but I feel like I\'m really close.

I\'ve got openCV set up

2条回答
  •  再見小時候
    2020-12-15 08:45

    This worked for me, though I am sending to RTSP stream and not using imutils library:

    import numpy as np
    import sys
    import cv2
    
    input_rtsp = "rtsp://10.10.10.9:8080"
    cap = cv2.VideoCapture(input_rtsp)
    
    while(cap.isOpened()):
        ret, frame = cap.read()
        if ret==True:        
            sys.stdout.write(frame.tostring())
        else:
            break
    
    cap.release()
    

    Then in command line:

    python opencv.py | cvlc --demux=rawvideo --rawvid-fps=25 --rawvid-width=1280 --rawvid-height=720  --rawvid-chroma=RV24 - --sout "#transcode{vcodec=h264,vb=200,fps=25,width=1280,height=720}:rtp{dst=10.10.10.10,port=8081,sdp=rtsp://10.10.10.10:8081/test.sdp}"
    

    Note that you do not need to convert opencv BGR to RGB.

提交回复
热议问题