Skip to content

rtspout

Romain Bouqueau edited this page Mar 5, 2024 · 36 revisions

Warning

GPAC's wiki has moved to wiki.gpac.io.

This github wiki will no longer be updated.

You can contribute to GPAC's documentation here.

RTSP Server

Register name used to load filter: rtspout
This filter may be automatically loaded during graph resolution.

The RTSP server partially implements RTSP 1.0, with support for OPTIONS, DESCRIBE, SETUP, PLAY, PAUSE and TEARDOWN.
Multiple PLAY ranges are not supported, PLAY range end is not supported, PAUSE range is not supported.
Only aggregated control is supported for PLAY and PAUSE, PAUSE/PLAY on single stream is not supported.
The server only runs on TCP, and handles request in sequence: it will not probe for commands until previous response is sent.
The server supports both RTP over UDP delivery and RTP interleaved over RTSP delivery.

The scheduling algorithm and RTP options are the same as the RTP output filter, see gpac -h rtpout
The server will disconnect UDP streaming sessions if no RTCP traffic has been received for timeout seconds.

The server can run over TLS by specifying cert and pkey, in which case the default port is 322.

Sink mode

The filter can work as a simple output filter by specifying the dst option:
Example

gpac -i source -o rtsp://myip/sessionname  
gpac -i source -o rtsp://myip/sessionname

In this mode, only one session is possible. It is possible to loop the input source(s).

Server mode

The filter can work as a regular RTSP server by specifying the mounts option to indicate paths of media file to be served:
Example

gpac rtspout:mounts=mydir1,mydir2

In this case, content RES from any of the specified directory is exposed as rtsp://SERVER/RES

The mounts option can also specify access rule file(s), see gpac -h creds. When rules are used:

  • if a directory has a name rule, it will be used in the URL
  • otherwise, the directory is directly available under server root /
  • only read access and multicast rights are checked
    Example
[foodir]  
name=bar

Content RES of this directory is exposed as rtsp://SERVER/bar/RES.

In this mode, it is possible to load any source supported by gpac by setting the option dynurl.
The expected syntax of the dynamic RTSP URLs is rtsp://servername/?URL1[&URLN] or rtsp://servername/@URL1[@URLN]
Each URL can be absolute or local, in which case it is resolved against the mount point(s).
Example

gpac -i rtsp://localhost/?pipe://mynamepipe&myfile.mp4 [dst filters]

The server will resolve this URL in a new session containing streams from myfile.mp4 and streams from pipe mynamepipe.
When setting runfor in server mode, the server will exit at the end of the last session being closed.

The parameter name=VAL is reserved to assign a session name in case multicast mirroring is used.
Example

gpac -i rtsp://localhost/?name=live?pipe://mynamepipe&myfile.mp4 [dst filters]

Usage of dynamic URLs can also be configured using the specific directory $dynurl in an access rule file.
EX[$dynurl]
ru=foo
This will allow dynamic URLs only for foo user.

Note: If the dynurl is set, it is enabled for all users, without authentication.

Multicasting

In both modes, clients can setup multicast if the mcast option is on or mirror.
When mcast is set to mirror mode, any DESCRIBE command on a resource already delivered through a multicast session will use that multicast.
Consequently, only DESCRIBE methods are processed for such sessions, other methods will return Unauthorized.

In server mode, multicast can be enabled per read directory using the mcast access rule of the directory configuration - see gpac -h creds.

HTTP Tunnel

The server mode supports handling RTSP over HTTP tunnel by default. This can be disabled using htun.
The tunnel conforms to QT specification, and only HTTP 1.0 and 1.1 tunnels are supported.

Options

dst (cstr): location of destination resource
port (uint, default: 554): server port
firstport (uint, default: 6000): port for first stream in session
mtu (uint, default: 1460): size of RTP MTU in bytes
ttl (uint, default: 0): time-to-live for multicast packets (a value of 0 uses client requested TTL, or 1)
ifce (str): default network interface to use
payt (uint, default: 96, minmax: 96-127): payload type to use for dynamic decoder configurations
mpeg4 (bool, default: false): send all streams using MPEG-4 generic payload format if possible
delay (sint, default: 0): send delay for packet (negative means send earlier)
tt (uint, default: 1000): time tolerance in microsecond (whenever schedule time minus realtime is below this value, the packet is sent right away)
runfor (sint, default: -1): run the session for the given time in ms. A negative value means run for ever if loop or source duration, value 0 only outputs the sdp
tso (sint, default: -1): set timestamp offset in microseconds (negative value means random initial timestamp)
xps (bool, default: false): force parameter set injection at each SAP. If not set, only inject if different from SDP ones
latm (bool, default: false): use latm for AAC payload format
mounts (strl): list of directories to expose in server mode
block_size (uint, default: 10000): block size used to read TCP socket
maxc (uint, default: 100): maximum number of connections
timeout (uint, default: 20): timeout in seconds for inactive sessions (0 disable timeout)
user_agent (str, default: $GUA): user agent string, by default solved from GPAC preferences
close (bool, default: false): close RTSP connection after each request, except when RTP over RTSP is used
loop (bool, default: true): loop all streams in session (not always possible depending on source type)
dynurl (bool, default: false): allow dynamic service assembly
mcast (enum, default: off): control multicast setup of a session

  • off: clients are never allowed to create a multicast
  • on: clients can create multicast sessions
  • mirror: clients can create a multicast session. Any later request to the same URL will use that multicast session

quit (bool, default: false): exit server once first session is over (for test purposes)
htun (bool, default: true): enable RTSP over HTTP tunnel
trp (enum, default: both): transport mode

  • both: allow TCP or UDP traffic
  • udp: only allow UDP traffic
  • tcp: only allow TCP traffic

cert (str): certificate file in PEM format to use for TLS mode
pkey (str): private key file in PEM format to use for TLS mode

HOME » Filters

Filters Overview

General Filters Concepts
gpac General Usage
Built-in Properties

GPAC Configuration

Configuration File
Global Options
Logging

Filters Help

Inspect packets (inspect)
Probe source (probe)
Compositor (compositor)
ISOBMFF/QT demultiplexer (mp4dmx)
MPEG-4 BIFS decoder (bifsdec)
MPEG-4 OD decoder (odfdec)
File input (fin)
BT/XMT/X3D loader (btplay)
HTTP input (httpin)
SVG loader (svgplay)
JPG/J2K/PNG/BMP reframer (rfimg)
PNG/JPG decoder (imgdec)
ADTS reframer (rfadts)
LATM reframer (rflatm)
MP3 reframer (rfmp3)
FAAD decoder (faad)
MAD decoder (maddec)
OpenJPEG2000 decoder (j2kdec)
AC3 reframer (rfac3)
A52 decoder (a52dec)
AMR/EVRC reframer (rfamr)
OGG demultiplexer (oggdmx)
Vorbis decoder (vorbisdec)
Theora decoder (theoradec)
MPEG-2 TS demultiplexer (m2tsdmx)
UDP/TCP input (sockin)
DVB for Linux (dvbin)
OpenSVC decoder (osvcdec)
VideoToolBox decoder (vtbdec)
MediaCodec decoder (mcdec)
MPEG-4 LASeR decoder (lsrdec)
SAF demultiplexer (safdmx)
MPEG-DASH and HLS client (dashin)
CENC decryptor (cdcrypt)
CENC encryptor (cecrypt)
ISOBMFF/QT multiplexer (mp4mx)
QCP reframer (rfqcp)
H263 reframer (rfh263)
M1V/M2V/M4V reframer (rfmpgvid)
NHNT reader (nhntr)
NHML reader (nhmlr)
AVC/HEVC reframer (rfnalu)
MPEG PS demultiplexer (m2psdmx)
AVI demultiplexer (avidmx)
Subtitle loader (txtin)
TTXT/TX3G decoder (ttxtdec)
WebVTT decoder (vttdec)
TTML decoder (ttmldec)
RTP/RTSP/SDP input (rtpin)
File output (fout)
Raw AAC to LATM writer (uflatm)
ADTS writer (ufadts)
MHAS writer (ufmhas)
Media Reframer (reframer)
Stream to file (writegen)
AVC/HEVC to AnnexB writer (ufnalu)
QCP writer (writeqcp)
WebVTT unframer (ufvtt)
NHNT writer (nhntw)
NHML writer (nhmlw)
VobSub parser (vobsubdmx)
AVI multiplexer (avimx)
Audio output (aout)
M4V writer (ufm4v)
VC1 writer (ufvc1)
Audio resampler (resample)
Video output (vout)
Video crop (vcrop)
Video flip (vflip)
RAW video reframer (rfrawvid)
PCM reframer (rfpcm)
JPG encoder (jpgenc)
PNG encoder (pngenc)
Audio/Video rewinder (rewind)
Sources concatenator (flist)
MPEG-2 TS multiplexer (m2tsmx)
DASH and HLS segmenter (dasher)
HEVC tile aggregator (tileagg)
HEVC tile bitstream splitter (tilesplit)
pipe input (pin)
pipe output (pout)
GSF Multiplexer (gsfmx)
GSF demultiplexer (gsfdmx)
UDP/TCP output (sockout)
AV1/IVF/VP9 reframer (rfav1)
IVF/OBU/annexB writer (ufobu)
NVidia decoder (nvdec)
ROUTE input (routein)
RTP Streamer (rtpout)
RTSP Server (rtspout)
HTTP Server (httpout)
HEVC tile splitter (hevcsplit)
HEVC Tile merger (hevcmerge)
FLAC reframer (rfflac)
MPEH-H Audio Stream reframer (rfmhas)
ProRes reframer (rfprores)
MPEG Transport Stream splitter (tssplit)
Compressed bitstream rewriter (bsrw)
Compressed layered bitstream splitter (bssplit)
Compressed layered bitstream aggregator (bsagg)
TX3G unframer (ufttxt)
TX3G to SRT (tx3g2srt)
TX3G to WebVTT (tx3g2vtt)
TX3G to TTML (tx3g2ttml)
WebVTT to TX3G (vtt2tx3g)
SRT reframer (rfsrt)
TTML to WebVTT (ttml2vtt)
TTML to SRT (ttml2srt)
MPEG-H Audio decoder (mpeghdec)
FFMPEG demultiplexer (ffdmx)
FFMPEG decoder (ffdec)
FFMPEG AV Capture (ffavin)
FFMPEG video rescaler (ffsws)
FFMPEG encoder (ffenc)
FFMPEG multiplexer (ffmx)
FFMPEG AVFilter (ffavf)
FFMPEG BitStream filter (ffbsf)
JavaScript filter (jsf)
ROUTE output (routeout)
TrueHD reframer (rftruehd)
CryptFile input (cryptin)
CryptFile output (cryptout)
Packet timestamp rewriter (restamp)
OGG multiplexer (oggmx)
Stream unframer (unframer)
Stream to unframed format (writeuf)
UNCV decoder (uncvdec)
GHI demultiplexer (ghidmx)
EVG video rescaler (evgs)
Closed-Caption decoder (ccdec)
DekTec SDIOut (dtout)
OpenHEVC decoder (ohevcdec)
Uncompressed Video File Format Generator Utility (uncvg)
GPU texture uploader (glpush)
Thumbnail collection generator (thumbs)
Audio Video Mixer (avmix)
AV Counter Generator (avgen)

Clone this wiki locally