gortsplib
![PkgGoDev](https://pkg.go.dev/badge/github.com/bluenviron/gortsplib/v4)
RTSP 1.0 client and server library for the Go programming language, written for MediaMTX.
Go ≥ 1.20 is required.
Features:
- Client
- Query servers about available media streams
- Play (read)
- Read media streams from servers with the UDP, UDP-multicast or TCP transport protocol
- Read TLS-encrypted streams (TCP only)
- Switch transport protocol automatically
- Read selected media streams
- Pause or seek without disconnecting from the server
- Write to ONVIF back channels
- Get PTS (relative) timestamp of incoming packets
- Get NTP (absolute) timestamp of incoming packets
- Record (write)
- Write media streams to servers with the UDP or TCP transport protocol
- Write TLS-encrypted streams (TCP only)
- Switch transport protocol automatically
- Pause without disconnecting from the server
- Server
- Handle requests from clients
- Record (read)
- Read media streams from clients with the UDP or TCP transport protocol
- Read TLS-encrypted streams (TCP only)
- Get PTS (relative) timestamp of incoming packets
- Get NTP (absolute) timestamp of incoming packets
- Play (write)
- Write media streams to clients with the UDP, UDP-multicast or TCP transport protocol
- Write TLS-encrypted streams (TCP only)
- Compute and provide SSRC, RTP-Info to clients
- Utilities
- Parse RTSP elements
- Encode/decode RTP packets into/from codec-specific frames
Table of contents
Examples
API Documentation
Click to open the API Documentation
RTP Payload Formats
In RTSP, media streams are routed between server and clients by using RTP packets, which are encoded in a specific, codec-dependent, format. This library supports formats for the following codecs:
Video
codec |
documentation |
encoder and decoder available |
AV1 |
link |
:heavy_check_mark: |
VP9 |
link |
:heavy_check_mark: |
VP8 |
link |
:heavy_check_mark: |
H265 |
link |
:heavy_check_mark: |
H264 |
link |
:heavy_check_mark: |
MPEG-4 Video (H263, Xvid) |
link |
:heavy_check_mark: |
MPEG-1/2 Video |
link |
:heavy_check_mark: |
M-JPEG |
link |
:heavy_check_mark: |
Audio
codec |
documentation |
encoder and decoder available |
Opus |
link |
:heavy_check_mark: |
Vorbis |
link |
MPEG-4 Audio (AAC) |
link |
:heavy_check_mark: |
MPEG-1/2 Audio (MP3) |
link |
:heavy_check_mark: |
AC-3 |
link |
:heavy_check_mark: |
Speex |
link |
G726 |
link |
G722 |
link |
:heavy_check_mark: |
G711 (PCMA, PCMU) |
link |
:heavy_check_mark: |
LPCM |
link |
:heavy_check_mark: |
Other
codec |
documentation |
encoder and decoder available |
MPEG-TS |
link |
Specifications
name |
area |
RFC2326, RTSP 1.0 |
protocol |
RFC7826, RTSP 2.0 |
protocol |
RFC8866, SDP: Session Description Protocol |
SDP |
RTP Payload Format For AV1 (v1.0) |
AV1 payload format |
RTP Payload Format for VP9 Video |
VP9 payload format |
RFC7741, RTP Payload Format for VP8 Video |
VP8 payload format |
RFC7798, RTP Payload Format for High Efficiency Video Coding (HEVC) |
H265 payload format |
RFC6184, RTP Payload Format for H.264 Video |
H264 payload format |
RFC3640, RTP Payload Format for Transport of MPEG-4 Elementary Streams |
MPEG-4 audio, MPEG-4 video payload formats |
RFC2250, RTP Payload Format for MPEG1/MPEG2 Video |
MPEG-1 video, MPEG-2 audio, MPEG-TS payload formats |
RFC2435, RTP Payload Format for JPEG-compressed Video |
M-JPEG payload format |
RFC7587, RTP Payload Format for the Opus Speech and Audio Codec |
Opus payload format |
Multiopus in libwebrtc |
Opus payload format |
RFC5215, RTP Payload Format for Vorbis Encoded Audio |
Vorbis payload format |
RFC4184, RTP Payload Format for AC-3 Audio |
AC-3 payload format |
RFC6416, RTP Payload Format for MPEG-4 Audio/Visual Streams |
MPEG-4 audio payload format |
RFC5574, RTP Payload Format for the Speex Codec |
Speex payload format |
RFC3551, RTP Profile for Audio and Video Conferences with Minimal Control |
G726, G722, G711, LPCM payload formats |
RFC3190, RTP Payload Format for 12-bit DAT Audio and 20- and 24-bit Linear Sampled Audio |
LPCM payload format |
Codec specifications |
codecs |
Golang project layout |
project layout |
Related projects