Documentation
¶
Overview ¶
Package mpegts implements MPEG-2 Transport Stream readers and writers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessUnit ¶
type AccessUnit struct {
Track *Track
// PTS and DTS are in 90 kHz ticks, unwrapped from the 33-bit wire
// representation into monotonically increasing values. DTS equals PTS
// when the stream carries no separate DTS.
PTS, DTS int64
// RandomAccess reports the random_access_indicator of the packet that
// started this access unit (set by muxers on IDR/IRAP pictures).
RandomAccess bool
// Data is the access unit in Annex-B format. It is only valid until
// the next call to NextAccessUnit; copy it to retain it.
Data []byte
}
AccessUnit is one coded video frame extracted from the transport stream.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader demuxes an MPEG-2 Transport Stream from an io.Reader. It selects the first program advertised in the PAT and exposes its supported video streams as tracks.
func NewReader ¶
func NewReader(src io.Reader, opts ...ReaderOption) (*Reader, error)
NewReader creates a Reader and consumes packets until the PAT and PMT have been parsed, so Tracks is available immediately after it returns.
func (*Reader) NextAccessUnit ¶
func (r *Reader) NextAccessUnit() (*AccessUnit, error)
NextAccessUnit returns the next complete access unit in stream order. It returns io.EOF once the input and all buffered data are exhausted.
type ReaderOption ¶
ReaderOption configures a Reader.
func WithMaxAccessUnitSize ¶
func WithMaxAccessUnitSize(n int) ReaderOption
WithMaxAccessUnitSize bounds the memory used to reassemble one access unit. Larger units are dropped and reading resynchronizes. Default 4 MiB.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer muxes video access units into a single-program MPEG-2 Transport Stream. The PCR is carried on the first configured track's PID.
func NewWriter ¶
func NewWriter(dst io.Writer, opts ...WriterOption) (*Writer, error)
NewWriter creates a Writer emitting to dst. At least one track option is required.
func (*Writer) Close ¶
Close closes the underlying writer when it implements io.Closer. A transport stream needs no trailer.
type WriterOption ¶
WriterOption configures a Writer.
func WithH264Track ¶
func WithH264Track(pid uint16) WriterOption
WithH264Track adds an H.264 elementary stream on the given PID.
func WithH265Track ¶
func WithH265Track(pid uint16) WriterOption
WithH265Track adds an H.265 elementary stream on the given PID.