avformat

package
v2.4.2 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: AGPL-3.0 Imports: 7 Imported by: 17

Documentation

Index

Constants

View Source
const (
	// FLV Tag Type
	FLV_TAG_TYPE_AUDIO  = 0x08
	FLV_TAG_TYPE_VIDEO  = 0x09
	FLV_TAG_TYPE_SCRIPT = 0x12
)
View Source
const (
	// NALU Type
	NALU_Unspecified           = 0
	NALU_Non_IDR_Picture       = 1
	NALU_Data_Partition_A      = 2
	NALU_Data_Partition_B      = 3
	NALU_Data_Partition_C      = 4
	NALU_IDR_Picture           = 5
	NALU_SEI                   = 6
	NALU_SPS                   = 7
	NALU_PPS                   = 8
	NALU_Access_Unit_Delimiter = 9
	NALU_Sequence_End          = 10
	NALU_Stream_End            = 11
	NALU_Filler_Data           = 12
	NALU_SPS_Extension         = 13
	NALU_Prefix                = 14
	NALU_SPS_Subset            = 15
	NALU_DPS                   = 16
	NALU_Reserved1             = 17
	NALU_Reserved2             = 18
	NALU_Not_Auxiliary_Coded   = 19
	NALU_Coded_Slice_Extension = 20
	NALU_Reserved3             = 21
	NALU_Reserved4             = 22
	NALU_Reserved5             = 23
	NALU_STAPA                 = 24
	NALU_FUA                   = 28
)
View Source
const (
	ADTS_HEADER_SIZE = 7
)

Variables

View Source
var (
	// 音频格式. 4 bit
	SoundFormat = map[byte]string{
		0:  "Linear PCM, platform endian",
		1:  "ADPCM",
		2:  "MP3",
		3:  "Linear PCM, little endian",
		4:  "Nellymoser 16kHz mono",
		5:  "Nellymoser 8kHz mono",
		6:  "Nellymoser",
		7:  "G.711 A-law logarithmic PCM",
		8:  "G.711 mu-law logarithmic PCM",
		9:  "reserved",
		10: "AAC",
		11: "Speex",
		14: "MP3 8Khz",
		15: "Device-specific sound"}

	// 采样频率. 2 bit
	SoundRate = map[byte]int{
		0: 5500,
		1: 11000,
		2: 22000,
		3: 44000}

	// 量化精度. 1 bit
	SoundSize = map[byte]string{
		0: "8Bit",
		1: "16Bit"}

	// 音频类型. 1bit
	SoundType = map[byte]string{
		0: "Mono",
		1: "Stereo"}

	// 视频帧类型. 4bit
	FrameType = map[byte]string{
		1: "keyframe (for AVC, a seekable frame)",
		2: "inter frame (for AVC, a non-seekable frame)",
		3: "disposable inter frame (H.263 only)",
		4: "generated keyframe (reserved for server use only)",
		5: "video info/command frame"}

	// 视频编码类型. 4bit
	CodecID = map[byte]string{
		1:  "JPEG (currently unused)",
		2:  "Sorenson H.263",
		3:  "Screen video",
		4:  "On2 VP6",
		5:  "On2 VP6 with alpha channel",
		6:  "Screen video version 2",
		7:  "AVC",
		12: "H265"}
)
View Source
var (
	NALU_AUD_BYTE   = []byte{0x00, 0x00, 0x00, 0x01, 0x09, 0xF0}
	NALU_Delimiter1 = []byte{0x00, 0x00, 0x01}
	NALU_Delimiter2 = []byte{0x00, 0x00, 0x00, 0x01}
	// 0x17 keyframe  7:AVC
	// 0x00 AVC sequence header
	// 0x00 0x00 0x00
	// 0x01 configurationVersion
	// 0x42 AVCProfileIndication
	// 0x00 profile_compatibility
	// 0x1E AVCLevelIndication
	// 0xFF lengthSizeMinusOne
	RTMP_AVC_HEAD         = []byte{0x17, 0x00, 0x00, 0x00, 0x00, 0x01, 0x42, 0x00, 0x1E, 0xFF}
	RTMP_KEYFRAME_HEAD    = []byte{0x17, 0x01, 0x00, 0x00, 0x00}
	RTMP_NORMALFRAME_HEAD = []byte{0x27, 0x01, 0x00, 0x00, 0x00}
)
View Source
var ErrDecconfInvalid = errors.New("decode error")
func (p *AVCDecoderConfigurationRecord) Marshal(b []byte) (n int) {
	b[0] = 1
	b[1] = p.AVCProfileIndication
	b[2] = p.ProfileCompatibility
	b[3] = p.AVCLevelIndication
	b[4] = p.LengthSizeMinusOne | 0xfc
	b[5] = uint8(len(p.SPS)) | 0xe0
	n += 6

	for _, sps := range p.SPS {
		pio.PutU16BE(b[n:], uint16(len(sps)))
		n += 2
		copy(b[n:], sps)
		n += len(sps)
	}

	b[n] = uint8(len(p.PPS))
	n++

	for _, pps := range p.PPS {
		pio.PutU16BE(b[n:], uint16(len(pps)))
		n += 2
		copy(b[n:], pps)
		n += len(pps)
	}

	return
}
View Source
var FLVHeader = []byte{0x46, 0x4c, 0x56, 0x01, 0x05, 0, 0, 0, 9, 0, 0, 0, 0}
View Source
var NALU_SEI_BYTE []byte
View Source
var SamplingFrequencies = [...]int{96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350, 0, 0, 0}

Profile:

0: Main profile 1: Low Complexity profile(LC) 2: Scalable Sampling Rate profile(SSR) 3: Reserved

View Source
var (
	SendPacketPool = &sync.Pool{
		New: func() interface{} {
			return new(SendPacket)
		},
	}
)

Functions

func ADTSToAudioSpecificConfig

func ADTSToAudioSpecificConfig(data []byte) []byte

所以说number_of_raw_data_blocks_in_frame == 0 表示说ADTS帧中有一个AAC数据块并不是说没有。(一个AAC原始帧包含一段时间内1024个采样及相关数据)

func ReadFLVTag

func ReadFLVTag(r io.Reader) (t byte, timestamp uint32, payload []byte, err error)

func ReadPPS

func ReadPPS(w io.Writer)

func SplitH264 added in v2.2.0

func SplitH264(payload []byte) (nalus [][]byte)

SplitH264 以0x00000001分割H264裸数据

func WriteFLVTag

func WriteFLVTag(w io.Writer, tag *SendPacket) (err error)

Types

type ADTS

type ADTS struct {
	ADTSFixedHeader
	ADTSVariableHeader
}

ISO/IEC 13838-7 20(25)/page

Advanced Audio Coding

AudioDataTransportStream

func AudioSpecificConfigToADTS

func AudioSpecificConfigToADTS(asc AudioSpecificConfig, rawDataLength int) (adts ADTS, adtsByte []byte, err error)

type ADTSFixedHeader

type ADTSFixedHeader struct {
	SyncWord               uint16 // 12 bits The bit string ‘1111 1111 1111’. See ISO/IEC 11172-3,subclause 2.4.2.3 (Table 8)
	ID                     byte   // 1 bit MPEG identifier, set to ‘1’. See ISO/IEC 11172-3,subclause 2.4.2.3 (Table 8)
	Layer                  byte   // 2 bits Indicates which layer is used. Set to ‘00’. See ISO/IEC 11172-3,subclause 2.4.2.3 (Table 8)
	ProtectionAbsent       byte   // 1 bit Indicates whether error_check() data is present or not. Same assyntax element ‘protection_bit’ in ISO/IEC 11172-3,subclause 2.4.1 and 2.4.2 (Table 8)
	Profile                byte   // 2 bits profile used. See clause 2 (Table 8)
	SamplingFrequencyIndex byte   // 4 bits indicates the sampling frequency used according to the followingtable (Table 8)
	PrivateBit             byte   // 1 bit see ISO/IEC 11172-3, subclause 2.4.2.3 (Table 8)
	ChannelConfiguration   byte   // 3 bits indicates the channel configuration used. Ifchannel_configuration is greater than 0, the channelconfiguration is given in Table 42, see subclause 8.5.3.1. Ifchannel_configuration equals 0, the channel configuration is notspecified in the header and must be given by aprogram_config_element() following as first syntactic element inthe first raw_data_block() after the header (seesubclause 8.5.3.2), or by the implicit configuration (seesubclause 8.5.3.3) or must be known in the application (Table 8)
	OriginalCopy           byte   // 1 bit see ISO/IEC 11172-3, definition of data element copyright
	Home                   byte   // 1 bit see ISO/IEC 11172-3, definition of data element original/copy
}

28 bits

type ADTSVariableHeader

type ADTSVariableHeader struct {
	CopyrightIdentificationBit   byte   // 1 bit One bit of the 72-bit copyright identification field (seecopyright_id above). The bits of this field are transmitted frame by frame; the first bit is indicated by the copyright_identification_start bit set to ‘1’. The field consists of an 8-bit copyright_identifier, followed by a 64-bit copyright_number.The copyright identifier is given by a Registration Authority as designated by SC29. The copyright_number is a value which identifies uniquely the copyrighted material. See ISO/IEC 13818-3, subclause 2.5.2.13 (Table 9)
	CopyrightIdentificationStart byte   // 1 bit One bit to indicate that the copyright_identification_bit in this audio frame is the first bit of the 72-bit copyright identification. If no copyright identification is transmitted, this bit should be kept '0'.'0' no start of copyright identification in this audio frame '1' start of copyright identification in this audio frame See ISO/IEC 13818-3, subclause 2.5.2.13 (Table 9)
	AACFrameLength               uint16 // 13 bits Length of the frame including headers and error_check in bytes(Table 9)
	ADTSBufferFullness           uint16 // 11 bits state of the bit reservoir in the course of encoding the ADTS frame, up to and including the first raw_data_block() and the optionally following adts_raw_data_block_error_check(). It is transmitted as the number of available bits in the bit reservoir divided by NCC divided by 32 and truncated to an integer value (Table 9). A value of hexadecimal 7FF signals that the bitstream is a variable rate bitstream. In this case, buffer fullness is not applicable
	NumberOfRawDataBlockInFrame  byte   // 2 bits Number of raw_data_block()’s that are multiplexed in the adts_frame() is equal to number_of_raw_data_blocks_in_frame + 1. The minimum value is 0 indicating 1 raw_data_block()(Table 9)
}

28 bits

type AVCDecoderConfigurationRecord

type AVCDecoderConfigurationRecord struct {
	ConfigurationVersion       byte // 8 bits Version
	AVCProfileIndication       byte // 8 bits
	ProfileCompatibility       byte // 8 bits
	AVCLevelIndication         byte // 8 bits
	Reserved1                  byte // 6 bits
	LengthSizeMinusOne         byte // 2 bits 非常重要,每个NALU包前面都(lengthSizeMinusOne & 3)+1个字节的NAL包长度描述
	Reserved2                  byte // 3 bits
	NumOfSequenceParameterSets byte // 5 bits SPS 的个数,计算方法是 numOfSequenceParameterSets & 0x1F
	NumOfPictureParameterSets  byte // 8 bits PPS 的个数

	SequenceParameterSetLength  uint16 // 16 byte SPS Length
	SequenceParameterSetNALUnit []byte // n byte  SPS
	PictureParameterSetLength   uint16 // 16 byte PPS Length
	PictureParameterSetNALUnit  []byte // n byte  PPS
}

func (*AVCDecoderConfigurationRecord) Unmarshal

func (p *AVCDecoderConfigurationRecord) Unmarshal(b []byte) (n int, err error)

type AVPacket

type AVPacket struct {
	Timestamp  uint32
	Type       byte //8 audio,9 video
	IsSequence bool //序列帧
	IsKeyFrame bool //是否为关键帧
	Payload    []byte
	Number     int //编号,audio和video独立编号
}

Video or Audio

func NewAVPacket

func NewAVPacket(avType byte) (p *AVPacket)

func (*AVPacket) ADTS2ASC

func (av *AVPacket) ADTS2ASC() (tagPacket *AVPacket)

func (AVPacket) Clone

func (av AVPacket) Clone() *AVPacket

func (*AVPacket) VideoFrameType

func (av *AVPacket) VideoFrameType() byte

type AdditionalMetadataContainerBox

type AdditionalMetadataContainerBox struct {
	MP4BoxHeader // standard header
}

ISO_IEC_14496-12_2012.pdf Page/87

Box Type: meco Container: File, Movie Box (‘moov’), or Track Box (‘trak’) Mandatory: No Quantity: Zero or one

type AudioSampleEntry

type AudioSampleEntry struct {
	Reserved1    [2]uint32 // 32 bits array,
	ChannelCount uint16    // 16 bits, is the number of channels such as 1 (mono) or 2 (stereo)
	SampleSize   uint16    // 16 bits, is in bits, and takes the default value of 16
	PreDefined   uint16    // 16 bits,
	Reserved2    uint16    // 16 bits,
	SampleRate   uint32    // 32 bits, is the sampling rate expressed as a 16.16 fixed-point number (hi.lo)
}

Audio Sequences

type AudioSampleGroupEntry

type AudioSampleGroupEntry struct{}

type AudioSpecificConfig

type AudioSpecificConfig struct {
	AudioObjectType        byte // 5 bits
	SamplingFrequencyIndex byte // 4 bits
	ChannelConfiguration   byte // 4 bits
	GASpecificConfig
}

type AuxInfo

type AuxInfo struct {
	AuxInfoType          uint32 // 32 bits,
	AuxInfoTypeParameter uint32 // 32 bits,
}

type BinaryXMLBox

type BinaryXMLBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	Data []uint8 // 8 bits array,
}

type BitRateBox

type BitRateBox struct {
	MP4BoxHeader // standard header

	BufferSizeDB uint32 // 32 bits, gives the size of the decoding buffer for the elementary stream in bytes.
	MaxBitrate   uint32 // 32 bits, gives the maximum rate in bits/second over any window of one second.
	AvgBitrate   uint32 // 32 bits, gives the average rate in bits/second over the entire presentation.
}

Box Types: btrt

type ChunkLargeOffsetBox

type ChunkLargeOffsetBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	EntryCount  uint32   // 32 bits, is an integer that gives the number of entries in the following table
	ChunkOffset []uint64 // 64 bits array, entry count elements.
}

Box Type: co64

type ChunkOffsetBox

type ChunkOffsetBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	EntryCount  uint32   // 32 bits, is an integer that gives the number of entries in the following table
	ChunkOffset []uint32 // 32 bits array, entry count elements.
}

ISO_IEC_14496-12_2012.pdf Page/59

Box Type: stco, co64 Container: Sample Table Box (‘stbl’) Mandatory: Yes Quantity: Exactly one variant must be present

type CleanApertureBox

type CleanApertureBox struct {
	MP4BoxHeader // standard header

	CleanApertureWidthN  uint32 // 32 bits, a fractional number which defines the exact clean aperture width, in counted pixels, of the video image
	CleanApertureWidthD  uint32 // 32 bits, a fractional number which defines the exact clean aperture width, in counted pixels, of the video image
	CleanApertureHeightN uint32 // 32 bits, a fractional number which defines the exact clean aperture height, in counted pixels, of the video image
	CleanApertureHeightD uint32 // 32 bits, a fractional number which defines the exact clean aperture height, in counted pixels, of the video image
	HorizOffN            uint32 // 32 bits, a fractional number which defines the horizontal offset of clean aperture centre minus (width-1)/2. Typically 0
	HorizOffD            uint32 // 32 bits, a fractional number which defines the horizontal offset of clean aperture centre minus (width-1)/2. Typically 0
	VertOffN             uint32 // 32 bits, a fractional number which defines the vertical offset of clean aperture centre minus (height-1)/2. Typically 0
	VertOffD             uint32 // 32 bits, a fractional number which defines the vertical offset of clean aperture centre minus (height-1)/2. Typically 0
}

Box Types: clap Visual Sequences

type ColourInformationBox

type ColourInformationBox struct {
	MP4BoxHeader // standard header

	ColourType uint32 // 32 bits, an indication of the type of colour information supplied. For colour_type ‘nclx’: these fields are exactly the four bytes defined for PTM_COLOR_INFO( ) in A.7.2 of ISO/IEC 29199-2 but note that the full range flag is here in a different bit position
}

Box Types: colr

type CompactSampleSizeBox

type CompactSampleSizeBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	Reserved    [3]uint8    // 24 bits,
	FieldSize   uint8       // 8 bits, is an integer specifying the size in bits of the entries in the following table; it shall take the value 4, 8 or 16. If the value 4 is used, then each byte contains two values: entry[i]<<4 + entry[i+1]; if the sizes do not fill an integral number of bytes, the last byte is padded with zeros.
	SampleCount uint32      // 32 bits,  is an integer that gives the number of entries in the following table
	EntrySize   interface{} //
}

Box Type: stz2

type CompositionOffsetBox

type CompositionOffsetBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	EntryCount uint32                   // 32 bits, is an integer that gives the number of entries in the following table
	Table      []CompositionOffsetTable // Composition Offset Table, EntryCount elements.
}

ISO_IEC_14496-12_2012.pdf Page/49

Box Type: ctts Container: Sample Table Box (‘stbl’) Mandatory: No Quantity: Zero or one

type CompositionOffsetTable

type CompositionOffsetTable struct {
	SampleCount  uint32      // 32 bits, is an integer that counts the number of consecutive samples that have the given offset.
	SampleOffset interface{} // int32 or uint32, is an integer that gives the offset between CT and DT, such that CT(n) = DT(n) + CTTS(n).
}

type CompositionToDecodeBox

type CompositionToDecodeBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	CompositionToDTSShift        int32 // 32 bits, signed, if this value is added to the composition times (as calculated by the CTS offsets from the DTS), then for all samples, their CTS is guaranteed to be greater than or equal to their DTS, and the buffer model implied by the indicated profile/level will be honoured; if leastDecodeToDisplayDelta is positive or zero, this field can be 0; otherwise it should be at least (- leastDecodeToDisplayDelta)
	LeastDecodeToDisplayDelta    int32 // 32 bits, signed, the smallest composition offset in the CompositionTimeToSample box in this track
	GreatestDecodeToDisplayDelta int32 // 32 bits, signed, the largest composition offset in the CompositionTimeToSample box in this track
	CompositionStartTime         int32 // 32 bits, signed, the smallest computed composition time (CTS) for any sample in the media of this track
	CompositionEndTime           int32 // 32 bits, signed, the composition time plus the composition duration, of the sample with the largest computed composition time (CTS) in the media of this track; if this field takes the value 0, the composition end time is unknown.
}

ISO_IEC_14496-12_2012.pdf Page/50

Box Type: cslg Container: Sample Table Box (‘stbl’) Mandatory: No Quantity: Zero or one

type CopyrightBox

type CopyrightBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	Pad      byte    // 1 bit,
	Language [2]byte // 15 bits, declares the language code for the following text. See ISO 639-2/T for the set of three character codes. Each character is packed as the difference between its ASCII value and 0x60. The code is confined to being three lower-case letters, so these values are strictly positive.
	Notice   string  // string, is a null-terminated string in either UTF-8 or UTF-16 characters, giving a copyright notice. If UTF- 16 is used, the string shall start with the BYTE ORDER MARK (0xFEFF), to distinguish it from a UTF- 8 string. This mark does not form part of the final string.
}

ISO_IEC_14496-12_2012.pdf Page/78

Box Type: cprt Container: User data box (‘udta’) Mandatory: No Quantity: Zero or more

The Copyright box contains a copyright declaration which applies to the entire presentation, when contained within the Movie Box, or, when contained in a track, to that entire track. There may be multiple copyright boxes using different language codes.

type DataEntryUrlBox

type DataEntryUrlBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	Location string // string,
}

type DataEntryUrnBox

type DataEntryUrnBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	Name     string // string,
	Location string // string,
}

type DataInformationBox

type DataInformationBox struct {
	MP4BoxHeader // standard header
}

ISO_IEC_14496-12_2012.pdf Page/56

Box Type: dinf Container: Media Information Box ('minf') or Meta Box ('meta') Mandatory: Yes (required within 'minf' box) and No (optional within 'meta' box) Quantity: Exactly one

The data information box contains objects that declare the location of the media information in a track

type DataReferenceBox

type DataReferenceBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	EntryCount uint32      // 32 bits, is an integer that gives the number of entries in the following table
	DataEntry  interface{} // DataEntryUrlBox or DataEntryUrnBox.
}

-------------------------------------------------------------------------------------------------------

ISO_IEC_14496-12_2012.pdf Page/56

Box Types: url, urn, dref Container: Data Information Box ('dinf') Mandatory: Yes Quantity: Exactly one

type DegradationPriorityBox

type DegradationPriorityBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	Priority []uint16 // 16 bits array, sample count elements, is integer specifying the degradation priority for each sample.
}

ISO_IEC_14496-12_2012.pdf Page/46

Box Type: stdp Container: Sample Table Box (‘stbl’). Mandatory: No. Quantity: Zero or one.

This box contains the degradation priority of each sample. The values are stored in the table, one for each sample. The size of the table, sample_count is taken from the sample_count in the Sample Size Box ('stsz'). Specifications derived from this define the exact meaning and acceptable range of the priority field.

type EditBox

type EditBox struct {
	MP4BoxHeader // standard header
}

ISO_IEC_14496-12_2012.pdf Page/54

Box Type: edts Container: Track Box (‘trak’) Mandatory: No Quantity: Zero or one

type EditListBox

type EditListBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	EntryCount uint32          // 32 bits, is an integer that gives the number of entries in the following table
	Tables     []EditListTable // Edit List Table
}

ISO_IEC_14496-12_2012.pdf Page/54

Box Type: elst Container: Edit Box (‘edts’) Mandatory: No Quantity: Zero or one

type EditListTable

type EditListTable struct {
	SegmentDuration   interface{} // uint64 or uint32, is an integer that specifies the duration of this edit segment in units of the timescale in the Movie Header Box
	MediaTime         interface{} // uint64 or uint32, is an integer containing the starting time within the media of this edit segment (in media time scale units, in composition time). If this field is set to –1, it is an empty edit. The last edit in a track shall never be an empty edit. Any difference between the duration in the Movie Header Box, and the track’s duration is expressed as an implicit empty edit at the end.
	MediaRateInteger  int16       // 16 bits,
	MediaRateFraction int16       // 16 bits,
}

type FDItemInformationBox

type FDItemInformationBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	EntryCount uint16            // 16 bits,
	PE         []PartitionEntry  // EntryCount elements.
	FDSGB      FDSessionGroupBox // optional
	GidToNameB GroupIdToNameBox  // optional
}

ISO_IEC_14496-12_2012.pdf Page/95

Box Type: fiin Container: Meta Box (‘meta’) Mandatory: No Quantity: Zero or one

The FD item information box is optional, although it is mandatory for files using FD hint tracks. It provides information on the partitioning of source files and how FD hint tracks are combined into FD sessions. Each partition entry provides details on a particular file partitioning, FEC encoding and associated File and FEC reservoirs. It is possible to provide multiple entries for one source file (identified by its item ID) if alternative FEC encoding schemes or partitionings are used in the file. All partition entries are implicitly numbered and the first entry has number 1.

type FDSessionGroupBox

type FDSessionGroupBox struct {
	MP4BoxHeader // standard header

	NumSessionGroups uint16                // 16 bits,
	Table            []FDSessionGroupTable // FD Session Group Table, NumSessionGroups elements.
}

ISO_IEC_14496-12_2012.pdf Page/97

Box Type: segr Container: FD Information Box (‘fiin’) Mandatory: No Quantity: Zero or One

type FDSessionGroupIDTable

type FDSessionGroupIDTable struct {
	GroupID uint32 // 32 bits
}

type FDSessionGroupTable

type FDSessionGroupTable struct {
	EntryCount                uint8                       // 8 bits,
	GIDTable                  []FDSessionGroupIDTable     // FDSession Group ID Table, EntryCount elements.
	NumChannelsInSessionGroup uint16                      // 16 bits
	HTIDTable                 []FDSessionHintTrackIDTable // FDSession Hint Track ID Table, NumChannelsInSessionGroup elements.
}

type FDSessionHintTrackIDTable

type FDSessionHintTrackIDTable struct {
	HintTrackID uint32 // 32 bits
}

type FECReservoirBox

type FECReservoirBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	EntryCount uint16              // 16 bits,
	Table      []FECReservoirTable // FEC Reservoir Table, EntryCount elements.
}

ISO_IEC_14496-12_2012.pdf Page/97

Box Type: fecr Container: Partition Entry (‘paen’) Mandatory: No Quantity: Zero or One

The FEC reservoir box associates the source file identified in the file partition box ('fpar') with FEC reservoirs stored as additional items. It contains a list that starts with the first FEC reservoir associated with the first source block of the source file and continues sequentially through the source blocks of the source file.

type FECReservoirTable

type FECReservoirTable struct {
	ItemID      uint16 // 16 bits, indicates the location of the FEC reservoir associated with a source block.
	SymbolCount uint32 // 32 bits, indicates the number of repair symbols contained in the FEC reservoir.
}

type FilePartitionBox

type FilePartitionBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	ItemID                     uint16               // 16 bits,
	PacketPayloadSize          uint16               // 16 bits,
	Reserved                   uint8                // 8 bits,
	FECEncodingID              uint8                // 8 bits,
	FECInstanceID              uint16               // 16 bits,
	MaxSourceBlockLength       uint16               // 16 bits,
	EncodingSymbolLength       uint16               // 16 bits,
	MaxNumberOfEncodingSymbols uint16               // 16 bits,
	SchemeSpecificInfo         string               // string,
	EntryCount                 uint16               // 16 bits,
	Tanble                     []FilePartitionTable //File Partition Table, EntryCount elements.
}

ISO_IEC_14496-12_2012.pdf Page/95

Box Type: fpar Container: Partition Entry (‘paen’) Mandatory: Yes Quantity: Exactly one

The File Partition box identifies the source file and provides a partitioning of that file into source blocks and symbols. Further information about the source file, e.g., filename, content location and group IDs, is contained in the Item Information box ('iinf'), where the Item Information entry corresponding to the item ID of the source file is of version 1 and includes a File Delivery Item Information Extension ('fdel').

type FilePartitionTable

type FilePartitionTable struct {
	BlockCount uint16 // 16 bits,
	BlockSize  uint32 // 32 bits,
}

type FileReservoirBox

type FileReservoirBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	EntryCount uint16               // 16 bits, gives the number of entries in the following list. An entry count here should match the total number or blocks in the corresponding file partition box.
	Table      []FileReservoirTable // EntryCount elements.
}

ISO_IEC_14496-12_2012.pdf Page/99

Box Type: fire Container: Partition Entry (‘paen’) Mandatory: No Quantity: Zero or One

The File reservoir box associates the source file identified in the file partition box ('fpar') with File reservoirs stored as additional items. It contains a list that starts with the first File reservoir associated with the first source block of the source file and continues sequentially through the source blocks of the source file.

type FileReservoirTable

type FileReservoirTable struct {
	ItemID      uint16 // 16 bits, indicates the location of the File reservoir associated with a source block.
	SymbolCount uint32 // 32 bits, indicates the number of source symbols contained in the File reservoir.
}

type FileTypeBox

type FileTypeBox struct {
	MP4BoxHeader // standard header

	MajorBrand       uint32   // 32 bits, is a brand identifier
	MinorVersion     uint32   // 32 bits, is an informative integer for the minor version of the major brand
	CompatibleBrands []uint32 // 32 bits array, is a list, to the end of the box, of brands
}

ISO_IEC_14496-12_2012.pdf Page/18

Box Type: ftyp Container: File Mandatory: Yes Quantity: Exactly one (but see below)

Each brand is a printable four-character code, registered with ISO, that identifies a precise specification

func NewFileTypeBox

func NewFileTypeBox() (box *FileTypeBox)

type FreeSpaceBox

type FreeSpaceBox struct {
	MP4BoxHeader // standard header

	Data []uint8 // 8 bits array,
}

ISO_IEC_14496-12_2012.pdf Page/29

Box Types: free, skip Container: File or other box Mandatory: No Quantity: Zero or more

The contents of a free-space box are irrelevant and may be ignored, or the object deleted, without affecting the presentation. (Care should be exercised when deleting the object, as this may invalidate the offsets used in the sample table, unless this object is after all the media data).

type GASpecificConfig

type GASpecificConfig struct {
	FrameLengthFlag    byte // 1 bit
	DependsOnCoreCoder byte // 1 bit
	ExtensionFlag      byte // 1 bit
}

type GroupIdToNameBox

type GroupIdToNameBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	EntryCount uint16             // 16 bits, gives the number of entries in the following list.
	Table      []GroupIdToNameBox // Group Id To Name Table, EntryCount elements.
}

ISO_IEC_14496-12_2012.pdf Page/98

Box Type: gitn Container: FD Information Box (‘fiin’) Mandatory: No Quantity: Zero or One

The Group ID to Name box associates file group names to file group IDs used in the version 1 item information entries in the item information box ('iinf').

type GroupIdToNameTable

type GroupIdToNameTable struct {
	GroupID   uint32 // 32 bits, indicates a file group.
	GroupName string // string, is a null-terminated string in UTF-8 characters containing a file group name.
}

type H264

type H264 struct {
	SPS []byte
	PPS []byte
}

func (*H264) Payload added in v2.1.4

func (h264 *H264) Payload(mtu int, payload []byte) (payloads [][]byte)

Payload 分包,用于RTP传输

type HandlerBox

type HandlerBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	PreDefined  uint32    // 32 bits,
	HandlerType uint32    // 32 bits, when present in a meta box, contains an appropriate value to indicate the format of the meta box contents. The value 'null' can be used in the primary meta box to indicate that it is merely being used to hold resources
	Reserved    [3]uint32 // 32 bits,
	Name        string    // string, is a null-terminated string in UTF-8 characters which gives a human-readable name for the track type (for debugging and inspection purposes).
}

ISO_IEC_14496-12_2012.pdf Page/37

Box Type: hdlr Container: Media Box ('mdia') or Meta Box ('meta') Mandatory: Yes Quantity: Exactly one

type HintMediaHeaderBox

type HintMediaHeaderBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	MaxPDUSize uint16 // 16 bits, gives the size in bytes of the largest PDU in this (hint) stream
	AvgPDUSize uint16 // 16 bits, gives the average size of a PDU over the entire presentation
	MaxBitrate uint32 // 32 bits, gives the maximum rate in bits/second over any window of one second
	AvgBitrate uint32 // 32 bits, gives the average rate in bits/second over the entire presentation
	Reserved   uint32 // 32 bits,
}

Box Types: hmhd The hint media header contains general information, independent of the protocol, for hint tracks. (A PDU is a Protocol Data Unit.)

type HintSampleEntry

type HintSampleEntry struct {
	Data []uint8 // 8 bits array,
}

type HintSampleGroupEntry

type HintSampleGroupEntry struct{}

type IPMPControlBox

type IPMPControlBox struct{}

type IndependentAndDisposableSamplesBox

type IndependentAndDisposableSamplesBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	Table []IndependentAndDisposableSamplesTable // Independent And Disposable Samples Table, sample count elements
}

ISO_IEC_14496-12_2012.pdf Page/53

Box Types: sdtp Container: Sample Table Box (‘stbl’) Mandatory: No Quantity: Zero or one

type IndependentAndDisposableSamplesTable

type IndependentAndDisposableSamplesTable struct {
	IsLeading           byte // 2 bits,
	SampleDependsOn     byte // 2 bits,
	SampleIsDependedOn  byte // 2 bits,
	SampleHasTedundancy byte // 2 bits,
}

type ItemDataBox

type ItemDataBox struct {
	MP4BoxHeader // standard header

	Data []byte // 8 bits array, is the contained meta data
}

ISO_IEC_14496-12_2012.pdf Page/90

Box Type: idat Container: Metadata box (‘meta’) Mandatory: No Quantity: Zero or one

This box contains the data of metadata items that use the construction method indicating that an item’s data extents are stored within this box.

type ItemInfoBox

type ItemInfoBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	EntryCount uint16          // 16 bits,
	ItemInfos  []ItemInfoEntry // EntryCount elements.
}

type ItemInfoEntry

type ItemInfoEntry struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	ItemID              uint16 // 16 bits
	ItemProtectionIndex uint16 // 16 bits
	ItemType            uint32 // 32 bits,
	ItemName            string // string,
	ContentType         string // string,
	ContentEncoding     string // string, optional
	ItemUriType         string // string,
	ExtensionType       uint32 // 32 bits, optional
	ItemInfoExtension          // optional
}

Box Type: infe

type ItemInfoExtension

type ItemInfoExtension struct {
}

type ItemLocationBox

type ItemLocationBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	OffsetSize     byte        // 4 bits,
	LengthSize     byte        // 4 bits,
	BaseOffsetSize byte        // 4 bits,
	IndexSize      byte        // 4 bits, if version == 1, index_size replace to reserved.
	ItemCount      uint16      // 16 bits,
	Table          interface{} // version == 1 -> ItemLocationTable1 , version == 2 -> ItemLocationTable2, ItemCount elements.
}

ISO_IEC_14496-12_2012.pdf Page/82

Box Type: iloc Container: Meta box (‘meta’) Mandatory: No Quantity: Zero or one

type ItemLocationExtentTable1

type ItemLocationExtentTable1 struct {
	ExtentIndex interface{} // unsigned int(index_size*8)
	ItemLocationExtentTable2
}

type ItemLocationExtentTable2

type ItemLocationExtentTable2 struct {
	ExtentOffset interface{} // unsigned int(offset_size*8)
	ExtentLength interface{} // unsigned int(length_size*8)
}

type ItemLocationTable1

type ItemLocationTable1 struct {
	ItemID             uint16                     // 16 bits,
	Reserved           uint16                     // 12 bits,
	ConstructionMethod byte                       // 4 bits,
	DataReferenceIndex uint16                     // 16 bits,
	BaseOffset         interface{}                // unsigned int(base_offset_size*8),
	ExtentCount        uint16                     // 16 bits,
	ExtentTable        []ItemLocationExtentTable1 // Item Location Extent Table1, ExtentCount elements.
}

type ItemLocationTable2

type ItemLocationTable2 struct {
	ItemID             uint16                     // 16 bits,
	DataReferenceIndex uint16                     // 16 bits,
	BaseOffset         interface{}                // unsigned int(base_offset_size*8),
	ExtentCount        uint16                     // 16 bits,
	ExtentTable        []ItemLocationExtentTable2 // Item Location Extent Table2, ExtentCount elements.
}

type ItemProtectionBox

type ItemProtectionBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	ProtectionCount uint16                // 16 bits,
	Table           []ItemProtectionTable // Item Protection Table, ProtectionCount elements.
}

ISO_IEC_14496-12_2012.pdf Page/85

Box Type: ipro Container: Meta box (‘meta’) Mandatory: No Quantity: Zero or one

The item protection box provides an array of item protection information, for use by the Item Information Box.

type ItemProtectionTable

type ItemProtectionTable struct {
	ProtectionInformation ProtectionSchemeInfoBox
}

type ItemReferenceBox

type ItemReferenceBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	SITRB []SingleItemTypeReferenceBox
}

ISO_IEC_14496-12_2012.pdf Page/91

Box Type: iref Container: Metadata box (‘meta’) Mandatory: No Quantity: Zero or one

The item reference box allows the linking of one item to others via typed references. All the references for one item of a specific type are collected into a single item type reference box, whose type is the reference type, and which has a ‘from item ID’ field indicating which item is linked. The items linked to are then represented by an array of ‘to item ID’s. All these single item type reference boxes are then collected into the item reference box. The reference types defined for the track reference box defined in 8.3.3 may be used here if appropriate, or other registered reference types.

type LevelAssignmentBox

type LevelAssignmentBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	LevelCount uint8                  // 8 bits, specifies the number of levels each fraction is grouped into. level_count shall be greater than or equal to 2.
	Table      []LevelAssignmentTable // Level Assignment Table, level count elements.
}

ISO_IEC_14496-12_2012.pdf Page/72

Box Type: leva Container: Movie Extends Box (`mvex’) Mandatory: No Quantity: Zero or one

type LevelAssignmentTable

type LevelAssignmentTable struct {
	TrackId        uint32 // 32 bits, for loop entry j specifies the track identifier of the track assigned to level j.
	PaddingFlag    byte   // 1 bit, equal to 1 indicates that a conforming fraction can be formed by concatenating any positive integer number of levels within a fraction and padding the last Media Data box by zero bytes up to the full size that is indicated in the header of the last Media Data box. The semantics of padding_flag equal to 0 are that this is not assured.
	AssignmentType byte   // 7 bits,
}

type MP4

type MP4 interface {
}

type MP4Body

type MP4Body struct{}

type MP4Box

type MP4Box interface {
	Header() *MP4Header
	Body() *MP4Body
}

type MP4BoxHeader

type MP4BoxHeader struct {
	BoxSize uint32 // 32 bits, is an integer that specifies the number of bytes in this box, including all its fields and contained boxes; if size is 1 then the actual size is in the field largesize; if size is 0, then this box is the last one in the file, and its contents extend to the end of the file (normally only used for a Media Data Box)
	BoxType uint32 // 32 bits, identifies the box type; standard boxes use a compact type, which is normally four printable characters, to permit ease of identification, and is shown so in the boxes below. User extensions use an extended type; in this case, the type field is set to ‘uuid’.
}

ISO_IEC_14496-12_2012.pdf Page/17

The standard boxes all use compact types (32-bit) and most boxes will use the compact (32-bit) size standard header

type MP4BoxLargeHeader

type MP4BoxLargeHeader struct {
	LargeSize uint64    // 64 bits
	UUIDs     [16]uint8 // 128 bits
}

ISO_IEC_14496-12_2012.pdf Page/17

Typically only the Media Data Box(es) need the 64-bit size. lagesize box header

type MP4FullBoxHeader

type MP4FullBoxHeader struct {
	Version uint8   // 8 bits, is an integer that specifies the version of this format of the box.
	Flags   [3]byte // 24 bits, is a map of flags
}

ISO_IEC_14496-12_2012.pdf Page/17

Many objects also contain a version number and flags field full box header

type MP4Header

type MP4Header struct {
	MP4BoxHeader
}

type MediaBox

type MediaBox struct {
	MP4BoxHeader // standard header

	Mhb MediaHeaderBox // the first child box(header box)
}

ISO_IEC_14496-12_2012.pdf Page/36

Box Type: mdia Container: Track Box ('trak') Mandatory: Yes Quantity: Exactly one

The media declaration container contains all the objects that declare information about the media data within a track.

type MediaDataBox

type MediaDataBox struct {
	MP4BoxHeader // standard header

	Data []byte // 8 bits array, is the contained media data.
}

ISO_IEC_14496-12_2012.pdf Page/29

Box Type: mdat Container: File Mandatory: No Quantity: Zero or more

type MediaHeaderBox

type MediaHeaderBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	CreationTime     interface{} // int64 or int32, is an integer that declares the creation time of the presentation (in seconds since midnight, Jan. 1, 1904, in UTC time)
	ModificationTime interface{} // int64 or int32, is an integer that declares the most recent time the presentation was modified (in seconds since midnight, Jan. 1, 1904, in UTC time)
	TimeScale        uint32      // 32 bits, is an integer that specifies the time-scale for the entire presentation; this is the number of time units that pass in one second. For example, a time coordinate system that measures time in sixtieths of a second has a time scale of 60.
	Duration         interface{} // int64 or int32, is an integer that declares length of the presentation (in the indicated timescale). This property is derived from the presentation's tracks: the value of this field corresponds to the duration of the longest track in the presentation. If the duration cannot be determined then duration is set to all 1s.
	Pad              byte        // 1 bit,
	Language         [2]byte     // 15 bits, unsigned int(5)[3], declares the language code for this media. See ISO 639-2/T for the set of three charactercodes. Each character is packed as the difference between its ASCII value and 0x60. Since the code is confined to being three lower-case letters, these values are strictly positive
	PreDefined       uint16      // 16 bits,
}

ISO_IEC_14496-12_2012.pdf Page/36

Box Type: mdhd Container: Media Box ('mdia') Mandatory: Yes Quantity: Exactly one

The media header declares overall information that is media-independent, and relevant to characteristics of the media in a track.

type MediaInformationBox

type MediaInformationBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header
}

ISO_IEC_14496-12_2012.pdf Page/38

Box Type: minf Container: Media Box ('mdia') Mandatory: Yes Quantity: Exactly one

This box contains all the objects that declare characteristic information of the media in the track.

type MediaInformationHeaderBoxes

type MediaInformationHeaderBoxes struct {
}

ISO_IEC_14496-12_2012.pdf Page/38

Box Types: vmhd, smhd, hmhd, nmhd Container: Media Information Box (‘minf’) Mandatory: Yes Quantity: Exactly one specific media header shall be present

There is a different media information header for each track type (corresponding to the media handler-type); the matching header shall be present, which may be one of those defined here, or one defined in a derived specification

type MetaBox

type MetaBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	PrimaryResource PrimaryItemBox     // optional
	FileLocations   DataInformationBox // optional
	ItemLocations   ItemLocationBox    // optional
	Protections     ItemProtectionBox  // optional
	ItemInfos       ItemInfoBox        // optional
	IPMPControl     IPMPControlBox     // optional
	ItemRefs        ItemReferenceBox   // optional
	ItemData        ItemDataBox        // optional

}

ISO_IEC_14496-12_2012.pdf Page/81

Box Type: meta Container: File, Movie Box (‘moov’), Track Box (‘trak’), or Additional Metadata Container Box (‘meco’) Mandatory: No Quantity: Zero or one (in File, ‘moov’, and ‘trak’), One or more (in ‘meco’)

type MetaDataSampleEntry

type MetaDataSampleEntry struct{}

type MetaboxRelationBox

type MetaboxRelationBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	FirstMetaboxHandlerType  uint32 // 32 bits, indicates the first meta box to be related.
	SecondMetaboxHandlerType uint32 // 32 bits,  indicates the second meta box to be related.
	MetaboxRelation          uint8  // 8 bits, indicates the relation between the two meta boxes.
}

ISO_IEC_14496-12_2012.pdf Page/88

Box Type: mere Container: Additional Metadata Container Box (‘meco’) Mandatory: No Quantity: Zero or more

The metabox relation box indicates a relation between two meta boxes at the same level, i.e., the top level of the file, the Movie Box, or Track Box. The relation between two meta boxes is unspecified if there is no metabox relation box for those meta boxes. Meta boxes are referenced by specifying their handler types.

type MovieBox

type MovieBox struct {
	MP4BoxHeader // standard header

}

ISO_IEC_14496-12_2012.pdf Page/30

Box Type: moov Container: File Mandatory: Yes Quantity: Exactly one

The metadata for a presentation is stored in the single Movie Box which occurs at the top-level of a file. Normally this box is close to the beginning or end of the file, though this is not required

func NewMovieBox

func NewMovieBox() (box *MovieBox)

type MovieExtendsBox

type MovieExtendsBox struct {
	MP4BoxHeader // standard header
}

ISO_IEC_14496-12_2012.pdf Page/64

Box Type: mvex Container: Movie Box (‘moov’) Mandatory: No Quantity: Zero or one

type MovieExtendsHeaderBox

type MovieExtendsHeaderBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header
}

ISO_IEC_14496-12_2012.pdf Page/65

Box Type: mehd Container: Movie Extends Box(‘mvex’) Mandatory: No Quantity: Zero or one

The Movie Extends Header is optional, and provides the overall duration, including fragments, of a fragmented movie. If this box is not present, the overall duration must be computed by examining each fragment.

type MovieFragmentBox

type MovieFragmentBox struct {
	MP4BoxHeader // standard header
}

ISO_IEC_14496-12_2012.pdf Page/66

Box Type: moof Container: File Mandatory: No Quantity: Zero or more

type MovieFragmentHeaderBox

type MovieFragmentHeaderBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	SequenceNumber uint32 // 32 bits, the ordinal number of this fragment, in increasing order
}

ISO_IEC_14496-12_2012.pdf Page/66

Box Type: mfhd Container: Movie Fragment Box ('moof') Mandatory: Yes Quantity: Exactly one

The movie fragment header contains a sequence number, as a safety check. The sequence number usually starts at 1 and must increase for each movie fragment in the file, in the order in which they occur. This allows readers to verify integrity of the sequence; it is an error to construct a file where the fragments are out of sequence.

type MovieFragmentRandomAccessBox

type MovieFragmentRandomAccessBox struct {
	MP4BoxHeader // standard header
}

ISO_IEC_14496-12_2012.pdf Page/69

Box Type: mfra Container: File Mandatory: No Quantity: Zero or one

type MovieFragmentRandomAccessOffsetBox

type MovieFragmentRandomAccessOffsetBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	Size uint32 // 32 bits, is an integer gives the number of bytes of the enclosing ‘mfra’ box. This field is placed at the last of the enclosing box to assist readers scanning from the end of the file in finding the ‘mfra’ box.
}

ISO_IEC_14496-12_2012.pdf Page/71

Box Type: mfro Container: Movie Fragment Random Access Box (‘mfra’) Mandatory: Yes Quantity: Exactly one

The Movie Fragment Random Access Offset Box provides a copy of the length field from the enclosing Movie Fragment Random Access Box. It is placed last within that box, so that the size field is also last in the enclosing Movie Fragment Random Access Box. When the Movie Fragment Random Access Box is also last in the file this permits its easy location. The size field here must be correct. However, neither the presence of the Movie Fragment Random Access Box, nor its placement last in the file, are assured.

type MovieHeaderBox

type MovieHeaderBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	CreationTime     interface{} // uint64 or uint32, is an integer that declares the creation time of the presentation (in seconds since midnight, Jan. 1, 1904, in UTC time)
	ModificationTime interface{} // uint64 or uint32, is an integer that declares the most recent time the presentation was modified (in seconds since midnight, Jan. 1, 1904, in UTC time)
	TimeScale        uint32      // 32 bits, is an integer that specifies the time-scale for the entire presentation; this is the number of time units that pass in one second. For example, a time coordinate system that measures time in sixtieths of a second has a time scale of 60.
	Duration         interface{} // uint64 or uint32, is an integer that declares length of the presentation (in the indicated timescale). This property is derived from the presentation's tracks: the value of this field corresponds to the duration of the longest track in the presentation. If the duration cannot be determined then duration is set to all 1s.
	Rate             int32       // 32 bits, is a fixed point 16.16 number that indicates the preferred rate to play the presentation; 1.0 (0x00010000) is normal forward playback
	Volume           int16       // 16 bits, is a fixed point 8.8 number that indicates the preferred playback volume. 1.0 (0x0100) is full volume.
	Reserved1        int16       // 16 bits, bit[16]
	Reserved2        [2]uint32   // 32 bits array, const unsigned int(32)[2]
	Matrix           [9]int32    // 32 bits array, provides a transformation matrix for the video; (u,v,w) are restricted here to (0,0,1), hex values(0,0,0x40000000).
	PreDefined       [6]int32    // 32 bits array, bit(32)[6]
	NextTrackID      uint32      // 32 bits, is a non-zero integer that indicates a value to use for the track ID of the next track to be added to this presentation. Zero is not a valid track ID value. The value of next_track_ID shall be larger than the largest track-ID in use. If this value is equal to all 1s (32-bit maxint), and a new media track is to be added, then a search must be made in the file for an unused track identifier.
}

ISO_IEC_14496-12_2012.pdf Page/31

Box Type: mvhd Container: Movie Box ('moov') Mandatory: Yes Quantity: Exactly one

This box defines overall information which is media-independent, and relevant to the entire presentation considered as a whole

type NALUHeader

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

type NALUnit

type NALUnit struct {
	NALUHeader
	RBSP
}

type NullMediaHeaderBox

type NullMediaHeaderBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header
}

Box Types: nmhd Streams other than visual and audio (e.g., timed metadata streams) may use a null Media Header Box, as defined here.

type OriginalFormatBox

type OriginalFormatBox struct {
	MP4BoxHeader // standard header

	DataFormat uint32 // 32 bits, is the four-character-code of the original un-transformed sample entry (e.g. “mp4v” if the stream contains protected or restricted MPEG-4 visual material).
}

type PaddingBitsBox

type PaddingBitsBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	SampleCount uint32             // 32 bits, counts the number of samples in the track; it should match the count in other tables
	Table       []PaddingBitsTable // Padding Bits Table, (sample count + 1) / 2 elements.
}

ISO_IEC_14496-12_2012.pdf Page/60

Box Type: padb Container: Sample Table (‘stbl’) Mandatory: No Quantity: Zero or one

In some streams the media samples do not occupy all bits of the bytes given by the sample size, and are padded at the end to a byte boundary. In some cases, it is necessary to record externally the number of padding bits used. This table supplies that information.

type PaddingBitsTable

type PaddingBitsTable struct {
	Reserved1 byte // 1 bit,
	Pad1      byte // 3 bits, a value from 0 to 7, indicating the number of bits at the end of sample (i*2)+1.
	Reserved2 byte // 1 bit,
	Pad2      byte // 3 bits, a value from 0 to 7, indicating the number of bits at the end of sample (i*2)+2.
}

type PartitionEntry

type PartitionEntry struct {
	FPB   FilePartitionBox //
	FECRB FECReservoirBox  //optional
	FRB   FileReservoirBox //optional
}

Box Type: paen

type PixelAspectRatioBox

type PixelAspectRatioBox struct {
	MP4BoxHeader // standard header

	HSpacing uint32 // 32 bits, define the relative width and height of a pixel;
	VSpacing uint32 // 32 bits, define the relative width and height of a pixel;
}

Box Types: pasp

type PrimaryItemBox

type PrimaryItemBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	ItemID uint16 // 16 bits, is the identifier of the primary item
}

ISO_IEC_14496-12_2012.pdf Page/93

Box Type: pitm Container: Meta box (‘meta’) Mandatory: No Quantity: Zero or one

For a given handler, the primary data may be one of the referenced items when it is desired that it be stored elsewhere, or divided into extents; or the primary metadata may be contained in the meta-box (e.g. in an XML box). Either this box must occur, or there must be a box within the meta-box (e.g. an XML box) containing the primary information in the format required by the identified handler.

type ProducerReferenceTimeBox

type ProducerReferenceTimeBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	ReferenceTrackID uint32      // 32 bits, provides the track_ID for the reference track.
	NtpTimestamp     uint64      // 64 bits, indicates a UTC time in NTP format corresponding to decoding_time.
	MediaTime        interface{} // uint32 or uint64, corresponds to the same time as ntp_timestamp, but in the time units used for the reference track, and is measured on this media clock as the media is produced.
}

ISO_IEC_14496-12_2012.pdf Page/111

Box Type: prft Container: File Mandatory: No Quantity: Zero or more

type ProgressiveDownloadInformationBox

type ProgressiveDownloadInformationBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	Rate         uint32 // 32 bits, is a download rate expressed in bytes/second
	InitialDelay uint32 // 32 bits, is the suggested delay to use when playing the file, such that if download continues at the given rate, all data within the file will arrive in time for its use and playback should not need to stall.
}

ISO_IEC_14496-12_2012.pdf Page/30

Box Types: pdin Container: File Mandatory: No Quantity: Zero or One

type ProtectionSchemeInfoBox

type ProtectionSchemeInfoBox struct {
	MP4BoxHeader // standard header

	OriginalFormat OriginalFormatBox    //
	Type           SchemeTypeBox        // optional
	Info           SchemeInformationBox // optional
}

ISO_IEC_14496-12_2012.pdf Page/92

Box Types: sinf Container: Protected Sample Entry, or Item Protection Box (‘ipro’) Mandatory: Yes Quantity: One or More

type RBSP

type RBSP interface {
}

type SPSInfo

type SPSInfo struct {
	ProfileIdc uint
	LevelIdc   uint

	MbWidth  uint
	MbHeight uint

	CropLeft   uint
	CropRight  uint
	CropTop    uint
	CropBottom uint

	Width  uint
	Height uint
}

func ParseSPS

func ParseSPS(data []byte) (self SPSInfo, err error)

type SampleAuxiliaryInformationOffsetsBox

type SampleAuxiliaryInformationOffsetsBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

}

ISO_IEC_14496-12_2012.pdf Page/63

Box Type: saio Container: Sample Table Box (‘stbl’) or Track Fragment Box ('traf') Mandatory: No Quantity: Zero or More

type SampleAuxiliaryInformationSizesBox

type SampleAuxiliaryInformationSizesBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	Table interface{} // SampleAuxiliaryInformationSizesTable1 or SampleAuxiliaryInformationSizesTable2.
}

ISO_IEC_14496-12_2012.pdf Page/62

Box Type: saiz Container: Sample Table Box (‘stbl’) or Track Fragment Box ('traf') Mandatory: No Quantity: Zero or More

type SampleAuxiliaryInformationSizesTable1

type SampleAuxiliaryInformationSizesTable1 struct {
	AuxInfoType           uint32 // 32 bits,
	AuxInfoTypeParameter  uint32 // 32 bits,
	DefaultSampleInfoSize uint8  // 8 bits,  is an integer specifying the sample auxiliary information size for the case where all the indicated samples have the same sample auxiliary information size. If the size varies then this field shall be zero.
	SampleCount           uint32 // 32 bits,
}

type SampleAuxiliaryInformationSizesTable2

type SampleAuxiliaryInformationSizesTable2 struct {
	DefaultSampleInfoSize uint8  // 8 bits,  is an integer specifying the sample auxiliary information size for the case where all the indicated samples have the same sample auxiliary information size. If the size varies then this field shall be zero.
	SampleCount           uint32 // 32 bits,
}

type SampleDescriptionBox

type SampleDescriptionBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	EntryCount uint32 // 32 bits, is an integer that gives the number of entries in the following table
}

ISO_IEC_14496-12_2012.pdf Page/40

Box Types: stsd Container: Sample Table Box ('stbl') Mandatory: Yes Quantity: Exactly one

type SampleEntry

type SampleEntry struct {
	Reserved           [6]uint8 // 48 bits,
	DataReferenceIndex uint16   // 16 bits, is an integer that contains the index of the data reference to use to retrieve data associated with samples that use this sample description. Data references are stored in Data Reference Boxes. The index ranges from 1 to the number of data references.
}

is the appropriate sample entry

type SampleGroupDescriptionBox

type SampleGroupDescriptionBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	GroupingType uint32 // 32 bits, is an integer that identifies the SampleToGroup box that is associated with this sample group description.
	EntryCount   uint32 // 32 bits, is an integer that gives the number of entries in the following table.
}

ISO_IEC_14496-12_2012.pdf Page/76

Box Type: sgpd Container: Sample Table Box (‘stbl’) or Track Fragment Box (‘traf’) Mandatory: No Quantity: Zero or more, with one for each Sample to Group Box.

type SampleGroupDescriptionEntry

type SampleGroupDescriptionEntry struct{}

type SampleSizeBox

type SampleSizeBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	SampleSize  uint32      // 32 bits, is integer specifying the default sample size. If all the samples are the same size, this field contains that size value. If this field is set to 0, then the samples have different sizes, and those sizes are stored in the sample size table. If this field is not 0, it specifies the constant sample size, and no array follows.
	SampleCount uint32      // 32 bits, is an integer that gives the number of samples in the track; if sample-size is 0, then it is also the number of entries in the following table.
	EntrySize   interface{} // 32 bits array, SampleCount elements, is an integer specifying the size of a sample, indexed by its number.
}

Box Type: stsz

type SampleSizeBoxes

type SampleSizeBoxes struct{}

ISO_IEC_14496-12_2012.pdf Page/57

Box Type: stsz, stz2 Container: Sample Table Box (‘stbl’) Mandatory: Yes Quantity: Exactly one variant must be present

type SampleTableBox

type SampleTableBox struct {
	MP4BoxHeader // standard header
}

-------------------------------------------------------------------------------------------------------

ISO_IEC_14496-12_2012.pdf Page/40

Box Type: stbl Container: Media Information Box ('minf') Mandatory: Yes Quantity: Exactly one

type SampleToChunkBox

type SampleToChunkBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	EntryCount uint32               // 32 bits, is an integer that gives the number of entries in the following table
	Table      []SampleToChunkTable // Sample To Chunk Table, entry count elements.
}

ISO_IEC_14496-12_2012.pdf Page/58

Box Type: stsc Container: Sample Table Box ('stbl') Mandatory: Yes Quantity: Exactly one

type SampleToChunkTable

type SampleToChunkTable struct {
	FirstChunk             []uint32 // 32 bits, is an integer that gives the index of the first chunk in this run of chunks that share the same samples-per-chunk and sample-description-index; the index of the first chunk in a track has the value 1 (the first_chunk field in the first record of this box has the value 1, identifying that the first sample maps to the first chunk).
	SamplesPerChunk        []uint32 // 32 bits, is an integer that gives the number of samples in each of these chunks
	SampleDescriptionIndex []uint32 // 32 bits, is an integer that gives the index of the sample entry that describes the samples in this chunk. The index ranges from 1 to the number of sample entries in the Sample Description Box
}

type SampleToGroupBox

type SampleToGroupBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	GroupingType uint32               // 32 bits, is an integer that identifies the type (i.e. criterion used to form the sample groups) of the sample grouping and links it to its sample group description table with the same value for grouping type. At most one occurrence of this box with the same value for grouping_type (and, if used, grouping_type_parameter) shall exist for a track.
	EntryCount   uint32               // 32 bits, is an integer that gives the number of entries in the following table.
	Table        []SampleToGroupTable // Sample To Group Table, entry count elements.
}

ISO_IEC_14496-12_2012.pdf Page/75

Box Type: sbgp Container: Sample Table Box (‘stbl’) or Track Fragment Box (‘traf’) Mandatory: No Quantity: Zero or more.

type SampleToGroupTable

type SampleToGroupTable struct {
	SampleCount           uint32 // 32 bits, is an integer that gives the number of consecutive samples with the same sample group descriptor. If the sum of the sample count in this box is less than the total sample count, then the reader should effectively extend it with an entry that associates the remaining samples with no group. It is an error for the total in this box to be greater than the sample_count documented elsewhere, and the reader behaviour would then be undefined.
	GroupDescriptionIndex uint32 // 32 bits, is an integer that gives the index of the sample group entry which describes the samples in this group. The index ranges from 1 to the number of sample group entries in the SampleGroupDescription Box, or takes the value 0 to indicate that this sample is a member of no group of this type.
}

type SchemeInformationBox

type SchemeInformationBox struct {
	MP4BoxHeader // standard header

	SchemeSpecificData []SchemeTypeBox
}

ISO_IEC_14496-12_2012.pdf Page/94

Box Types: schi Container: Protection Scheme Information Box (‘sinf’), Restricted Scheme Information Box (‘rinf’), or SRTP Process box (‘srpp‘) Mandatory: No Quantity: Zero or one The Scheme Information Box is a container Box that is only interpreted by the scheme being used. Any information the encryption or restriction system needs is stored here. The content of this box is a series of boxes whose type and format are defined by the scheme declared in the Scheme Type Box.

type SchemeTypeBox

type SchemeTypeBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	SchemeType    uint32 // 32 bits, is the code defining the protection or restriction scheme.
	SchemeVersion uint32 // 32 bits, is the version of the scheme (used to create the content)
}

ISO_IEC_14496-12_2012.pdf Page/93

Box Types: schm Container: Protection Scheme Information Box (‘sinf’), Restricted Scheme Information Box (‘rinf’), or SRTP Process box (‘srpp‘) Mandatory: No

Quantity: Zero or one in ‘sinf’, depending on the protection structure; Exactly one in ‘rinf’ and ‘srpp’ The Scheme Type Box (‘schm’) identifies the protection or restriction scheme.

type SegmentIndexBox

type SegmentIndexBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	ReferenceID              uint32              // 32 bits,
	TimeScale                uint32              // 32 bits,
	EarliestPresentationTime interface{}         // uint32 or uint64,
	FirstOffset              interface{}         // uint32 or uint64,
	Reserved                 uint16              // 16 bits,
	ReferenceCount           uint16              // 16 bits,
	Table                    []SegmentIndexTable // Segment Index Table, ReferenceCount elements
}

ISO_IEC_14496-12_2012.pdf Page/106

Box Type: sidx Container: File Mandatory: No Quantity: Zero or more

type SegmentIndexTable

type SegmentIndexTable struct {
	ReferenceType      byte   // 1 bit
	ReferencedSize     uint32 // 32 bits
	SubSegmentDuration uint32 // 32 bits,
	StartsWithSAP      byte   // 1 bit
	SAPType            byte   // 3 bits,
	SAPDeltaTime       uint32 // 28 bits,
}

type SendPacket

type SendPacket struct {
	*AVPacket
	Timestamp uint32
}

func NewSendPacket

func NewSendPacket(p *AVPacket, timestamp uint32) (result *SendPacket)

func (*SendPacket) Recycle

func (packet *SendPacket) Recycle()

type ShadowSyncSampleBox

type ShadowSyncSampleBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	EntryCount uint32                  // 32 bits, is an integer that gives the number of entries in the following table.
	Table      []ShadowSyncSampleTable // Shadow Sync Sample Table, entry count elements.
}

ISO_IEC_14496-12_2012.pdf Page/52

Box Type: stsh Container: Sample Table Box (‘stbl’) Mandatory: No Quantity: Zero or one

type ShadowSyncSampleTable

type ShadowSyncSampleTable struct {
	ShadowedSampleNumber uint32 // 32 bits, gives the number of a sample for which there is an alternative sync sample.
	SyncSampleNumber     uint32 // 32 bits, gives the number of the alternative sync sample.
}

type SingleItemTypeReferenceBox

type SingleItemTypeReferenceBox struct {
	MP4BoxHeader // standard header

	FromItemID     uint16                         // 16 bits, contains the ID of the item that refers to other items
	ReferenceCount uint16                         // 16 bits, is the number of references
	Table          []SingleItemTypeReferenceTable // Single Item Type Reference Table, ReferenceCount elements.
}

type SingleItemTypeReferenceTable

type SingleItemTypeReferenceTable struct {
	ToItemID uint16 // 16 bits, contains the ID of the item referred to
}

type SoundMediaHeaderBox

type SoundMediaHeaderBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	Balance  int16  // 16 bits, is a fixed-point 8.8 number that places mono audio tracks in a stereo space; 0 is centre (the normal value); full left is -1.0 and full right is 1.0
	Reserved uint16 // 16 bits,
}

Box Types: smhd The sound media header contains general presentation information, independent of the coding, for audio media. This header is used for all tracks containing audio.

type SubSampleCountTable

type SubSampleCountTable struct {
	SubsampleSize     interface{} // uint16 or uint32, is an integer that specifies the size, in bytes, of the current sub-sample
	SubsamplePriority uint8       // 8 bits, is an integer specifying the degradation priority for each sub-sample. Higher values of subsample_priority, indicate sub-samples which are important to, and have a greater impact on, the decoded quality.
	DiscardAble       uint8       // 8 bits, equal to 0 means that the sub-sample is required to decode the current sample, while equal to 1 means the sub-sample is not required to decode the current sample but may be used for enhancements, e.g., the sub-sample consists of supplemental enhancement information (SEI) messages.
	Reserved          uint32      // 32 bits,
}

type SubSampleInformationBox

type SubSampleInformationBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	EntryCount uint32                      // 32 bits, is an integer that gives the number of entries in the following table.
	Table      []SubSampleInformationTable // Sub-Sample Information Table, entry count elements.

}

ISO_IEC_14496-12_2012.pdf Page/61

Box Type: subs Container: Sample Table Box (‘stbl’) or Track Fragment Box (‘traf’) Mandatory: No Quantity: Zero or one

type SubSampleInformationTable

type SubSampleInformationTable struct {
	SampleDelta    uint32                // 32 bits, is an integer that specifies the sample number of the sample having sub-sample structure. It is coded as the difference between the desired sample number, and the sample number indicated in the previous entry. If the current entry is the first entry, the value indicates the sample number of the first sample having sub-sample information, that is, the value is the difference between the sample number and zero (0).
	SubsampleCount uint16                // 16 bits, is an integer that specifies the number of sub-sample for the current sample. If there is no sub-sample structure, then this field takes the value 0.
	CountTable     []SubSampleCountTable // Sub-Sample Information Table1, subsample count elements.
}

type SubTrack

type SubTrack struct {
	MP4BoxHeader // standard header
}

ISO_IEC_14496-12_2012.pdf Page/100

Box Type: strk Container: User Data box (‘udta’) of the corresponding Track box (‘trak’) Mandatory: No Quantity: Zero or more

This box contains objects that define and provide information about a sub track in the present track.

type SubTrackDefinition

type SubTrackDefinition struct {
	MP4BoxHeader // standard header
}

ISO_IEC_14496-12_2012.pdf Page/101

Box Type: strd Container: Sub Track box (‘strk’) Mandatory: Yes Quantity: One

This box contains objects that provide a definition of the sub track.

type SubTrackInformation

type SubTrackInformation struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	SwitchGroup    int16    // 16 bits,
	AlternateGroup int16    // 16 bits,
	SubTrackID     uint32   // 32 bits, is an integer. A non-zero value uniquely identifies the sub track locally within the track. A zero value (default) means that sub track ID is not assigned.
	AttributeList  []uint32 // 32 bits array, is a list, to the end of the box, of attributes. The attributes in this list should be used as descriptions of sub tracks or differentiating criteria for tracks and sub tracks in the same alternate or switch group
}

ISO_IEC_14496-12_2012.pdf Page/100

Box Type: stri Container: Sub Track box (‘strk’) Mandatory: Yes Quantity: One

type SubsegmentIndexBox

type SubsegmentIndexBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	SubSegmentCount uint32                 // 32 bits, is a positive integer specifying the number of subsegments for which partial subsegment information is specified in this box. subsegment_count shall be equal to reference_count (i.e., the number of movie fragment references) in the immediately preceding Segment Index box.
	Table           []SubsegmentIndexTable // Subsegment Index Table, SubSegmentCount elements.
}

ISO_IEC_14496-12_2012.pdf Page/109

Box Type: ssix Container: File Mandatory: No Quantity: Zero or more

type SubsegmentIndexTable

type SubsegmentIndexTable struct {
	RangesCount uint32                  // 32 bits, specifies the number of partial subsegment levels into which the media data is grouped. This value shall be greater than or equal to 2.
	Rtable      []SubsegmentRangesTable // Subsegment Ranges Table, RangesCount elements.
}

type SubsegmentRangesTable

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

type SyncSampleBox

type SyncSampleBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	EntryCount   uint32   // 32 bits, is an integer that gives the number of entries in the following table. If entry_count is zero, there are no sync samples within the stream and the following table is empty
	SampleNumber []uint32 // 32 bits array, entry count elements. gives the numbers of the samples that are sync samples in the stream.
}

ISO_IEC_14496-12_2012.pdf Page/51

Box Type: stss Container: Sample Table Box (‘stbl’) Mandatory: No Quantity: Zero or one

This box provides a compact marking of the sync samples within the stream. The table is arranged in strictly increasing order of sample number. If the sync sample box is not present, every sample is a sync sample.

type TextMetaDataSampleEntry

type TextMetaDataSampleEntry struct {
	ContentEncoding string     // optional, is a null-terminated string in UTF-8 characters, and provides a MIME type which identifies the content encoding of the timed metadata
	MimeFormat      string     // string, provides a MIME type which identifies the content format of the timed metadata. Examples for this field are ‘text/html’ and ‘text/plain’.
	Brb             BitRateBox // optional
}

type TimeToSampleBox

type TimeToSampleBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	EntryCount uint32              // 32 bits, is an integer that gives the number of entries in the following table
	Table      []TimeToSampleTable // Time To Sample Table , EntryCount elements
}

ISO_IEC_14496-12_2012.pdf Page/48

Box Type: stts Container: Sample Table Box ('stbl') Mandatory: Yes Quantity: Exactly one

type TimeToSampleTable

type TimeToSampleTable struct {
	SampleCount []uint32 // 32 bits, is an integer that counts the number of consecutive samples that have the given duration
	SampleDelta []uint32 // 32 bits, is an integer that gives the delta of these samples in the time-scale of the media.
}

type TrackBox

type TrackBox struct {
	MP4BoxHeader // standard header

	Thb TrackHeaderBox // the first child box(header box)
}

ISO_IEC_14496-12_2012.pdf Page/32

Box Type: trak Container: Movie Box ('moov') Mandatory: Yes Quantity: One or more

type TrackExtendsBox

type TrackExtendsBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	TrackID                       uint32 // 32 bits, identifies the track; this shall be the track ID of a track in the Movie Box
	DefaultSampleDescriptionIndex uint32 // 32 bits,
	DefaultSampleDuration         uint32 // 32 bits,
	DefaultSampleSize             uint32 // 32 bits,
	DefaultSampleFlags            uint32 // 32 bits,
}

ISO_IEC_14496-12_2012.pdf Page/65

Box Type: trex Container: Movie Extends Box (‘mvex’) Mandatory: Yes Quantity: Exactly one for each track in the Movie Box

type TrackFragmentBaseMediaDecodeTimeBox

type TrackFragmentBaseMediaDecodeTimeBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	BaseMediaDecodeTime interface{} // uint32 or uint64, is an integer equal to the sum of the decode durations of all earlier samples in the media, expressed in the media's timescale. It does not include the samples added in the enclosing track fragment.
}

ISO_IEC_14496-12_2012.pdf Page/71

Box Type: tfdt Container: Track Fragment box (‘traf’) Mandatory: No Quantity: Zero or one

type TrackFragmentBox

type TrackFragmentBox struct {
	MP4BoxHeader // standard header
}

ISO_IEC_14496-12_2012.pdf Page/67

Box Type: traf Container: Movie Fragment Box ('moof') Mandatory: No Quantity: Zero or more

type TrackFragmentHeaderBox

type TrackFragmentHeaderBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	TrackID uint32 // 32 bits,

	// all the following are optional fields
	BaseDataOffset         uint64 // 64 bits, the base offset to use when calculating data offsets
	SampleDescriptionIndex uint32 // 32 bits,
	DefaultSampleDuration  uint32 // 32 bits,
	DefaultSampleSize      uint32 // 32 bits,
	DefaultSampleFlags     uint32 // 32 bits,
}

ISO_IEC_14496-12_2012.pdf Page/67

Box Type: tfhd Container: Track Fragment Box ('traf') Mandatory: Yes Quantity: Exactly one

type TrackFragmentRandomAccessBox

type TrackFragmentRandomAccessBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	TrackID               uint32                           // 32 bits, is an integer identifying the track_ID.
	Reserved              uint32                           // 26 bits,
	LengthSizeOfTrafNum   byte                             // 2 bits, indicates the length in byte of the traf_number field minus one.
	LengthSizeOfTrunNum   byte                             // 2 bits, indicates the length in byte of the trun_number field minus one.
	LengthSizeOfSampleNum byte                             // 2 bits, indicates the length in byte of the sample_number field minus one.
	NumberOfEntry         uint32                           // 32 bits, is an integer that gives the number of the entries for this track. If this value is zero, it indicates that every sample is a sync sample and no table entry follows.
	Table                 []TrackFragmentRandomAccessTable // Track Fragment RandomAccess Table 1, NumberOfEntry elements.
}

ISO_IEC_14496-12_2012.pdf Page/70

Box Type: tfra Container: Movie Fragment Random Access Box (‘mfra’) Mandatory: No Quantity: Zero or one per track

type TrackFragmentRandomAccessTable

type TrackFragmentRandomAccessTable struct {
	Time         interface{} // uint32 or uint64, is 32 or 64 bits integer that indicates the presentation time of the sync sample in units defined in the ‘mdhd’ of the associated track.
	Moofoffset   interface{} // uint32 or uint64, is 32 or 64 bits integer that gives the offset of the ‘moof’ used in this entry. Offset is the byte-offset between the beginning of the file and the beginning of the ‘moof’.
	TrafNumber   interface{} // unsigned int((length_size_of_traf_num+1) * 8). indicates the ‘traf’ number that contains the sync sample. The number ranges from 1 (the first ‘traf’ is numbered 1) in each ‘moof’.
	TrunNumber   interface{} // unsigned int((length_size_of_trun_num+1) * 8). indicates the ‘trun’ number that contains the sync sample. The number ranges from 1 in each ‘traf’
	SampleNumber interface{} // unsigned int((length_size_of_sample_num+1) * 8) . indicates the sample number of the sync sample. The number ranges from 1 in each ‘trun’.
}

type TrackFragmentRunBox

type TrackFragmentRunBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	SampleCount uint32 // 32 bits, the number of samples being added in this run; also the number of rows in the following table (the rows can be empty)

	// the following are optional fields
	DataOffset       int32  // 32 bits, signed, is added to the implicit or explicit data_offset established in the track fragment header.
	FirstSampleFlags uint32 // 32 bits, provides a set of flags for the first sample only of this run.

	// all fields in the following array are optional
	Table []TrackFragmentRunTable // Track Fragment Run Table 1, SampleCount elements.
}

ISO_IEC_14496-12_2012.pdf Page/68

Box Type: trun Container: Track Fragment Box ('traf') Mandatory: No Quantity: Zero or more

type TrackFragmentRunTable

type TrackFragmentRunTable struct {
	SampleDuration              uint32      // 32 bits,
	SampleSize                  uint32      // 32 bits,
	SampleFlags                 uint32      // 32 bits,
	SampleCompositionTimeOffset interface{} // uint32 or int32,
}

type TrackGroupBox

type TrackGroupBox struct {
	MP4BoxHeader // standard header
}

ISO_IEC_14496-12_2012.pdf Page/35

Box Type: trgr Container: Track Box (‘trak’) Mandatory: No Quantity: Zero or one

type TrackGroupTypeBox

type TrackGroupTypeBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	TrackGroupID uint32 // 32 bits, indicates the grouping type and shall be set to one of the following values, or a value registered, or a value from a derived specification or registration
}

type TrackHeaderBox

type TrackHeaderBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	CreationTime     interface{} // uint64 or uint32,
	ModificationTime interface{} // uint64 or uint32,
	TrackID          uint32      // 32 bits, is an integer that uniquely identifies this track over the entire life-time of this presentation. Track IDs are never re-used and cannot be zero
	Reserved1        uint32      // 32 bits,
	Duration         interface{} // uint64 or uint32,
	Reserved2        [2]uint32   // 32 bits array,
	Layer            int16       // 16 bits, specifies the front-to-back ordering of video tracks; tracks with lower numbers are closer to the viewer. 0 is the normal value, and -1 would be in front of track 0, and so on
	AlternateGroup   int16       // 16 bits,
	Volume           int16       // 16 bits, if track_is_audio 0x0100 else 0
	Reserved3        uint16      // 16 bits,
	Matrix           [9]int32    // 32 bits array, provides a transformation matrix for the video; (u,v,w) are restricted here to (0,0,1), hex (0,0,0x40000000). { 0x00010000,0,0,0,0x00010000,0,0,0,0x40000000 }
	Width            uint32      // 32 bits,
	Height           uint32      // 32 bits,
}

ISO_IEC_14496-12_2012.pdf Page/32

Box Type: tkhd Container: Track Box ('trak') Mandatory: Yes Quantity: Exactly one

type TrackReferenceBox

type TrackReferenceBox struct {
	MP4BoxHeader // standard header
}

ISO_IEC_14496-12_2012.pdf Page/34

Box Type: tref Container: Track Box (‘trak’) Mandatory: No Quantity: Zero or one

type TrackReferenceTypeBox

type TrackReferenceTypeBox struct {
	MP4BoxHeader // standard header

	TrackIDs []uint32 // 32 bits, is an integer that provides a reference from the containing track to another track in the presentation. track_IDs are never re-used and cannot be equal to zero
}

type TrackSelectionBox

type TrackSelectionBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	SwitchGroup   int32    // 32 bits, is an integer that specifies a group or collection of tracks. If this field is 0 (default value) or if the Track Selection box is absent there is no information on whether the track can be used for switching during playing or streaming. If this integer is not 0 it shall be the same for tracks that can be used for switching between each other. Tracks that belong to the same switch group shall belong to the same alternate group. A switch group may have only one member.
	AttributeList []uint32 // 32 bits array, to end of the box, is a list, to the end of the box, of attributes. The attributes in this list should be used as descriptions of tracks or differentiation criteria for tracks in the same alternate or switch group. Each differentiating attribute is associated with a pointer to the field or information that distinguishes the track.
}

ISO_IEC_14496-12_2012.pdf Page/79

Box Type: tsel Container: User Data Box (‘udta’) Mandatory: No Quantity: Zero or One

The track selection box is contained in the user data box of the track it modifies.

type URIBox

type URIBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	TheURI string // string, is a URI formatted according to the rules in 6.2.4
}

type URIInitBox

type URIInitBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	UriInitializationData []uint8 // 8 bits array,  is opaque data whose form is defined in the documentation of the URI form.
}

type URIMetaSampleEntry

type URIMetaSampleEntry struct {
	TheLabel URIBox
	Init     URIInitBox // optional

}

type UserDataBox

type UserDataBox struct {
	MP4BoxHeader // standard header
}

ISO_IEC_14496-12_2012.pdf Page/78

Box Type: udta Container: Movie Box (‘moov’) or Track Box (‘trak’) Mandatory: No Quantity: Zero or one

type VideoMediaHeaderBox

type VideoMediaHeaderBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	GraphicsMode uint16    // 16 bits, specifies a composition mode for this video track, from the following enumerated set, which may be extended by derived specifications: copy = 0 copy over the existing image
	Opcolor      [3]uint16 // 16 bits array, is a set of 3 colour values (red, green, blue) available for use by graphics modes
}

Box Types: vmhd The video media header contains general presentation information, independent of the coding, for video media. Note that the flags field has the value 1.

type VisualSampleEntry

type VisualSampleEntry struct {
	PreDefined1     uint16              // 16 bits,
	Reserved1       uint16              // 16 bits,
	PreDefined2     [3]uint32           // 96 bits,
	Width           uint16              // 16 bits, are the maximum visual width and height of the stream described by this sample description, in pixels
	Height          uint16              // 16 bits, are the maximum visual width and height of the stream described by this sample description, in pixels
	HorizreSolution uint32              // 32 bits, fields give the resolution of the image in pixels-per-inch, as a fixed 16.16 number
	VertreSolution  uint32              // 32 bits, fields give the resolution of the image in pixels-per-inch, as a fixed 16.16 number
	Reserved3       uint32              // 32 bits,
	FrameCount      uint16              // 16 bits, indicates how many frames of compressed video are stored in each sample. The default is 1, for one frame per sample; it may be more than 1 for multiple frames per sample
	CompressorName  [32]string          // 32 string, is a name, for informative purposes. It is formatted in a fixed 32-byte field, with the first byte set to the number of bytes to be displayed, followed by that number of bytes of displayable data, and then padding to complete 32 bytes total (including the size byte). The field may be set to 0.
	Depth           uint16              // 16 bits, takes one of the following values 0x0018 – images are in colour with no alpha
	PreDefined3     int16               // 16 bits,
	Cab             CleanApertureBox    // optional, other boxes from derived specifications
	Parb            PixelAspectRatioBox // optional, other boxes from derived specifications
}

type VisualSampleGroupEntry

type VisualSampleGroupEntry struct{}

type XMLBox

type XMLBox struct {
	MP4BoxHeader     // standard header
	MP4FullBoxHeader // full box header

	XML string // string,
}

ISO_IEC_14496-12_2012.pdf Page/82

Box Type: ‘xml ‘ or ‘bxml’ Container: Meta box (‘meta’) Mandatory: No Quantity: Zero or one

When the primary data is in XML format and it is desired that the XML be stored directly in the meta-box, one of these forms may be used. The Binary XML Box may only be used when there is a single well-defined binarization of the XML for that defined format as identified by the handler. Within an XML box the data is in UTF-8 format unless the data starts with a byte-order-mark (BOM), which indicates that the data is in UTF-16 format.

type XMLMetaDataSampleEntry

type XMLMetaDataSampleEntry struct {
	ContentEncoding string     // optional, is a null-terminated string in UTF-8 characters, and provides a MIME type which identifies the content encoding of the timed metadata
	NameSpace       string     // string, gives the namespace of the schema for the timed XML metadata
	SchemaLocation  string     // optional, optionally provides an URL to find the schema corresponding to the namespace. This is needed for decoding of the timed metadata by XML aware encoding mechanisms such as BiM.
	Brb             BitRateBox // optional
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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