Issue writing Mat3b to GStreamer UDP sink

asked 2019-10-26 06:00:35 -0600

Shishigami gravatar image

I have one component that receives from GStreamer's UDP source and serves that as RTSP stream using gst-rtsp-server. It uses the following pipeline:

udpsrc port=8553 ! application/x-rtp, payload=96 ! rtpjitterbuffer ! rtph264depay ! avdec_h264 ! x264enc tune=zerolatency ! rtph264pay name=pay0 pt=96

I verified the functionality successfully by writing into UDP sink from command line:

gst-launch-1.0 -v videotestsrc ! video/x-raw,width=800,height=600,codec=h264,type=video ! videoscale ! videoconvert ! x264enc tune=zerolatency ! rtph264pay ! udpsink host= port=8553

Instead of feeding data from command line, I want to use an Intel RealSense camera. I use OpenCV to transform the frames, the result is a Mat3b (foreground) that is displayed in imshow. This works fine, but I want to write it to the UDP sink instead of displaying it. I added this code to achieve this:

VideoWriter out("appsrc ! videoconvert ! x264enc tune=zerolatency ! rtph264pay pt=96 ! udpsink host= port=8553", CAP_GSTREAMER, 0, 30, Size(640, 480), true);


I don't get any errors running this, but when I try to open the RTSP stream in VLC, the server prints an error and VLC is unable to open the network stream:

I'm not sure why this fails? I'd appreciate any help greatly. The full code is available here:

edit retag flag offensive close merge delete