Skip to content

RTSP Server, SDP

Martin Pulec edited this page Nov 11, 2020 · 21 revisions

When using network protocol SDP or RTSP, UltraGrid uses RTP as normally but 2 things act differently:

  1. codecs are packed according to the RFCs (that however limits available codecs that can be used - H.264 for video and OPUS or PCMU for audio)
  2. descriptive SDP file is produced - depending on the protocol used it is provided either as a file (or with a HTTP server) or utilized within a RTSP session

Note: Current implementation is able to handle only one receiver at the same time. To process multiple receivers, check Use Cases.

Table of Contents

RTSP

RTSP server can be run with following commands:

uv -t <your_capture> -c libavcodec:encoder=libx264 --video-protocol rtsp

or with audio

uv -t <your_capture> -c libavcodec:encoder=libx264 --video-protocol rtsp -s <audio_cap> --audio-codec u-law --audio-protocol rtsp

If you omit audio/video compression, some suitable will be chosen.

SDP

uv -t <video_capture> -s <audio_capture> --protocol sdp <receiver>

In this case, default compression will be chosen (can be changed similarly to RTSP, eg. also A-law or OPUS for audio). SDP file ug.sdp will be created which can then be played by the receiver given on command-line. Alternatively, the receiver can use (play) the URL provided by sender on terminal, eg.:

mplayer http://93.184.216.34:8554/ug.sdp

Multicast

UltraGrid can also use a multicast address as a receiver. In that case all receivers that are able to receive multicast can join the multicast group:

uv -t <video_capture> -s <audio_capture> --protocol sdp 224.0.0.20 # sender IPv4
uv -t <video_capture> -s <audio_capture> --protocol sdp ff02::20 # sender IPv6
mplayer http://93.184.216.34:8554/ug.sdp # receivers IPv4

Autorun

There is also an autorun option allows setting the receiver IP address automatically, eg.:

uv -4 -t <video_capture> -s <audio_capture> --protocol sdp:autorun
mplayer http://93.184.216.34:8554/ug.sdp

It works as a very simple session management - UltraGrid will send data to the client that requests the SDP file over HTTP.

Note: Avoid sending the link over services (eg. Facebook) that deliberately open the sent links.

Supported formats

Audio

  • 1 channel PCMA/PCMU 8000 Hz (G.711) - --audio-codec u-law:sample-rate=8000
  • 1 channel PCMA/PCMU or OPUS 48000 Hz
  • 2 channel PCMA/PCMU 48000 Hz (--audio-codec u-law --audio-capture-format channels=2)

not working:

  • OPUS with 2 or more channels

may be working:

  • 1 channel OPUS with supported sampling rates (8, 12, 16, 24 and 48 kHz)
  • multi-channel PCMA/PCMU with various sample rates

Video

H.264 and JPEG are currently supported for video. H.264 is set automatically if no compression is explicitly given.

For best compatibility it is recommended to turn of Intra Frame Refresh and possibly reduce the bitrate for H.264:

-c libavcodec:encoder=libx265:subsampling=420:disable_intra_refresh:bpp=0.15

JPEG encapsulation is quite rigid according to RFC 2435. Only interleaved, YUV 4:2:2 and 4:2:0 with default Huffman tables is supported. Therefore recommended settings for GPUJPEG and libavcodec are:

-c GPUJPEG:interleaved
# or
-c libavcodec:encoder=mpjpeg:subsampling=420   # libavcodec uses RFC-incompatible component order for 422, thus only 420 can be used
Clone this wiki locally