GstRtspSink - Dual Multicast
This example publishes two multicast-backed streams from one deployment. It is useful when two groups of clients need different content and both groups benefit from one-to-many delivery.
The multicast clients can't be in the same machine as the server. Please use at least 2 machines (one as a server and one as a client. This wiki provides an example of H264 streams through two different multicast groups. |
Server-side Pipeline
This example generates two test patterns and encodes to H264. Then it creates two independent RTSP streams, each one in a different multicast group.
PORT=12345
MAPPING1=/stream1
MAPPING2=/stream2
IP_MIN=224.2.0.3
IP_MAX=224.2.0.10
PORT_MIN=7000
PORT_MAX=7010
TTL=128
gst-launch-1.0 rtspsink name=sink service=${PORT} multicast-ip-min=${IP_MIN} multicast-ip-max=${IP_MAX} \
multicast-port-min=${PORT_MIN} multicast-port-max=${PORT_MAX} multicast=true \
videotestsrc pattern=snow ! queue ! x264enc key-int-max=30 ! video/x-h264,mapping=${MAPPING1} ! sink. \
videotestsrc pattern=ball ! queue ! x264enc key-int-max=30 ! video/x-h264,mapping=${MAPPING2} ! sink.
Clients-side
VLC
IP_ADDRESS=<IP ADDRESS OF HOST>
PORT=12345
MAPPING1=stream1
MAPPING2=stream2
# Stream 1
vlc rtsp://${IP_ADDRESS}:${PORT}/${MAPPING1}
# Stream 2
vlc rtsp://${IP_ADDRESS}:${PORT}/${MAPPING2}
GStreamer
IP_ADDRESS=<IP ADDRESS OF HOST>
PORT=12345
MAPPING1=stream1
MAPPING2=stream2
# Stream 1
gst-launch-1.0 rtspsrc location=rtsp://${IP_ADDRESS}:${PORT}/${MAPPING1} ! rtph264depay ! avdec_h264 ! autovideosink
# Stream 2
gst-launch-1.0 rtspsrc location=rtsp://${IP_ADDRESS}:${PORT}/${MAPPING2} ! rtph264depay ! avdec_h264 ! autovideosink
MPlayer
IP_ADDRESS=<IP ADDRESS OF HOST>
PORT=12345
MAPPING1=stream1
MAPPING2=stream2
# Stream 1
mplayer rtsp://${IP_ADDRESS}:${PORT}/${MAPPING1}
# Stream 2
mplayer rtsp://${IP_ADDRESS}:${PORT}/${MAPPING2}
Totem
IP_ADDRESS=<IP ADDRESS OF HOST>
PORT=12345
MAPPING1=stream1
MAPPING2=stream2
# Stream 1
totem rtsp://${IP_ADDRESS}:${PORT}/${MAPPING1}
# Stream 2
totem rtsp://${IP_ADDRESS}:${PORT}/${MAPPING2}
Multicast Group Validation
Using
iftop
the use of the two multicast groups can be validated as the following:
sudo iftop -p
which effectively shows the use of two independent groups, 224.2.0.3 and 224.2.0.4 as shown in Figure 1.

Summary
Dual multicast is a useful pattern for split monitoring systems or products that must distribute two independent feeds efficiently.
Problems running the pipelines shown on this page? Please see our GStreamer Debugging guide for help.
Related pages
- GstRtspSink
- GstRtspSink - Basic usage
- GstRtspSink - Simple Examples
- GstRtspSink - Advanced examples
- GStreamer Debugging