Ask Your Question

Revision history [back]

Issue writing Mat3b to GStreamer UDP sink

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=127.0.0.1 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=127.0.0.1 port=8553", CAP_GSTREAMER, 0, 30, Size(640, 480), true);

out.write(foreground);

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:

https://gist.githubusercontent.com/marcelherd/7b0f70d40b91da9725db2bd92ef64f1a/raw/91eaad0a53160a552b3acef61cf1570768c99f6d/RTSP_Server_Log.txt

I'm not sure why this fails? I'd appreciate any help greatly. The full code is available here: https://gist.github.com/marcelherd/67be9734ec018626b7d7b2d9c42b86a8