top of page
  • Writer's pictureJafet Chaves

Unleashing the Power of RTSP for Video Streaming Applications using GstRtspSink

Updated: 4 days ago

Introduction


With GstRtspSink you can effectively transform any video producing system into an IP camera. The intention of this blog post is to show how easily it can be to deploy such a solution.


Streaming video is becoming an increasingly important part of many industries, from entertainment to security. To meet the growing demand for high-quality video streaming, developers need powerful tools that can help them deliver video streams reliably and efficiently. One of these solutions for streaming video is GstRtspSink from RidgeRun.


GstRtspSink is a plugin for GStreamer, the popular open-source multimedia framework, that allows developers to easily build multimedia applications. The plugin allows developers to stream video using the Real Time Streaming Protocol (RTSP), a popular network streaming protocol that is widely used for streaming video over the internet. GstRtspSink is compatible with a wide range of architectures such as ARM or x86.


As shown in figure 1 GstRtspSink can be deployed in an embedded system such as any NVIDIA Jetson or NXP i.MX 8 Series or even on a PC. Once installed, this solution allows to capture different media (video/audio/metadata) from any source and send it through the network to the internet, other PCs or mobile devices.



Figure 1. GstRtspSink solution architecture

Why is RTSP Needed at All?

You may wonder what is the necessity of RTSP. Isn't enough just to send data through a UDP socket? In the GStreamer domain I could achieve just the same with a udpsink/udpsrc pair.


Figure 2. RTSP as part of the OSI model

As shown in figure 2 RTSP operates within the application layer of the internet protocol stack, which is the highest level of abstraction. This layer's primary purpose is to provide network services to users. RTSP extends the functionality of RTP and UDP by incorporating features such as control commands (start, stop, pause, seek), improved error handling, data encryption, user authentication, and metadata transmission related to the media being streamed, such as format, bitrate, and resolution.


Also, RTSP defines a set of methods that enables clients to interact with servers, negotiate stream parameters, and control its delivery in real-time. This feature is particularly crucial in supporting multiple clients with varying encoding or streaming specifications. By providing such functionality, RTSP allows for a more flexible and efficient use of network resources, as it enables users to adjust their reception according to their needs and preferences, while minimizing the impact on the network.


Why GstRtpSink?


There are several key reasons why you should consider using GstRtspSink in your product development process:

  1. Simplifies Video Streaming Development: The GstRtspSink plugin implements in itself the RTSP server so it provides a reliable and efficient mechanism for transmitting video/audio streams to multiple clients all at once, reducing the complexity of the underlying streaming infrastructure. This simplification translates to faster development cycles and shorter time-to-market for video products.

  2. Customizable Streaming Options: The plugin supports a wide range of codecs, resolutions, authentication and encryption methods, allowing developers to tailor their streaming applications to meet specific requirements. This flexibility enables developers to create products that meet the unique needs of their customers and target markets.

  3. Low-Latency Streaming: GstRtspSink offers low-latency streaming, a critical feature in applications such as video conferencing, Advanced Driver Assistance Systems (ADAS) or live sports streaming for example. Low-latency streaming reduces the delay between when an event occurs and when it is perceived by the end user. GstRtspSink is suitable for applications where latency must be low enough for the operation of a system in real-time, such as driving a drone or moving a robotic arm.

  4. On-demand streaming: Due to how the RTSP protocol is defined a streaming is started until a client asks for it. This is fundamentally different from UDP, RTP or MPEG TS streaming where media is just sent all over the network from the beginning. This means that there is a reduced waste of bandwidth, especially in limited bandwidth budget networks.

  5. Easy prototyping: GstRtspSink provides a wrapper around the RTSP server library offered by the mainline GStreamer releases. This simplifies the integration of RTSP into an existing pipeline, reduces time to market and requires less expertise in GStreamer programming, compared to using the server as a standalone.

Potential Industries

  • Video Surveillance: GstRtspSink is commonly used in video surveillance systems. It allows users to stream live video footage from security cameras to a remote monitoring station in real-time.

  • Industrial Automation: GstRtspSink can be used in industrial automation systems for real-time monitoring of machinery and processes.

  • Healthcare: GstRtspSink can be used in healthcare applications such as telemedicine, where real-time streaming of video and audio is necessary for remote consultations between doctors and patients.

  • Drones and robotics: GstRtspSink can facilitate real-time video streaming and control of the device. Some examples are: remote control, autonomous navigation, object recognition, telepresence or augmented reality.

How can GstRtspSink be Used then?


Figure 3. Potential applications

Imagine you need to develop a robot or drone where having available on-demand, low latency live streaming video for navigation or inspection of a hazardous space is a crucial requirement. The purpose of this section is to demonstrate how fast this can be done with easy to use prototyping tools like gst-launch.


GstRtspSink is an out-of-the-box solution, so all you have to do is to install the plugin in your system and start using it. The usage of GstRtspSink is no different from any other GStreamer element so, if you are familiar with how to build GStreamer pipelines, then you would catch the usage of GstRtspSink right away. If not, don’t worry since we intend to show step by step how to implement a simple RTSP streaming link between a host PC and remote video producer device.


For our proposed concept example this was our hardware and software setup:

  • Sender: NVIDIA Jetson Xavier NX (developer kit)

  • Receiver: PC. Intel Core i7, 16 GB RAM, 1 TB disk

  • JetPack 5.1

  • GStreamer 1.16.3 (sender and receiver device)

  • GstShark, GstPerf (to measure frame rate or CPU load)

  • GstRtspSink (installed in the sender system)

The first step will be to set up the sender system (Jetson Xavier NX) with a JetPack installation. For convenience, during the time of writing this post we decided to use JetPack 5.1. To set up our Xavier NX developer kit we use the instructions here.


Next, GstRtspSink has to be installed either by using an evaluation version binary or compiled from source code. If you want to play around taking some CPU load or frame measurements you will need to install the GstShark and GstPerf elements as well, but these are optional.


Figure 4. High level diagram of the media processing

Figure 4 shows a block diagram of the sender and receiver pipelines that we want to implement using gst-launch-1.0. For the sender end the video source could be anything from an image sensor, an FPGA, video playback, etc. In our example, for simplicity, we chose to artificially produce image buffers using a test pattern generator (videotestsrc element). In general, the process stage is an optional stage that depends on the specific application. It could be cropping, resizing or applying some filter to the image, for example. Encoding is an essential part since it is impractical to send raw video through the network. Finally in the RTSP stage the pipeline gets the compressed data and sends it in RTP payloads over the network.

  • GStreamer pipeline of the sender end:

PORT=12345
MAPPING1=/stream1

gst-launch-1.0 videotestsrc is-live=true ! "video/x-raw, width=1920, height=1080, framerate=30/1" ! perf print-cpu-load=true ! queue leaky=2 max-size-buffers=30 ! nvvidconv ! nvv4l2h264enc insert-sps-pps=true insert-vui=true idrinterval=30 iframeinterval=30 maxperf-enable=true ! "video/x-h264, mapping=${MAPPING1}" ! rtspsink name=sink service=$PORT

Notice how we added RTSP functionality into the pipeline just by adding the element rtspsink into the GStreamer pipeline. So, adding RTSP streaming into your media application is just a matter of specifying the proper port number on which the RTSP server will be listening for incoming clients and the mapping. On the client side all that is needed is to specify the URL, which is composed of the IP address of the RTSP server, the port number and the mapping.

  • GStreamer pipeline of the receiver end:

IP_ADDRESS=172.17.1.36
PORT=12345
MAPPING1=stream1

gst-launch-1.0 uridecodebin uri=rtsp://${IP_ADDRESS}:${PORT}/${MAPPING1} ! queue leaky=2 max-size-buffers=30 ! perf ! xvimagesink sync=false

For the receiver end we could use any standard/well-known tools, independent from OS or platform. For example, we could use a simple GStreamer pipeline as shown above or we could use VLC with the command shown below (we could even receive the same stream simultaneously with different tools too!). Notice how easy it is to specify a receiver end, not in one single moment we needed to know the streaming specifics, such a resolution, frame rate, codec, etc. This is one of the beautiful aspects where RTSP simplifies the transmission for any user.

vlc rtsp://${IP_ADDRESS}:${PORT}/${MAPPING1}

If you prefer using the VLC GUI, go to Media menu -> Open Network Stream and type the RTSP URL, for example: rtsp://192.168.1.1:1234/stream1 as shown in figure 5.


Figure 5. VLC window example

Overall, GstRtspSink is a powerful embedded software solution that can significantly streamline media processing applications development, offering:

  • Flexibility.

  • Low-latency streaming.

  • Low CPU consumption.

  • Long-term runtime stability.

  • Portability on a wide range of platforms and architectures.

If you are a developer looking to quickly create high-quality, reliable, fast and efficient video streaming products, GstRtspSink is definitely a solution you should consider.


What’s Next?

For technical questions or to ask for an evaluation (free of charge) version of the plugin please send an email to support@ridgerun.com or send a message through http://www.ridgerun.com/contact.

522 views
bottom of page