gomediautils

module
v0.0.0-...-787406a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2026 License: MIT

README

GoMediaUtils

A Go library for muxing and demuxing MPEG-TS, MPEG-PS, FLV, MP4, Matroska/WebM, and RTMP, RTSP and SRT media streams.

Installation

go get github.com/ntklink/gomediautils

Codec Utilities

See the codec usage guide for more details.

  • Decode SPS, PPS, VPS, and slice headers
  • Decode and encode HEVCDecoderConfigurationRecord, AVCDecoderConfigurationRecord, AAC ADTS, and AudioSpecificConfiguration
  • Decode Opus extra data (OpusHead) and packets (TOC), and encode Opus extra data
  • Decode VP8 frame tags and keyframe headers
  • Decode MP3 frame headers

Supported Formats and Codecs

Format Mux Demux
MPEG-TS H.264, H.265, AAC, MP3 H.264, H.265, AAC, MP3
MPEG-PS H.264, H.265, AAC, G.711 A-law, G.711 μ-law H.264, H.265, AAC, G.711 A-law, G.711 μ-law
FLV H.264, H.265, AAC, G.711 A-law, G.711 μ-law, MP3 H.264, H.265, AAC, G.711 A-law, G.711 μ-law, MP3
MP4 H.264, H.265, AAC, G.711 A-law, G.711 μ-law, MP3, Opus H.264, H.265, AAC, G.711 A-law, G.711 μ-law, MP3, Opus
fMP4 H.264, H.265, AAC, G.711 A-law, G.711 μ-law H.264, H.265, AAC, G.711 A-law, G.711 μ-law
Matroska (MKV) H.264, H.265, VP8, AAC, Opus, MP3, G.711 A-law, G.711 μ-law H.264, H.265, VP8, AAC, Opus, MP3, G.711 A-law, G.711 μ-law
WebM VP8, Opus VP8, Opus
Ogg Opus Opus, VP8
WAV G.711 A-law, G.711 μ-law (and PCM / float samples) G.711 A-law, G.711 μ-law (and PCM / float samples)
Elementary stream H.264 / H.265 (Annex-B), AAC (ADTS), MP3, G.711 H.264 / H.265 (Annex-B), AAC (ADTS), MP3, G.711

Elementary streams (go-es) carry no timestamps; the readers derive them from the frame rate in the SPS and, for H.264/H.265 with B-frames, recover the presentation order from the picture order count of every slice.

RTMP

See the RTMP usage guide for more details.

  • Client and server support
  • Play and publish support
  • H.264, H.265, AAC, G.711 A-law, G.711 μ-law, and MP3 support

RTSP

  • Client and server support (RFC 2326)
  • Basic and Digest authentication
  • RTP support (RFC 3550)
  • G.711, AAC, H.264, and H.265 support

SRT

  • Caller (srt.Dial) and listener (srt.Listen, Accept) in live mode, interoperable with libsrt (ffmpeg, OBS, srt-live-transmit)
  • HSv5 handshake with stream id, parsed in the #!::r=...,m=publish access control syntax, and per stream authorization and rejection
  • Loss recovery: ACK/ACKACK round trip timing, immediate and periodic NAK, retransmission, too-late packet drop within the negotiated latency
  • AES-128/192/256 encryption from a passphrase (PBKDF2, RFC 3394 key wrap, AES-CTR)
  • Conn is a net.Conn; its reads form a byte stream the MPEG-TS demuxer consumes directly
  • Sender backpressure: Write waits for room in a bounded send buffer, and with MaxSendDelay while the link falls behind, so a live source can drop whole GOPs upstream instead of losing packets mid-GOP; write deadlines, Done/Err and typed close reasons

Directories

Path Synopsis
example
demux_flv command
demux_fmp4 command
demux_mp4 command
demux_ogg command
demux_ps command
demux_ts command
edit_mp4_time command
hls_fmp4_h265 command
http_flv_client command
http_flv_server command
internal/mediatest
Package mediatest runs the examples against real media produced and inspected by ffmpeg.
Package mediatest runs the examples against real media produced and inspected by ffmpeg.
mux_flv command
mux_mkv command
mux_ps command
mux_ps_h264 command
mux_ts command
mux_ts_aac command
mux_ts_mp3 command
read_mp3 command
remux_webm command
rtmp_server command
rtsp_server command
srt_push command
srt_server command
Package es reads and writes bare elementary streams: Annex-B H.264 and H.265 (.h264, .h265), ADTS AAC (.aac), MPEG audio (.mp3) and G.711 (.alaw, .ulaw).
Package es reads and writes bare elementary streams: Annex-B H.264 and H.265 (.h264, .h265), ADTS AAC (.aac), MPEG audio (.mp3) and G.711 (.alaw, .ulaw).
rtp
sdp
Package srt implements the SRT (Secure Reliable Transport) protocol in live mode, the mode media is sent in: a caller (Dial) and a listener (Listen, Accept) exchange messages over UDP, lost packets are recovered by retransmission within a fixed latency, and payloads can be encrypted with AES-CTR from a passphrase.
Package srt implements the SRT (Secure Reliable Transport) protocol in live mode, the mode media is sent in: a caller (Dial) and a listener (Listen, Accept) exchange messages over UDP, lost packets are recovered by retransmission within a fixed latency, and payloads can be encrypted with AES-CTR from a passphrase.
Package wav reads and writes RIFF/WAVE files: linear PCM, IEEE float and the G.711 A-law and μ-law formats that GB28181 cameras and RTSP/RTMP sources carry, so a G.711 stream pulled out of a PS, FLV or MKV file can be listened to directly and a WAV file can feed the muxers of this module.
Package wav reads and writes RIFF/WAVE files: linear PCM, IEEE float and the G.711 A-law and μ-law formats that GB28181 cameras and RTSP/RTMP sources carry, so a G.711 stream pulled out of a PS, FLV or MKV file can be listened to directly and a WAV file can feed the muxers of this module.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL