GStreamer In-Band Metadata for MPEG Transport Stream - Examples - RTSP stream with metadata

From RidgeRun Developer Wiki


Previous: Examples/ C/C++ Index Next: FAQ





This pages shows how to implement a typical inquiry from customers: How to implement an RTSP server with muxed metadata?

Easy, for that you will need 2 RidgeRun products:

  • In-band metadata: described in this wiki page, in order to inject and extract custom KLV metadata to a GStreamer pipeline
  • RTSPsink: Easy to use RTSP server GStreamer pipeline

First thing to do is to create the pipeline that will inject metadata into the GStreamer pipeline. In below pipeline, metasrc element is used, injecting a sample metadata "hello" into the pipeline. The KLV stream is then muxed with the video and sent over RTSP. This example uses h.264 and a videotestsrc element, but it can be easily changed to use h.265 and any other video source, or even an audio stream.

Sender pipeline for x86

gst-launch-1.0 -e metasrc metadata="hello" period=1 ! 'meta/x-klv' ! mpegtsmux name=mux ! capsfilter caps="video/mpegts, mapping=stream1" ! identity silent=false ! rtspsink service=5005 async-handling=true  videotestsrc is-live=true ! 'video/x-raw,format=(string)I420,width=320,height=240,framerate=(fraction)30/1' ! videoconvert ! x264enc key-int-max=15 ! mux.

Sender pipeline for NVIDIA Jetson

gst-launch-1.0 -e metasrc metadata="hello" period=1 ! 'meta/x-klv' ! mpegtsmux name=mux ! capsfilter caps="video/mpegts, mapping=stream1" ! identity silent=false ! rtspsink service=5005 async-handling=true  videotestsrc is-live=true ! 'video/x-raw,format=(string)I420,width=320,height=240,framerate=(fraction)30/1' ! nvvideoconvert ! nvv4l2h264enc insert-sps-pps=true idrinterval=15 ! mux.

Above pipelines have already generated the muxed streams, now it is time to show how to receive and demux the streams. Below pipeline will receive the RTSP stream and demux it, in order to display the video and log the KLV metadata.

Receiver pipeline for x86

RTSP_IP_ADDRESS=192.168.55.1 #IP Address of the sender

gst-launch-1.0 rtspsrc location=rtsp://$RTSP_IP_ADDRESS:5005/stream1 ! rtpmp2tdepay ! tsdemux name=demux demux. ! h264parse ! avdec_h264 ! queue ! videoconvert ! autovideosink sync=false demux. ! queue ! "meta/x-klv" ! fakesink dump=true async=true sync=false

Receiver pipeline for NVIDIA Jetson

RTSP_IP_ADDRESS=192.168.55.1 #IP Address of the sender

gst-launch-1.0 rtspsrc location=rtsp://$RTSP_IP_ADDRESS:5005/stream1 ! rtpmp2tdepay ! tsdemux name=demux demux. ! h264parse ! nvv4l2decoder ! queue ! autovideosink sync=false demux. ! queue ! "meta/x-klv" ! fakesink dump=true async=true sync=false

With above receiver pipelines you will see the videotestsrc image displayed in a window, but you will also see the KLV metadata printed out on the terminal, something like:

00000000 (0x7f346c035f80): 68 65 6c 6c 6f 00                                hello.          
00000000 (0x7f346c035f60): 68 65 6c 6c 6f 00                                hello.          
00000000 (0x7f346c0b37a0): 68 65 6c 6c 6f 00                                hello.


Previous: Examples/ C/C++ Index Next: FAQ