How to connect two Gstreamer pipes?


I have a Jetson TX2 and am using Gstreamer to capture frames from my camera. I want to stream this via rtsp and receive it on another computer, for example with vlc.

I want to enter an URL into vlc and then see my stream. I got it working with an sdp file but want to use only an url that works without an sdp file.

I looked into it and found something called gst-rtsp-server. I installed it according to this stackoverflow comment:

the example works flawlessly. I can start it with:

./test-launch "( videotestsrc ! x264enc ! rtph264pay name=pay0 pt=96 )"

And then i can see it via vlc, even on an ipad where you can’t even open sdp files.

But i am having trouble using this with my existing setup. I have a cpp file where i already have a pipeline and a mainloop that feeds frames into it. I can’t do that in commandline arguments as they did with the ‘test-launch’ example.

Is there a way where i can do the following?

.cpp code:

// ...
g_streamer_pipeline_string = ("appsrc ! video/x-raw, format=BGR ! queue ! videoconvert ! video/x-raw, format=BGRx ! nvvidconv \
! nvv4l2h264enc bitrate=1600000 maxperf-enable=1 \
! MAGIC_SINK", 0, 40, cv::Size (width, height));
// ...

and then use this with the example of gst-rtsp-server:

./test-launch "( MAGIC_SOURCE ! rtph264pay name=pay0 pt=96 )"

Where MAGIC_SOURCE and MAGIC_SINK are the magic glue i need to connect the two Gstreamer pipes. Basically i want my cpp code to stream into some sort of sink that i can pick up with another pipe in another process.
Is that possible ?

The rtsp server will be taking care of the sink for you (on the tx side). In the pipeline you’ve posted you’re missing a payloader, which in this case is rtph264pay, the payloader goes after the nvv4l2h264enc and before the sink (though since it’s an rtsp server I dunno if you need the sink). On the receiving side you’d have something like “udpsrc uri=udp://IP_ADDRESS/suffix_you_added ! rtph264depay ! avdec_h264 ! videoconvert ! appsink”. The rtsp-server-repo has a bunch of good examples to get you up and running with some boilerplate code. This is a good example of how to construct the a multi-casting rtsp server (and set up the URI for said server).

i found an easy way following this: