I’ve a problem in order to stream a video, using opencv, to a RTSP server.
I’m not interested to the possibility to use gstreamer RTSP server sink, so if you would like to suggest to use it, please avoid.
I have a fully working mediaserver that includes RTSP,RTMP,Websocket and HLS functionalities. I would like to push a H264 stream into it.
Server reference: https://github.com/xiongziliang/ZLMediaKit
What I have (currently working):
... # python stuff rtmpUrl = 'rtmp://127.0.0.1:1935/live/' + str(opt.camera_id) + ' live=1' send_gst = "appsrc ! videoconvert ! video/x-raw,format=BGRx ! nvvidconv ! nvv4l2h264enc bitrate="+ str(config['viewer']['bitrate']) +" ! video/x-h264,stream-format=(string)byte-stream,alignment=(string)au ! h264parse ! queue ! flvmux name=mux ! rtmpsink location='" + rtmpUrl+"'" out_send = cv2.VideoWriter(send_gst, 0, stream_fps, (stream_width, stream_height)) ... out_send.write(frame_output)
All works properly but flvmux is not accelerated by hardware so CPU usage is very high, especially at high resolution.
What I want: I would like to stream directly H264 to RTSP, instead of RTMP, without muxing it in FLV. In this way I should prevent CPU usage.
I’ve tested this code:
... # python stuff rtspUrl = 'rtsp://127.0.0.1:554/live/' + str(opt.camera_id) send_gst = "appsrc ! videoconvert ! video/x-raw,format=BGRx ! nvvidconv ! nvv4l2h264enc bitrate=" + str(config['viewer']['bitrate']) + " ! h264parse ! rtspclientsink location='" + rtspUrl + "'" out_send = cv2.VideoWriter(send_gst, 0, stream_fps, (stream_width, stream_height)) ... out_send.write(frame_output)
but for something reason it doesn’t work, it remains stucked to:
Opening in BLOCKING MODE
Issue seems limited to OpenCV VideoWriter cause if I use gst-launch-1.0 all works properly, in fact using:
gst-launch-1.0 videotestsrc ! video/x-raw,format=I420,width=640,height=480 ! omxh264enc ! video/x-h264, stream-format=byte-stream ! rtspclientsink location=rtsp://127.0.0.1/live/test
gst-launch-1.0 rtspsrc location=rtsp://admin:Password@192.168.0.202:554/ latency=500 ! queue ! rtph264depay ! h264parse ! rtspclientsink location=rtsp://127.0.0.1/live/test
I’m going crazy, I cannot find a solution.
Has anyone an idea?