Difference between revisions of "RTSP Sink"
m |
m (→Client) |
||
Line 199: | Line 199: | ||
$ vlc rtsp://<target.or.host.pc.ip.address>:554/mystream | $ vlc rtsp://<target.or.host.pc.ip.address>:554/mystream | ||
− | + | <br> | |
− | |||
+ | == rtspsink gstreamer pipelines for 1080p30 mt9p031 camera capture == | ||
+ | |||
+ | ====== Pipeline to run at target hardware board:<br> ====== | ||
+ | <pre>gst-launch --gst-debug=2 v4l2src input-src=camera always-copy=false ! 'video/x-raw-yuv, width=1920, height=1088, framerate=(fraction)30/1' ! dmaiaccel ! dmaiperf ! / | ||
+ | dmaienc_h264 encodingpreset=2 ratecontrol=2 targetbitrate=2000000 intraframeinterval=30 idrinterval=90 bytestream=true ! queue ! mpegtsmux ! rtspsink mapping=/stream | ||
+ | </pre> | ||
+ | <br> | ||
+ | |||
+ | ====== Pipeline to run at client (Host PC):<br> ====== | ||
+ | <pre>gst-launch rtspsrc location="rtsp://ip.address of.targetboard/stream" ! rtpmp2tdepay ! mpegtsdemux ! queue ! ffdec_h264 ! xvimagesink sync=false | ||
+ | </pre> | ||
+ | Note: Please replace 'ip.address of targetboard' with the IP address of your target board.<br> | ||
+ | |||
+ | |||
+ | |||
+ | ====== OR Streaming can be tested at client (Host PC) using vlc or mplayer like below:<br> ====== | ||
+ | <pre>vlc rtsp://target.board.ip/stream | ||
+ | |||
+ | mplayer rtsp://target.board.ip/stream | ||
+ | </pre> | ||
+ | <br> | ||
+ | |||
+ | <br> | ||
== See also == | == See also == | ||
*[[RidgeRun RTSP GStreamer Server|RTSP server]] | *[[RidgeRun RTSP GStreamer Server|RTSP server]] |
Revision as of 12:15, 18 June 2013
Contents
Overview
The RTSP Sink is a Gstreamer sink element which permits high performance streaming to multiple computers using the RTSP protocol. This element leverages previous logic from RidgeRun's RTSP server but providing the benefits of a Gstreamer sink element like great flexibility to integrate into applications and easy gst-launch based testing.
With RTSP Sink multiple streams can be achieved simultaneously using any desired combination. This means that within a single pipeline you can stream multiple videos, multiple audios and multiple audio+video, each one to a different client and a different mapping. On the examples section different streaming possibilities are shown.
Features
Currently rtspsink exhibits the following features:
- Configurable mappings for each stream.
- Configurable port.
- Automatic payloader detection according to the negotiated caps.
- Multiple independent video only streamings.
- Multiple independent audio only streamings.
- Multiple independent audio+video streamings.
- Support for:
- H264 video encoding
- MPEG4 video encoding
- MJPEG video encoding
- AAC audio encoding
Getting the code
RTSP Sink is an add-on to RidgeRun's professional SDK.
Building the code
Although RtspSink source code is delivered ready to be built along with RidgeRun's SDK, the code is platform independent and can be built for the host PC as well.
Building for RidgeRun SDK
The source code for RTSP sink can be found on
$DEVDIR/proprietary/gst-rtsp-sink
The element will build along with the SDK if selected on the configuration menu.
make config '-> Proprietary software '-> RR RTSP Sink
The RTSP Sink can be built manually by:
- Build the code
cd $DEVDIR/proprietary/gst-rtsp-sink make
- Install the plugin
make install
Note: Building the gst-rtsp-sink as a standalone may fail if the package dependencies are not built properly
Building for a host PC
- Build the code
$ cd $DEVDIR/proprietary/rr_rtsp_sink/src; #Note the src subdirectory $ ./configure --prefix=/usr; #Prefix is necessary in order to install the plugin in the default gstreamer location $ make
- Install the plugin
$ sudo make install; #You will need root privileges to install the plugin
Basic usage
RTSP Sink is a Gstreamer sink element which you can attach multiple pipeline branches, each one describing a different media to stream. To use RTSP Sink on the host PC you may need root privileges in order to access the respective sockets.
Requesting pads
On the RTSP Sink pads are requested using regular Gstreamer notation. For example, to attach 3 different branches to the sink the pipeline should look like the following:
~# gst-launch rtspsink name=sink \ < branch 1 > ! sink. \ < branch 2 > ! sink. \ < branch 3 > ! sink.
Graphically, the pipeline would look something like:
Combining and naming streams
Each stream needs to be mapped to a different URL so the different clients can access them independently. This is called the mapping of the stream. The RTSP Sink element will try to read the mapping from the caps it negotiates with the upstream element, this means that assigning a mapping to a stream is as simple as setting it on the caps. For example, a pipeline with a single streaming branch with "/stream" as the mapping should look like the following:
~# gst-launch videotestsrc ! x264enc ! video/x-h264, mapping=/stream ! rtspsink
Note that the mapping is defined by setting the mapping=/stream value on the caps. The only rule is that the mapping must always start with a trailing "/". If no mapping is explicitly provided the it will default to /test
Each mapping will be treated as an individual stream. This means that if you want to combine an audio and a video branch within a single A/V stream, they must share the same mapping. The following pipeline will produce 3 independent streams: a video mapped to "/video", an audio mapped to "/audio" and an audio+video mapped to "/audiovideo".
~# gst-launch rtspsink name=sink \ < branch 1 > ! video/x-h264, mapping=/video ! sink. \ < branch 2 > ! audio/mpeg, mapping=/audio ! sink. \ < branch 3v > ! video/x-h264, mapping=/audiovideo ! sink. \ < branch 3a > ! audio/mpeg, mapping=/audiovideo ! sink.
This will combine branches 3v and 3a as a single streaming under the name of "/audiovideo". This can be shown graphically on figure 2.
Supported formats
The following table conveniently resumes the supported encoding formats and their respective mimetypes for you to build as
gst-launch ... ! mimetype, mapping="/test" ! rtspsink
Format | Mimetype |
---|---|
H264 video | video/x-h264 |
MPEG4 video | video/mpeg |
MJPEG video | image/jpeg |
AAC audio | audio/mpeg |
Service configuration
Besides the actual streaming data, RTSP is high level protocol that negotiates streaming internals with every client that intends to connect to a mapping. In order to request a stream, the client must connect to the server at a specific port where the RTSP server is up and waiting for connections. The port at which the server is listening to, and the clients must talk to is called the service and it is typically set to 554. RTSP Sink allows to configure the service by means of a GStreamer property like the following:
~# gst-launch audiotestsrc ! ffenc_aac ! audio/mpeg, mapping=/mystream ! rtspsink service="3000"
If no service is specified then it default to 554.
Examples
The following section provides a series of examples of possible use cases of RTSP Sink. For all of them, the different streams can be viewed on a host PC using VLC as the following:
~# vlc rtsp://$SERVER_IP/$MAPPING:$PORT
where $SERVER_IP is the IP address of the RTSP server and $MAPPING is the name of the mapping that the client wants to connect to, and $PORT is the service at which the server is listening to.
Note: When running on a host PC root privileges may be needed to access the respective sockets.
Single MPEG4 video streaming
~# gst-launch v4l2src ! ffenc_mpeg4 ! video/mpeg, mapping=/stream ! rtspsink
Single AAC audio streaming
~# gst-launch alsasrc ! ffenc_aac ! audio/mpeg, mapping=/stream ! rtspsink
Dual H264 video streaming
~#gst-launch rtspsink name=sink \ v4l2src ! x264enc ! video/x-h264, mapping=/stream1 ! sink. videotestsrc ! x264enc ! video/xh264, mapping=/stream2 ! sink.
Audio+Video Streaming
~#gst-launch rtspsink name=sink \ v4l2src ! x264enc ! video/x-h264, mapping=/stream ! sink. alsasrc ! ffenc_aac ! audio/aac, mapping=/stream ! sink.
Audio+Video streaming plus H264 single streaming
~#gst-launch rtspsink name=sink \ v4l2src ! x264enc ! video/x-h264, mapping=/stream1 ! sink. alsasrc ! ffenc_aac ! audio/aac, mapping=/stream1 ! sink. videotestsrc ! x264enc ! video/x-h264, mapping=stream2 ! sink.
Additional documentation
Access the full plugin documentation by making a gst-inspect of the rtspsink
$ gst-inspect rtspsink
Legacy RTSP Sink
The old version of RTSP Sink maintains the same idea of integrating an RTSP server into a gstreamer pipeline but its developed to support a single video stream. The main difference is that the service is specified by means of a property rather than on the caps.
On target board
$ gst-launch videotestsrc ! dmaienc_h264 idrinterval=30 targetbitrate=2500000 single-nalu=false ! rtspsink mapping="/mystream" service=554
On host PC
On the host PC you might need to use root privileges to access the respective sockets.
$ sudo gst-launch videotestsrc ! x264enc ! rtspsink mapping="/mystream" service=554
Client
As an RTSP client vlc may be used as the following:
$ vlc rtsp://<target.or.host.pc.ip.address>:554/mystream
rtspsink gstreamer pipelines for 1080p30 mt9p031 camera capture
Pipeline to run at target hardware board:
gst-launch --gst-debug=2 v4l2src input-src=camera always-copy=false ! 'video/x-raw-yuv, width=1920, height=1088, framerate=(fraction)30/1' ! dmaiaccel ! dmaiperf ! / dmaienc_h264 encodingpreset=2 ratecontrol=2 targetbitrate=2000000 intraframeinterval=30 idrinterval=90 bytestream=true ! queue ! mpegtsmux ! rtspsink mapping=/stream
Pipeline to run at client (Host PC):
gst-launch rtspsrc location="rtsp://ip.address of.targetboard/stream" ! rtpmp2tdepay ! mpegtsdemux ! queue ! ffdec_h264 ! xvimagesink sync=false
Note: Please replace 'ip.address of targetboard' with the IP address of your target board.
OR Streaming can be tested at client (Host PC) using vlc or mplayer like below:
vlc rtsp://target.board.ip/stream mplayer rtsp://target.board.ip/stream