Documentation
¶
Overview ¶
Package m2ts demultiplexes the video elementary streams of an MPEG-2 transport stream (including Blu-ray .m2ts with 192-byte packets) and pairs the base view (AVC) and dependent view (MVC) access units.
Index ¶
Constants ¶
const ( PIDBaseView = 0x1011 PIDDepView = 0x1012 )
Blu-ray PIDs of the primary video and its MVC dependent view.
const ( TypeMPEG2Video = 0x02 TypeAVC = 0x1b TypeMVC = 0x20 TypeHEVC = 0x24 TypeVC1 = 0xea TypeLPCM = 0x80 TypeAC3 = 0x81 TypeDTS = 0x82 TypeTrueHD = 0x83 TypeEAC3 = 0x84 TypeDTSHDHR = 0x85 TypeDTSHDMA = 0x86 TypeEAC3Sec = 0xa1 TypeDTSSec = 0xa2 TypePGS = 0x90 TypeIGS = 0x91 TypeText = 0x92 )
Stream types of a Blu-ray program (stream_type in the PMT).
Variables ¶
var ErrEncrypted = errors.New("m2ts: the stream is encrypted (AACS): only a decrypted disc can be read")
ErrEncrypted is a Blu-ray stream still under AACS: its aligned units' copy permission bits are set and all but their first 16 bytes scrambled. Only decrypted discs can be read.
Functions ¶
Types ¶
type AccessUnit ¶
type AccessUnit struct {
Base []byte // base view NAL units (AVC)
Dep []byte // dependent view NAL units (MVC), may be empty
PTS int64 // presentation time stamp (90 kHz), -1 if absent
DTS int64
}
AccessUnit is one paired access unit in Annex B format.
type Demuxer ¶
type Demuxer struct {
// contains filtered or unexported fields
}
Demuxer extracts paired access units from a transport stream.
func NewDemuxer ¶
NewDemuxer returns a demuxer for the Blu-ray video PIDs.
func NewDemuxerPIDs ¶
NewDemuxerPIDs returns a demuxer for the given base and dependent PIDs.
func (*Demuxer) Next ¶
func (d *Demuxer) Next() (AccessUnit, error)
Next returns the next access unit. The returned buffers may be passed to Recycle once consumed.
func (*Demuxer) Recycle ¶
func (d *Demuxer) Recycle(au *AccessUnit)
Recycle returns the buffers of an access unit for reuse.
type PES ¶
type PES struct {
PID uint16
StreamID byte
PTS, DTS int64 // 90 kHz, -1 when absent
Payload []byte
}
PES is one packetised elementary stream packet, with its header removed.
type Program ¶
type Program struct {
Number uint16
PCRPID uint16
Version byte
// Info is the raw program_info descriptor loop.
Info []byte
Streams []ProgramStream
}
Program is the content of the PMT.
type ProgramStream ¶
type ProgramStream struct {
PID uint16
Type byte
// Lang is the ISO 639-2 code from the language descriptor, if any.
Lang string
// Descriptors is the stream's raw descriptor loop, for rewriting a PMT.
Descriptors []byte
}
ProgramStream is one elementary stream the PMT announces.
type Reader ¶
type Reader struct {
// Packets counts the transport packets read.
Packets int64
// contains filtered or unexported fields
}
Reader splits a transport stream into PES packets, for every PID or a chosen set, and reads the program tables on the way.
func (*Reader) Next ¶
Next returns the next PES packet. Packets of the same PID come in stream order; across PIDs in the order they complete. The payload is owned by the caller.
func (*Reader) ReadProgram ¶
ReadProgram reads packets until a PMT has been seen, keeping any PES packets completed meanwhile for Next. A file interleaving two clips (an SSIF) carries a PMT per clip; the program grows as later ones are read, so a caller wanting every stream reads on and asks Program again.