Skip to main content

gortsplib

gortsplib is a production-ready RTSP client and server library for Go, written to power MediaMTX. It implements RTSP 1.0 and 2.0, handles RTP/RTCP packet routing, and supports a wide array of codecs and transport modes.

Quick Start

Get a working RTSP client or server running in minutes

Client Guide

Read and write RTSP streams with the Client API

Server Guide

Build custom RTSP servers with the handler interface

RTP Formats

Encode and decode H264, H265, AV1, AAC, Opus, and more

Key features

Client: Play & Record

Connect to any RTSP server to read media streams or publish your own, with automatic transport negotiation.

Server with handler interface

Implement only the callbacks you need — OnDescribe, OnAnnounce, OnSetup, OnPlay, OnRecord — and gortsplib handles the protocol.

Multiple transports

UDP, UDP-multicast, and TCP transports. The library switches automatically when a transport fails.

Secure variants

RTSPS (TLS), SRTP, and SRTCP for encrypted streams and authenticated sessions.

Tunneling

RTSP-over-HTTP and RTSP-over-WebSocket for traversing firewalls and proxies.

Rich codec support

Native RTP packetizers and depacketizers for H264, H265, AV1, VP8, VP9, AAC, Opus, G711, LPCM, and more.

Accurate timestamps

Extract PTS and NTP timestamps from inbound packets for synchronized playback or recording.

ONVIF back channels

Two-way audio support for ONVIF-compatible IP cameras using RTSP back channels.

Module path

gortsplib is published as a Go module. The current major version is v5:
github.com/bluenviron/gortsplib/v5
Go 1.25 or later is required.
ProjectDescription
MediaMTXProduction media server built on gortsplib
gohlslibHLS client and server library for Go
gortmplibRTMP client and server library for Go
mediacommonShared codec utilities
pion/rtpRTP library used internally
pion/rtcpRTCP library used internally
pion/srtpSRTP library used internally