rtmpav

package module
v0.0.0-...-bdb2c91 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package rtmpav moves media between goav and RTMP and RTMPS peers: publishing to YouTube, Twitch, or a local MediaMTX or nginx-rtmp, playing from them, and taking OBS's publish. RTMP is the protocol here, in the standard library alone (the handshake, signed and simple, the chunk stream, AMF0 commands, and Enhanced RTMP's codec negotiation); the media is FLV, which goav's container/flv reads and writes, Enhanced RTMP's HEVC, AV1, VP9, Opus, and multitrack included.

RTMP is the rtmp and rtmps URL scheme, registered with runconfig.Scheme: goav.URI publishes, goav.URIInput plays. Listen is an ingest server whose Input is the live input of one stream.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCodecRefused reports a stream in a codec the server does not take:
	// it negotiated Enhanced RTMP and listed codecs without this one. Encode
	// the stream to H.264 or AAC, which every server takes.
	ErrCodecRefused = errors.New("rtmpav: the server does not take the codec")
	// ErrStreamEnded reports a live stream whose publisher stopped or
	// dropped; goav.Reconnect waits for the next.
	ErrStreamEnded = errors.New("rtmpav: the live stream ended")
)

Functions

func RTMP

func RTMP(options ...Option) provider.Scheme

RTMP is the rtmp and rtmps scheme, an RTMP client for goav.URIInput and goav.URI. Register it under both names:

rtmp := rtmpav.RTMP()
runconfig.Scheme("rtmp", rtmp), runconfig.Scheme("rtmps", rtmp)

A URL names the server, the application, and the stream key: rtmp://host[:port]/app/key, the port 1935 by default and 443 for rtmps, which runs over TLS. A query belongs to the key, as the services that sign keys with one expect.

goav.URI publishes. The destination takes H.264, HEVC, AV1, and VP9 video and AAC, Opus, and FLAC audio packets, and encodes frames to H.264 and AAC, which every server reads. When the run opens it, it connects, offers the Enhanced RTMP codecs, and publishes; a server that answers with the codecs it takes refuses the others with ErrCodecRefused, and one that answers with none is sent what the streams carry. It publishes live: a file routed to it plays at its media time.

goav.URIInput plays a live stream: FLV over RTMP, which the runtime demuxes, Enhanced RTMP included. A publisher that stops ends it with ErrStreamEnded, which goav.Reconnect recovers from, and a read that waits 30s for media fails. A refused connect, publish, or play is a *StatusError.

goav reports the URL with its stream key redacted, as it does userinfo and secret query values; only this scheme sees it.

Types

type Option

type Option func(*config)

Option configures RTMP and Listen.

func WithTLSConfig

func WithTLSConfig(c *tls.Config) Option

WithTLSConfig sets the TLS configuration: the roots and server name an rtmps client trusts (the system's by default), or the certificates that make Listen serve rtmps.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is an RTMP ingest: it accepts publishers (OBS, ffmpeg, another goav task publishing rtmp://) and hands each to the live input of its stream. Only the streams an Input names are taken, so the stream key is the publisher's credential.

func Listen

func Listen(addr string, options ...Option) (*Server, error)

Listen accepts RTMP publishers on addr, or rtmps ones when WithTLSConfig gives it certificates. Close stops it.

The server answers the signed and the simple handshake, connect with the Enhanced RTMP codecs and multitrack goav reads, and createStream and publish for the streams an Input names; it refuses a play, and a publish to a stream no Input names or another publisher holds, with NetStream.Publish.BadName.

func (*Server) Addr

func (s *Server) Addr() net.Addr

Addr is the address the server listens on.

func (*Server) Close

func (s *Server) Close() error

Close stops accepting, ends every publish, and wakes the inputs waiting for one.

func (*Server) Input

func (s *Server) Input(stream string) provider.Input

Input is the live input of the stream app/key a publisher sends to rtmp://host/app/key (its query ignored). Each open waits for the next publisher and reads it until it stops, which ends the input with ErrStreamEnded; goav.Reconnect waits for the one after.

type StatusError

type StatusError struct {
	Command     string
	Code        string
	Description string
}

StatusError is a server's refusal: the command it answered with _error or an error-level onStatus, and the code and description it gave, the stream key replaced wherever the description repeats it.

func (*StatusError) Error

func (e *StatusError) Error() string

Jump to

Keyboard shortcuts

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