Documentation ¶
Overview ¶
Package m2ts is parsing M2TS files followings specs: https://en.wikipedia.org/wiki/MPEG_transport_stream https://en.wikipedia.org/wiki/Packetized_elementary_stream https://en.wikipedia.org/wiki/Program-specific_information
Index ¶
Constants ¶
const ( MDPMDate = 0x18 MDPMTime = 0x19 MDPMGPSLatitude = 0xb2 MDPMGPSLongitude = 0xb6 MDPMMake = 0xe0 MDPMModel = 0xe4 )
Variables ¶
This section is empty.
Functions ¶
func UpdateDetailsFromMDPM ¶
func UpdateDetailsFromMDPM(payload []byte, details *backupmodel.MediaDetails) map[byte][]byte
UpdateDetailsFromMDPM find MDPM UUID followed by 'MDPM' marker, and reads what's following as key-value map inspired by https://metacpan.org/release/EXIFTOOL/Image-ExifTool-8.90/source/lib/Image/ExifTool/H264.pm
Types ¶
type PES ¶
type PES []byte
func (PES) PESLength ¶
PESLength is the number of bytes the PES header is. The Following bytes are the stream payload. Example:
00000000 00 00 01 e0 00 00 85 c0 0a 31 00 07 13 81 11 00 |.........1......| 00000010 05 bf 21 00 00 00 01 09 10 00 00 00 01 27 64 00 |..!..........'d.| ^ Video Stream starts here
type PSI ¶
type PSI []byte
PSI is a wrapper to decode a PSI table
func (PSI) AssociationTable ¶
AssociationTable reads PAT table content to extract association table
func (PSI) UpdateProgramMap ¶
func (p PSI) UpdateProgramMap(programs map[uint16]ProgramNumber) map[uint16]ProgramNumber
UpdateProgramMap reads PMT table to update program map
type Packet ¶
type Packet []byte
func (Packet) PesPsiDvbPayload ¶
PesPsiDvbPayload returns TRUE when the Payload is PES, PSI, or DVB
type Parser ¶
type Parser struct {
Debug bool // Debug can be set to true to print in the console payload dumps and read metadata.
}
func (*Parser) ReadDetails ¶
func (p *Parser) ReadDetails(reader io.Reader, options backupmodel.DetailsReaderOptions) (*backupmodel.MediaDetails, error)
ReadDetails unmux M2TS (MTS) file, with h264 support, to collect the Make, Model, and DateTime of the video flux. Example: 00 00 00 00 | 47 40 00 10 | 00 00 b0 11 00 00 c1 00 00 00 00 e0 1f 00 01 e1 00 23 5a ab 82 ffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff
M2TS HEADER-- PAT HEADER- SECTION------- #1--------- #2--------- CRC--------
00 00 06 9c | 47 | 41 00 10 | 00 02 b0 3e | 00 01 c1 00 00 | f0 01 f0 0c | 05 04 48 44 | 4d 56 88 04 | 0f ff fc fc | 1b f0 11 f0 0a | 05 08 48 44 4d 56 ff 1b 43 3f | 81 f1 00 f0 0c | 05 04 41 43 2d 33 81 04 04 30 04 00 90 f2 00 f0 00 | 0c d3 f4 dc
M2TS HEADER--- PAT HEADER-- SECTION------- PMT-------- | Program Descriptors ------------------- #1 1011=>1b----------------------------------- CRC--------
func (*Parser) Supports ¶
func (p *Parser) Supports(media backupmodel.FoundMedia, mediaType backupmodel.MediaType) bool
type ProgramNumber ¶
type ProgramNumber uint8
ProgramNumber is the code as defined in https://en.wikipedia.org/wiki/Program-specific_information#Program_and_Elementary_Stream_Descriptor_Tags
const ( PIDMask = 0x1fff // PIDMask can be used to get PID from uint16: last 13 bits ProgramNumberH264 ProgramNumber = 0x1b // ProgramNumberH264 is a H264 video stream )