Every RTP stream carries a specific payload format that defines how media is encoded into packets. gortsplib models each format as a Go struct that implements theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/bluenviron/gortsplib/llms.txt
Use this file to discover all available pages before exploring further.
Format interface, giving you typed access to codec parameters and built-in RTP packetizers/depacketizers.
The Format interface
All format structs live in thegithub.com/bluenviron/gortsplib/v5/pkg/format package and satisfy this interface:
CreateEncoder() and CreateDecoder() methods that return format-specific RTP encoder/decoder objects.
| Method | Purpose |
|---|---|
PayloadType() | Identifies the payload within an RTP stream |
ClockRate() | Used to convert RTP timestamps to wall-clock time |
RTPMap() | Written into SDP a=rtpmap lines |
FMTP() | Written into SDP a=fmtp lines |
CreateEncoder() | Returns a packetizer that turns codec data into RTP packets |
CreateDecoder() | Returns a depacketizer that reassembles RTP packets into codec data |
Formats in a session description
When you callclient.Describe(), the library parses the SDP and returns a *description.Session. Each description.Media in desc.Medias holds a []format.Format slice:
Detecting a specific format
Because each codec is a concrete struct, you can use a type assertion to check for it:desc.FindFormat does this for you and also returns the matching media:
Creating encoders and decoders
Once you have a concrete format value, callCreateDecoder() to receive an RTP depacketizer, or CreateEncoder() to receive an RTP packetizer. The returned objects are format-specific, with typed Decode / Encode methods.
Not every format ships with a built-in encoder or decoder. Formats such as Speex, Vorbis, and G726 require you to supply your own RTP packetizer. See the audio and video reference pages for availability details.
Next steps
Video formats
H264, H265, AV1, VP8, VP9, M-JPEG, MPEG-4 Video, and MPEG-1/2 Video.
Audio formats
Opus, MPEG-4 Audio (AAC), G711, G722, LPCM, AC-3, Speex, and more.