mp4

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: MIT Imports: 14 Imported by: 41

README

go-mp4

Go Reference Test Coverage Status Go Report Card

go-mp4 is Go library which provides low-level I/O interfaces of MP4. This library supports you to parse or build any MP4 boxes(atoms) directly.

go-mp4 provides very flexible interfaces for reading boxes. If you want to read only specific parts of MP4 file, this library extracts those boxes via io.ReadSeeker interface.

On the other hand, this library is not suitable for complex data conversions.

Integration with your Go application

Reading

You can parse MP4 file as follows:

// expand all boxes
_, err := mp4.ReadBoxStructure(file, func(h *mp4.ReadHandle) (interface{}, error) {
	fmt.Println("depth", len(h.Path))

	// Box Type (e.g. "mdhd", "tfdt", "mdat")
	fmt.Println("type", h.BoxInfo.Type.String())

	// Box Size
	fmt.Println("size", h.BoxInfo.Size)

	if h.BoxInfo.IsSupportedType() {
		// Payload
		box, _, err := h.ReadPayload()
		if err != nil {
			return nil, err
		}
		str, err := mp4.Stringify(box, h.BoxInfo.Context)
		if err != nil {
			return nil, err
		}
		fmt.Println("payload", str)

		// Expands children
		return h.Expand()
	}
	return nil, nil
})
// extract specific boxes
boxes, err := mp4.ExtractBoxWithPayload(file, nil, mp4.BoxPath{mp4.BoxTypeMoov(), mp4.BoxTypeTrak(), mp4.BoxTypeTkhd()})
if err != nil {
   :
}
for _, box := range boxes {
  tkhd := box.Payload.(*mp4.Tkhd)
  fmt.Println("track ID:", tkhd.TrackID)
}
// get basic informations
info, err := mp4.Probe(bufseekio.NewReadSeeker(file, 1024, 4))  
if err != nil {
   :
}
fmt.Println("track num:", len(info.Tracks))

Writing

Writer helps you to write box tree. The following sample code edits emsg box and writes to another file.

r := bufseekio.NewReadSeeker(inputFile, 128*1024, 4)
w := mp4.NewWriter(outputFile)
_, err = mp4.ReadBoxStructure(r, func(h *mp4.ReadHandle) (interface{}, error) {
	switch h.BoxInfo.Type {
	case mp4.BoxTypeEmsg():
		// write box size and box type
		_, err := w.StartBox(&h.BoxInfo)
		if err != nil {
			return nil, err
		}
		// read payload
		box, _, err := h.ReadPayload()
		if err != nil {
			return nil, err
		}
		// update MessageData
		emsg := box.(*mp4.Emsg)
		emsg.MessageData = []byte("hello world")
		// write box playload
		if _, err := mp4.Marshal(w, emsg, h.BoxInfo.Context); err != nil {
			return nil, err
		}
		// rewrite box size
		_, err = w.EndBox()
		return nil, err
	default:
		// copy all
		return nil, w.CopyBox(r, &h.BoxInfo)
	}
})

User-defined Boxes

You can create additional box definition as follows:

func BoxTypeXxxx() BoxType { return mp4.StrToBoxType("xxxx") }

func init() {
	mp4.AddBoxDef(&Xxxx{}, 0)
}

type Xxxx struct {
	FullBox  `mp4:"0,extend"`
	UI32      uint32 `mp4:"1,size=32"`
	ByteArray []byte `mp4:"2,size=8,len=dynamic"`
}

func (*Xxxx) GetType() BoxType {
	return BoxTypeXxxx()
}

Buffering

go-mp4 has no buffering feature for I/O. If you should reduce Read function calls, you can wrap the io.ReadSeeker by bufseekio.

Command Line Tool

Install mp4tool as follows:

go install github.com/abema/go-mp4/cmd/mp4tool@latest

mp4tool -help

For example, mp4tool dump MP4_FILE_NAME command prints MP4 box tree as follows:

[moof] Size=504
  [mfhd] Size=16 Version=0 Flags=0x000000 SequenceNumber=1
  [traf] Size=480
    [tfhd] Size=28 Version=0 Flags=0x020038 TrackID=1 DefaultSampleDuration=9000 DefaultSampleSize=33550 DefaultSampleFlags=0x1010000
    [tfdt] Size=20 Version=1 Flags=0x000000 BaseMediaDecodeTimeV1=0
    [trun] Size=424 ... (use -a option to show all)
[mdat] Size=44569 Data=[...] (use -mdat option to expand)

Documentation

Index

Constants

View Source
const (
	SmallHeaderSize = 8
	LargeHeaderSize = 16
)
View Source
const (
	AVCBaselineProfile uint8 = 66  // 0x42
	AVCMainProfile     uint8 = 77  // 0x4d
	AVCExtendedProfile uint8 = 88  // 0x58
	AVCHighProfile     uint8 = 100 // 0x64
	AVCHigh10Profile   uint8 = 110 // 0x6e
	AVCHigh422Profile  uint8 = 122 // 0x7a
)
View Source
const (
	TfhdBaseDataOffsetPresent         = 0x000001
	TfhdSampleDescriptionIndexPresent = 0x000002
	TfhdDefaultSampleDurationPresent  = 0x000008
	TfhdDefaultSampleSizePresent      = 0x000010
	TfhdDefaultSampleFlagsPresent     = 0x000020
	TfhdDurationIsEmpty               = 0x010000
	TfhdDefaultBaseIsMoof             = 0x020000
)
View Source
const (
	ESDescrTag            = 0x03
	DecoderConfigDescrTag = 0x04
	DecSpecificInfoTag    = 0x05
	SLConfigDescrTag      = 0x06
)
View Source
const (
	DataTypeBinary             = 0
	DataTypeStringUTF8         = 1
	DataTypeStringUTF16        = 2
	DataTypeStringMac          = 3
	DataTypeStringJPEG         = 14
	DataTypeSignedIntBigEndian = 21
	DataTypeFloat32BigEndian   = 22
	DataTypeFloat64BigEndian   = 23
)
View Source
const LengthUnlimited = math.MaxUint32
View Source
const UrlSelfContained = 0x000001
View Source
const UrnSelfContained = 0x000001

Variables

View Source
var ErrBoxInfoNotFound = errors.New("box info not found")
View Source
var ErrUnsupportedBoxVersion = errors.New("unsupported box version")

Functions

func AddAnyTypeBoxDef

func AddAnyTypeBoxDef(payload IAnyType, boxType BoxType, versions ...uint8)

func AddAnyTypeBoxDefEx added in v0.4.0

func AddAnyTypeBoxDefEx(payload IAnyType, boxType BoxType, isTarget func(Context) bool, versions ...uint8)

func AddBoxDef

func AddBoxDef(payload IBox, versions ...uint8)

func AddBoxDefEx added in v0.4.0

func AddBoxDefEx(payload IBox, isTarget func(Context) bool, versions ...uint8)

func BrandAVC1 added in v0.6.0

func BrandAVC1() [4]byte

func BrandISO2 added in v0.6.0

func BrandISO2() [4]byte

func BrandISO3 added in v0.6.0

func BrandISO3() [4]byte

func BrandISO4 added in v0.6.0

func BrandISO4() [4]byte

func BrandISO5 added in v0.6.0

func BrandISO5() [4]byte

func BrandISO6 added in v0.6.0

func BrandISO6() [4]byte

func BrandISO7 added in v0.6.0

func BrandISO7() [4]byte

func BrandISO8 added in v0.6.0

func BrandISO8() [4]byte

func BrandISO9 added in v0.6.0

func BrandISO9() [4]byte

func BrandISOM added in v0.6.0

func BrandISOM() [4]byte

func BrandMP41 added in v0.6.0

func BrandMP41() [4]byte

func BrandMP71 added in v0.6.0

func BrandMP71() [4]byte

func BrandQT added in v0.6.0

func BrandQT() [4]byte

func FindIDRFrames added in v0.6.0

func FindIDRFrames(r io.ReadSeeker, trackInfo *TrackInfo) ([]int, error)

func IsIlstMetaBoxType added in v0.4.0

func IsIlstMetaBoxType(boxType BoxType) bool

func Marshal

func Marshal(w io.Writer, src IImmutableBox, ctx Context) (n uint64, err error)

func ReadBoxStructure

func ReadBoxStructure(r io.ReadSeeker, handler ReadHandler, params ...interface{}) ([]interface{}, error)

func ReadBoxStructureFromInternal

func ReadBoxStructureFromInternal(r io.ReadSeeker, bi *BoxInfo, handler ReadHandler, params ...interface{}) (interface{}, error)

func Stringify

func Stringify(src IImmutableBox, ctx Context) (string, error)

func StringifyWithIndent

func StringifyWithIndent(src IImmutableBox, indent string, ctx Context) (string, error)

func Unmarshal

func Unmarshal(r io.ReadSeeker, payloadSize uint64, dst IBox, ctx Context) (n uint64, err error)

Types

type AVCDecConfigInfo added in v0.6.0

type AVCDecConfigInfo struct {
	ConfigurationVersion uint8
	Profile              uint8
	ProfileCompatibility uint8
	Level                uint8
	LengthSize           uint16
	Width                uint16
	Height               uint16
}

type AVCDecoderConfiguration

type AVCDecoderConfiguration struct {
	AnyTypeBox
	ConfigurationVersion         uint8             `mp4:"0,size=8"`
	Profile                      uint8             `mp4:"1,size=8"`
	ProfileCompatibility         uint8             `mp4:"2,size=8"`
	Level                        uint8             `mp4:"3,size=8"`
	Reserved                     uint8             `mp4:"4,size=6,const=63"`
	LengthSizeMinusOne           uint8             `mp4:"5,size=2"`
	Reserved2                    uint8             `mp4:"6,size=3,const=7"`
	NumOfSequenceParameterSets   uint8             `mp4:"7,size=5"`
	SequenceParameterSets        []AVCParameterSet `mp4:"8,len=dynamic"`
	NumOfPictureParameterSets    uint8             `mp4:"9,size=8"`
	PictureParameterSets         []AVCParameterSet `mp4:"10,len=dynamic"`
	HighProfileFieldsEnabled     bool              `mp4:"11,hidden"`
	Reserved3                    uint8             `mp4:"12,size=6,opt=dynamic,const=63"`
	ChromaFormat                 uint8             `mp4:"13,size=2,opt=dynamic"`
	Reserved4                    uint8             `mp4:"14,size=5,opt=dynamic,const=31"`
	BitDepthLumaMinus8           uint8             `mp4:"15,size=3,opt=dynamic"`
	Reserved5                    uint8             `mp4:"16,size=5,opt=dynamic,const=31"`
	BitDepthChromaMinus8         uint8             `mp4:"17,size=3,opt=dynamic"`
	NumOfSequenceParameterSetExt uint8             `mp4:"18,size=8,opt=dynamic"`
	SequenceParameterSetsExt     []AVCParameterSet `mp4:"19,len=dynamic,opt=dynamic"`
}

func (*AVCDecoderConfiguration) GetFieldLength added in v0.3.0

func (avcc *AVCDecoderConfiguration) GetFieldLength(name string, ctx Context) uint

func (*AVCDecoderConfiguration) IsOptFieldEnabled added in v0.3.0

func (avcc *AVCDecoderConfiguration) IsOptFieldEnabled(name string, ctx Context) bool

func (*AVCDecoderConfiguration) OnReadField added in v0.3.0

func (avcc *AVCDecoderConfiguration) OnReadField(name string, r bitio.ReadSeeker, leftBits uint64, ctx Context) (rbits uint64, override bool, err error)

func (*AVCDecoderConfiguration) OnWriteField added in v0.3.0

func (avcc *AVCDecoderConfiguration) OnWriteField(name string, w bitio.Writer, ctx Context) (wbits uint64, override bool, err error)

type AVCParameterSet added in v0.3.0

type AVCParameterSet struct {
	BaseCustomFieldObject
	Length  uint16 `mp4:"0,size=16"`
	NALUnit []byte `mp4:"1,size=8,len=dynamic"`
}

func (*AVCParameterSet) GetFieldLength added in v0.3.0

func (s *AVCParameterSet) GetFieldLength(name string, ctx Context) uint

type AlternativeStartupEntry added in v0.3.0

type AlternativeStartupEntry struct {
	BaseCustomFieldObject
	RollCount         uint16                       `mp4:"0,size=16"`
	FirstOutputSample uint16                       `mp4:"1,size=16"`
	SampleOffset      []uint32                     `mp4:"2,size=32,len=dynamic"`
	Opts              []AlternativeStartupEntryOpt `mp4:"3,size=32"`
}

func (*AlternativeStartupEntry) GetFieldLength added in v0.3.0

func (entry *AlternativeStartupEntry) GetFieldLength(name string, ctx Context) uint

type AlternativeStartupEntryL added in v0.3.0

type AlternativeStartupEntryL struct {
	DescriptionLength       uint32 `mp4:"0,size=32"`
	AlternativeStartupEntry `mp4:"1,extend,size=dynamic"`
}

func (*AlternativeStartupEntryL) GetFieldSize added in v0.3.0

func (entry *AlternativeStartupEntryL) GetFieldSize(name string, ctx Context) uint

type AlternativeStartupEntryOpt added in v0.3.0

type AlternativeStartupEntryOpt struct {
	NumOutputSamples uint16 `mp4:"0,size=16"`
	NumTotalSamples  uint16 `mp4:"1,size=16"`
}

type AnyTypeBox

type AnyTypeBox struct {
	Box
	Type BoxType
}

func (*AnyTypeBox) GetType

func (e *AnyTypeBox) GetType() BoxType

func (*AnyTypeBox) SetType

func (e *AnyTypeBox) SetType(boxType BoxType)

type AudioSampleEntry

type AudioSampleEntry struct {
	SampleEntry   `mp4:"0,extend,opt=dynamic"`
	EntryVersion  uint16    `mp4:"1,size=16,opt=dynamic"`
	Reserved      [3]uint16 `mp4:"2,size=16,opt=dynamic,const=0"`
	ChannelCount  uint16    `mp4:"3,size=16,opt=dynamic"`
	SampleSize    uint16    `mp4:"4,size=16,opt=dynamic"`
	PreDefined    uint16    `mp4:"5,size=16,opt=dynamic"`
	Reserved2     uint16    `mp4:"6,size=16,opt=dynamic,const=0"`
	SampleRate    uint32    `mp4:"7,size=32,opt=dynamic"` // fixed-point 16.16
	QuickTimeData []byte    `mp4:"8,size=8,opt=dynamic,len=dynamic"`
}

func (*AudioSampleEntry) GetFieldLength added in v0.4.0

func (ase *AudioSampleEntry) GetFieldLength(name string, ctx Context) uint

func (*AudioSampleEntry) GetSampleRate added in v0.12.0

func (ase *AudioSampleEntry) GetSampleRate() float64

func (*AudioSampleEntry) GetSampleRateInt added in v0.12.0

func (ase *AudioSampleEntry) GetSampleRateInt() uint16

func (*AudioSampleEntry) IsOptFieldEnabled added in v0.4.0

func (ase *AudioSampleEntry) IsOptFieldEnabled(name string, ctx Context) bool

func (*AudioSampleEntry) StringifyField added in v0.12.0

func (ase *AudioSampleEntry) StringifyField(name string, indent string, depth int, ctx Context) (string, bool)

StringifyField returns field value as string

type Av1C added in v0.12.0

type Av1C struct {
	Box
	Marker                           uint8   `mp4:"0,size=1,const=1"`
	Version                          uint8   `mp4:"1,size=7,const=1"`
	SeqProfile                       uint8   `mp4:"2,size=3"`
	SeqLevelIdx0                     uint8   `mp4:"3,size=5"`
	SeqTier0                         uint8   `mp4:"4,size=1"`
	HighBitdepth                     uint8   `mp4:"5,size=1"`
	TwelveBit                        uint8   `mp4:"6,size=1"`
	Monochrome                       uint8   `mp4:"7,size=1"`
	ChromaSubsamplingX               uint8   `mp4:"8,size=1"`
	ChromaSubsamplingY               uint8   `mp4:"9,size=1"`
	ChromaSamplePosition             uint8   `mp4:"10,size=2"`
	Reserved                         uint8   `mp4:"11,size=3,const=0"`
	InitialPresentationDelayPresent  uint8   `mp4:"12,size=1"`
	InitialPresentationDelayMinusOne uint8   `mp4:"13,size=4"`
	ConfigOBUs                       []uint8 `mp4:"14,size=8"`
}

func (Av1C) GetType added in v0.12.0

func (Av1C) GetType() BoxType

type BaseCustomFieldObject

type BaseCustomFieldObject struct {
}

func (*BaseCustomFieldObject) BeforeUnmarshal

func (*BaseCustomFieldObject) GetFieldLength

func (box *BaseCustomFieldObject) GetFieldLength(string, Context) uint

GetFieldLength returns length of dynamic field

func (*BaseCustomFieldObject) GetFieldSize

func (box *BaseCustomFieldObject) GetFieldSize(string, Context) uint

GetFieldSize returns size of dynamic field

func (*BaseCustomFieldObject) IsOptFieldEnabled

func (box *BaseCustomFieldObject) IsOptFieldEnabled(string, Context) bool

IsOptFieldEnabled check whether if the optional field is enabled

func (*BaseCustomFieldObject) IsPString

func (*BaseCustomFieldObject) IsPString(name string, bytes []byte, remainingSize uint64, ctx Context) bool

func (*BaseCustomFieldObject) OnReadField added in v0.3.0

func (*BaseCustomFieldObject) OnWriteField added in v0.3.0

func (*BaseCustomFieldObject) StringifyField

func (box *BaseCustomFieldObject) StringifyField(string, string, int, Context) (string, bool)

StringifyField returns field value as string

type Box

type Box struct {
	BaseCustomFieldObject
}

func (*Box) AddFlag

func (box *Box) AddFlag(flag uint32)

AddFlag adds the flag

func (*Box) CheckFlag

func (box *Box) CheckFlag(flag uint32) bool

CheckFlag checks the flag status

func (*Box) GetFlags

func (box *Box) GetFlags() uint32

GetFlags returns the flags

func (*Box) GetVersion

func (box *Box) GetVersion() uint8

GetVersion returns the box version

func (*Box) RemoveFlag

func (box *Box) RemoveFlag(flag uint32)

RemoveFlag removes the flag

func (*Box) SetFlags

func (box *Box) SetFlags(uint32)

SetFlags sets the flags

func (*Box) SetVersion

func (box *Box) SetVersion(uint8)

SetVersion sets the box version

type BoxInfo

type BoxInfo struct {
	// Offset specifies an offset of the box in a file.
	Offset uint64

	// Size specifies size(bytes) of box.
	Size uint64

	// HeaderSize specifies size(bytes) of common fields which are defined as "Box" class member at ISO/IEC 14496-12.
	HeaderSize uint64

	// Type specifies box type which is represented by 4 characters.
	Type BoxType

	// ExtendToEOF is set true when Box.size is zero. It means that end of box equals to end of file.
	ExtendToEOF bool

	// Context would be set by ReadBoxStructure, not ReadBoxInfo.
	Context
}

BoxInfo has common infomations of box

func ExtractBox

func ExtractBox(r io.ReadSeeker, parent *BoxInfo, path BoxPath) ([]*BoxInfo, error)

func ExtractBoxes

func ExtractBoxes(r io.ReadSeeker, parent *BoxInfo, paths []BoxPath) ([]*BoxInfo, error)

func ReadBoxInfo

func ReadBoxInfo(r io.ReadSeeker) (*BoxInfo, error)

ReadBoxInfo reads common fields which are defined as "Box" class member at ISO/IEC 14496-12.

func WriteBoxInfo

func WriteBoxInfo(w io.WriteSeeker, bi *BoxInfo) (*BoxInfo, error)

WriteBoxInfo writes common fields which are defined as "Box" class member at ISO/IEC 14496-12. This function ignores bi.Offset and returns BoxInfo which contains real Offset and recalculated Size/HeaderSize.

func (*BoxInfo) IsSupportedType added in v0.4.0

func (bi *BoxInfo) IsSupportedType() bool

func (*BoxInfo) SeekToEnd

func (bi *BoxInfo) SeekToEnd(s io.Seeker) (int64, error)

func (*BoxInfo) SeekToPayload

func (bi *BoxInfo) SeekToPayload(s io.Seeker) (int64, error)

func (*BoxInfo) SeekToStart

func (bi *BoxInfo) SeekToStart(s io.Seeker) (int64, error)

type BoxInfoWithPayload

type BoxInfoWithPayload struct {
	Info    BoxInfo
	Payload IBox
}

func ExtractBoxWithPayload

func ExtractBoxWithPayload(r io.ReadSeeker, parent *BoxInfo, path BoxPath) ([]*BoxInfoWithPayload, error)

func ExtractBoxesWithPayload

func ExtractBoxesWithPayload(r io.ReadSeeker, parent *BoxInfo, paths []BoxPath) ([]*BoxInfoWithPayload, error)

type BoxPath

type BoxPath []BoxType

type BoxType

type BoxType [4]byte

BoxType is mpeg box type

func BoxTypeAC3 added in v1.1.0

func BoxTypeAC3() BoxType

func BoxTypeAny added in v0.2.0

func BoxTypeAny() BoxType

func BoxTypeAv01 added in v0.12.0

func BoxTypeAv01() BoxType

func BoxTypeAv1C added in v0.12.0

func BoxTypeAv1C() BoxType

func BoxTypeAvc1 added in v0.6.0

func BoxTypeAvc1() BoxType

func BoxTypeAvcC added in v0.6.0

func BoxTypeAvcC() BoxType

func BoxTypeBtrt added in v0.4.0

func BoxTypeBtrt() BoxType

func BoxTypeCo64 added in v0.3.0

func BoxTypeCo64() BoxType

func BoxTypeColr added in v0.3.0

func BoxTypeColr() BoxType

func BoxTypeCslg added in v0.4.0

func BoxTypeCslg() BoxType

func BoxTypeCtts

func BoxTypeCtts() BoxType

func BoxTypeDAC3 added in v1.1.0

func BoxTypeDAC3() BoxType

func BoxTypeDOps added in v0.12.0

func BoxTypeDOps() BoxType

func BoxTypeData added in v0.4.0

func BoxTypeData() BoxType

func BoxTypeDinf

func BoxTypeDinf() BoxType

func BoxTypeDref

func BoxTypeDref() BoxType

func BoxTypeEdts

func BoxTypeEdts() BoxType

func BoxTypeElst

func BoxTypeElst() BoxType

func BoxTypeEmsg

func BoxTypeEmsg() BoxType

func BoxTypeEnca added in v0.6.0

func BoxTypeEnca() BoxType

func BoxTypeEncv added in v0.6.0

func BoxTypeEncv() BoxType

func BoxTypeEsds

func BoxTypeEsds() BoxType

func BoxTypeFiel added in v0.9.0

func BoxTypeFiel() BoxType

func BoxTypeFpcm added in v1.2.0

func BoxTypeFpcm() BoxType

func BoxTypeFree

func BoxTypeFree() BoxType

func BoxTypeFrma added in v0.4.0

func BoxTypeFrma() BoxType

func BoxTypeFtyp

func BoxTypeFtyp() BoxType

func BoxTypeHdlr

func BoxTypeHdlr() BoxType

func BoxTypeHev1 added in v0.9.0

func BoxTypeHev1() BoxType

func BoxTypeHvc1 added in v0.10.0

func BoxTypeHvc1() BoxType

func BoxTypeHvcC added in v0.9.0

func BoxTypeHvcC() BoxType

func BoxTypeIlst added in v0.3.0

func BoxTypeIlst() BoxType

func BoxTypeIpcm added in v1.2.0

func BoxTypeIpcm() BoxType

func BoxTypeKeys added in v1.2.0

func BoxTypeKeys() BoxType

func BoxTypeMdat

func BoxTypeMdat() BoxType

func BoxTypeMdhd

func BoxTypeMdhd() BoxType

func BoxTypeMdia

func BoxTypeMdia() BoxType

func BoxTypeMehd

func BoxTypeMehd() BoxType

func BoxTypeMeta

func BoxTypeMeta() BoxType

func BoxTypeMfhd

func BoxTypeMfhd() BoxType

func BoxTypeMfra

func BoxTypeMfra() BoxType

func BoxTypeMfro

func BoxTypeMfro() BoxType

func BoxTypeMinf

func BoxTypeMinf() BoxType

func BoxTypeMoof

func BoxTypeMoof() BoxType

func BoxTypeMoov

func BoxTypeMoov() BoxType

func BoxTypeMp4a added in v0.6.0

func BoxTypeMp4a() BoxType

func BoxTypeMp4v added in v1.1.0

func BoxTypeMp4v() BoxType

func BoxTypeMvex

func BoxTypeMvex() BoxType

func BoxTypeMvhd

func BoxTypeMvhd() BoxType

func BoxTypeOpus added in v0.12.0

func BoxTypeOpus() BoxType

func BoxTypePasp added in v0.6.0

func BoxTypePasp() BoxType

func BoxTypePcmC added in v1.2.0

func BoxTypePcmC() BoxType

func BoxTypePssh

func BoxTypePssh() BoxType

func BoxTypeSaio added in v0.4.0

func BoxTypeSaio() BoxType

func BoxTypeSaiz added in v0.4.0

func BoxTypeSaiz() BoxType

func BoxTypeSbgp

func BoxTypeSbgp() BoxType

func BoxTypeSchi added in v0.3.0

func BoxTypeSchi() BoxType

func BoxTypeSchm added in v0.4.0

func BoxTypeSchm() BoxType

func BoxTypeSdtp added in v0.4.0

func BoxTypeSdtp() BoxType

func BoxTypeSgpd

func BoxTypeSgpd() BoxType

func BoxTypeSidx added in v0.2.0

func BoxTypeSidx() BoxType

func BoxTypeSinf added in v0.3.0

func BoxTypeSinf() BoxType

func BoxTypeSkip

func BoxTypeSkip() BoxType

func BoxTypeSmhd

func BoxTypeSmhd() BoxType

func BoxTypeStbl

func BoxTypeStbl() BoxType

func BoxTypeStco

func BoxTypeStco() BoxType

func BoxTypeStsc

func BoxTypeStsc() BoxType

func BoxTypeStsd

func BoxTypeStsd() BoxType

func BoxTypeStss

func BoxTypeStss() BoxType

func BoxTypeStsz

func BoxTypeStsz() BoxType

func BoxTypeStts

func BoxTypeStts() BoxType

func BoxTypeStyp added in v0.2.0

func BoxTypeStyp() BoxType

func BoxTypeTenc added in v0.4.0

func BoxTypeTenc() BoxType

func BoxTypeTfdt

func BoxTypeTfdt() BoxType

func BoxTypeTfhd

func BoxTypeTfhd() BoxType

func BoxTypeTfra

func BoxTypeTfra() BoxType

func BoxTypeTkhd

func BoxTypeTkhd() BoxType

func BoxTypeTraf

func BoxTypeTraf() BoxType

func BoxTypeTrak

func BoxTypeTrak() BoxType

func BoxTypeTrep added in v0.4.0

func BoxTypeTrep() BoxType

func BoxTypeTrex

func BoxTypeTrex() BoxType

func BoxTypeTrun

func BoxTypeTrun() BoxType

func BoxTypeUdta

func BoxTypeUdta() BoxType

func BoxTypeUrl

func BoxTypeUrl() BoxType

func BoxTypeUrn

func BoxTypeUrn() BoxType

func BoxTypeVmhd

func BoxTypeVmhd() BoxType

func BoxTypeVp08 added in v0.13.0

func BoxTypeVp08() BoxType

func BoxTypeVp09 added in v0.13.0

func BoxTypeVp09() BoxType

func BoxTypeVpcC added in v0.13.0

func BoxTypeVpcC() BoxType

func BoxTypeWave added in v0.4.0

func BoxTypeWave() BoxType

func StrToBoxType

func StrToBoxType(code string) BoxType

func Uint32ToBoxType added in v1.2.0

func Uint32ToBoxType(i uint32) BoxType

Uint32ToBoxType returns a new BoxType from the provied uint32

func (BoxType) GetSupportedVersions

func (boxType BoxType) GetSupportedVersions(ctx Context) ([]uint8, error)

func (BoxType) IsSupported

func (boxType BoxType) IsSupported(ctx Context) bool

func (BoxType) IsSupportedVersion

func (boxType BoxType) IsSupportedVersion(ver uint8, ctx Context) bool

func (BoxType) MatchWith added in v0.2.0

func (lhs BoxType) MatchWith(rhs BoxType) bool

func (BoxType) New

func (boxType BoxType) New(ctx Context) (IBox, error)

func (BoxType) String

func (boxType BoxType) String() string

type Btrt added in v0.4.0

type Btrt struct {
	Box
	BufferSizeDB uint32 `mp4:"0,size=32"`
	MaxBitrate   uint32 `mp4:"1,size=32"`
	AvgBitrate   uint32 `mp4:"2,size=32"`
}

func (*Btrt) GetType added in v0.4.0

func (*Btrt) GetType() BoxType

GetType returns the BoxType

type Chunk added in v0.6.0

type Chunk struct {
	DataOffset      uint64
	SamplesPerChunk uint32
}

type Chunks added in v0.6.0

type Chunks []*Chunk

type Co64 added in v0.3.0

type Co64 struct {
	FullBox     `mp4:"0,extend"`
	EntryCount  uint32   `mp4:"1,size=32"`
	ChunkOffset []uint64 `mp4:"2,size=64,len=dynamic"`
}

func (*Co64) GetFieldLength added in v0.3.0

func (co64 *Co64) GetFieldLength(name string, ctx Context) uint

GetFieldLength returns length of dynamic field

func (*Co64) GetType added in v0.3.0

func (*Co64) GetType() BoxType

GetType returns the BoxType

type Codec added in v0.6.0

type Codec int
const (
	CodecUnknown Codec = iota
	CodecAVC1
	CodecMP4A
)

type Colr added in v0.3.0

type Colr struct {
	Box
	ColourType              [4]byte `mp4:"0,size=8,string"`
	ColourPrimaries         uint16  `mp4:"1,size=16,opt=dynamic"`
	TransferCharacteristics uint16  `mp4:"2,size=16,opt=dynamic"`
	MatrixCoefficients      uint16  `mp4:"3,size=16,opt=dynamic"`
	FullRangeFlag           bool    `mp4:"4,size=1,opt=dynamic"`
	Reserved                uint8   `mp4:"5,size=7,opt=dynamic"`
	Profile                 []byte  `mp4:"6,size=8,opt=dynamic"`
	Unknown                 []byte  `mp4:"7,size=8,opt=dynamic"`
}

func (*Colr) GetType added in v0.3.0

func (*Colr) GetType() BoxType

GetType returns the BoxType

func (*Colr) IsOptFieldEnabled added in v0.3.0

func (colr *Colr) IsOptFieldEnabled(name string, ctx Context) bool

type CompatibleBrandElem

type CompatibleBrandElem struct {
	CompatibleBrand [4]byte `mp4:"0,size=8,string"`
}

type Context added in v0.4.0

type Context struct {
	// IsQuickTimeCompatible represents whether ftyp.compatible_brands contains "qt  ".
	IsQuickTimeCompatible bool

	// QuickTimeKeysMetaEntryCount the expected number of items under the ilst box as observed from the keys box
	QuickTimeKeysMetaEntryCount int

	// UnderWave represents whether current box is under the wave box.
	UnderWave bool

	// UnderIlst represents whether current box is under the ilst box.
	UnderIlst bool

	// UnderIlstMeta represents whether current box is under the metadata box under the ilst box.
	UnderIlstMeta bool

	// UnderIlstFreeMeta represents whether current box is under "----" box.
	UnderIlstFreeMeta bool

	// UnderUdta represents whether current box is under the udta box.
	UnderUdta bool
}

type Cslg added in v0.4.0

type Cslg struct {
	FullBox                        `mp4:"0,extend"`
	CompositionToDTSShiftV0        int32 `mp4:"1,size=32,ver=0"`
	LeastDecodeToDisplayDeltaV0    int32 `mp4:"2,size=32,ver=0"`
	GreatestDecodeToDisplayDeltaV0 int32 `mp4:"3,size=32,ver=0"`
	CompositionStartTimeV0         int32 `mp4:"4,size=32,ver=0"`
	CompositionEndTimeV0           int32 `mp4:"5,size=32,ver=0"`
	CompositionToDTSShiftV1        int64 `mp4:"6,size=64,nver=0"`
	LeastDecodeToDisplayDeltaV1    int64 `mp4:"7,size=64,nver=0"`
	GreatestDecodeToDisplayDeltaV1 int64 `mp4:"8,size=64,nver=0"`
	CompositionStartTimeV1         int64 `mp4:"9,size=64,nver=0"`
	CompositionEndTimeV1           int64 `mp4:"10,size=64,nver=0"`
}

func (*Cslg) GetCompositionEndTime added in v0.8.0

func (cslg *Cslg) GetCompositionEndTime() int64

func (*Cslg) GetCompositionStartTime added in v0.8.0

func (cslg *Cslg) GetCompositionStartTime() int64

func (*Cslg) GetCompositionToDTSShift added in v0.8.0

func (cslg *Cslg) GetCompositionToDTSShift() int64

func (*Cslg) GetGreatestDecodeToDisplayDelta added in v0.8.0

func (cslg *Cslg) GetGreatestDecodeToDisplayDelta() int64

func (*Cslg) GetLeastDecodeToDisplayDelta added in v0.8.0

func (cslg *Cslg) GetLeastDecodeToDisplayDelta() int64

func (*Cslg) GetType added in v0.4.0

func (*Cslg) GetType() BoxType

GetType returns the BoxType

type Ctts

type Ctts struct {
	FullBox    `mp4:"0,extend"`
	EntryCount uint32      `mp4:"1,size=32"`
	Entries    []CttsEntry `mp4:"2,len=dynamic,size=64"`
}

func (*Ctts) GetFieldLength

func (ctts *Ctts) GetFieldLength(name string, ctx Context) uint

GetFieldLength returns length of dynamic field

func (*Ctts) GetSampleOffset added in v0.8.0

func (ctts *Ctts) GetSampleOffset(index int) int64

func (*Ctts) GetType

func (*Ctts) GetType() BoxType

GetType returns the BoxType

type CttsEntry

type CttsEntry struct {
	SampleCount    uint32 `mp4:"0,size=32"`
	SampleOffsetV0 uint32 `mp4:"1,size=32,ver=0"`
	SampleOffsetV1 int32  `mp4:"2,size=32,ver=1"`
}

type DOps added in v0.12.0

type DOps struct {
	Box
	Version              uint8   `mp4:"0,size=8"`
	OutputChannelCount   uint8   `mp4:"1,size=8"`
	PreSkip              uint16  `mp4:"2,size=16"`
	InputSampleRate      uint32  `mp4:"3,size=32"`
	OutputGain           int16   `mp4:"4,size=16"`
	ChannelMappingFamily uint8   `mp4:"5,size=8"`
	StreamCount          uint8   `mp4:"6,opt=dynamic,size=8"`
	CoupledCount         uint8   `mp4:"7,opt=dynamic,size=8"`
	ChannelMapping       []uint8 `mp4:"8,opt=dynamic,size=8,len=dynamic"`
}

func (DOps) GetFieldLength added in v0.12.0

func (ops DOps) GetFieldLength(name string, ctx Context) uint

func (DOps) GetType added in v0.12.0

func (DOps) GetType() BoxType

func (DOps) IsOptFieldEnabled added in v0.12.0

func (dops DOps) IsOptFieldEnabled(name string, ctx Context) bool

type Dac3 added in v1.1.0

type Dac3 struct {
	Box
	Fscod       uint8 `mp4:"0,size=2"`
	Bsid        uint8 `mp4:"1,size=5"`
	Bsmod       uint8 `mp4:"2,size=3"`
	Acmod       uint8 `mp4:"3,size=3"`
	LfeOn       uint8 `mp4:"4,size=1"`
	BitRateCode uint8 `mp4:"5,size=5"`
	Reserved    uint8 `mp4:"6,size=5,const=0"`
}

func (Dac3) GetType added in v1.1.0

func (Dac3) GetType() BoxType

type Data added in v0.4.0

type Data struct {
	Box
	DataType uint32 `mp4:"0,size=32"`
	DataLang uint32 `mp4:"1,size=32"`
	Data     []byte `mp4:"2,size=8"`
}

Data is a Value BoxType https://developer.apple.com/documentation/quicktime-file-format/value_atom

func (*Data) GetType added in v0.4.0

func (*Data) GetType() BoxType

GetType returns the BoxType

func (*Data) StringifyField added in v0.4.0

func (data *Data) StringifyField(name string, indent string, depth int, ctx Context) (string, bool)

StringifyField returns field value as string

type DecoderConfigDescriptor

type DecoderConfigDescriptor struct {
	BaseCustomFieldObject
	ObjectTypeIndication byte   `mp4:"0,size=8"`
	StreamType           int8   `mp4:"1,size=6"`
	UpStream             bool   `mp4:"2,size=1"`
	Reserved             bool   `mp4:"3,size=1"`
	BufferSizeDB         uint32 `mp4:"4,size=24"`
	MaxBitrate           uint32 `mp4:"5,size=32"`
	AvgBitrate           uint32 `mp4:"6,size=32"`
}

type Descriptor

type Descriptor struct {
	BaseCustomFieldObject
	Tag                     int8                     `mp4:"0,size=8"` // must be 0x03
	Size                    uint32                   `mp4:"1,varint"`
	ESDescriptor            *ESDescriptor            `mp4:"2,extend,opt=dynamic"`
	DecoderConfigDescriptor *DecoderConfigDescriptor `mp4:"3,extend,opt=dynamic"`
	Data                    []byte                   `mp4:"4,size=8,opt=dynamic,len=dynamic"`
}

func (*Descriptor) GetFieldLength

func (ds *Descriptor) GetFieldLength(name string, ctx Context) uint

GetFieldLength returns length of dynamic field

func (*Descriptor) IsOptFieldEnabled

func (ds *Descriptor) IsOptFieldEnabled(name string, ctx Context) bool

func (*Descriptor) StringifyField

func (ds *Descriptor) StringifyField(name string, indent string, depth int, ctx Context) (string, bool)

StringifyField returns field value as string

type Dinf

type Dinf struct {
	Box
}

Dinf is ISOBMFF dinf box type

func (*Dinf) GetType

func (*Dinf) GetType() BoxType

GetType returns the BoxType

type Dref

type Dref struct {
	FullBox    `mp4:"0,extend"`
	EntryCount uint32 `mp4:"1,size=32"`
}

Dref is ISOBMFF dref box type

func (*Dref) GetType

func (*Dref) GetType() BoxType

GetType returns the BoxType

type ESDescriptor

type ESDescriptor struct {
	BaseCustomFieldObject
	ESID                 uint16 `mp4:"0,size=16"`
	StreamDependenceFlag bool   `mp4:"1,size=1"`
	UrlFlag              bool   `mp4:"2,size=1"`
	OcrStreamFlag        bool   `mp4:"3,size=1"`
	StreamPriority       int8   `mp4:"4,size=5"`
	DependsOnESID        uint16 `mp4:"5,size=16,opt=dynamic"`
	URLLength            uint8  `mp4:"6,size=8,opt=dynamic"`
	URLString            []byte `mp4:"7,size=8,len=dynamic,opt=dynamic,string"`
	OCRESID              uint16 `mp4:"8,size=16,opt=dynamic"`
}

func (*ESDescriptor) GetFieldLength

func (esds *ESDescriptor) GetFieldLength(name string, ctx Context) uint

func (*ESDescriptor) IsOptFieldEnabled

func (esds *ESDescriptor) IsOptFieldEnabled(name string, ctx Context) bool

type EditList added in v0.6.0

type EditList []*EditListEntry

type EditListEntry added in v0.6.0

type EditListEntry struct {
	MediaTime       int64
	SegmentDuration uint64
}

type Edts

type Edts struct {
	Box
}

Edts is ISOBMFF edts box type

func (*Edts) GetType

func (*Edts) GetType() BoxType

GetType returns the BoxType

type Elst

type Elst struct {
	FullBox    `mp4:"0,extend"`
	EntryCount uint32      `mp4:"1,size=32"`
	Entries    []ElstEntry `mp4:"2,len=dynamic,size=dynamic"`
}

Elst is ISOBMFF elst box type

func (*Elst) GetFieldLength

func (elst *Elst) GetFieldLength(name string, ctx Context) uint

GetFieldLength returns length of dynamic field

func (*Elst) GetFieldSize

func (elst *Elst) GetFieldSize(name string, ctx Context) uint

GetFieldSize returns size of dynamic field

func (*Elst) GetMediaTime added in v0.8.0

func (elst *Elst) GetMediaTime(index int) int64

func (*Elst) GetSegmentDuration added in v0.8.0

func (elst *Elst) GetSegmentDuration(index int) uint64

func (*Elst) GetType

func (*Elst) GetType() BoxType

GetType returns the BoxType

type ElstEntry

type ElstEntry struct {
	SegmentDurationV0 uint32 `mp4:"0,size=32,ver=0"`
	MediaTimeV0       int32  `mp4:"1,size=32,ver=0"`
	SegmentDurationV1 uint64 `mp4:"2,size=64,ver=1"`
	MediaTimeV1       int64  `mp4:"3,size=64,ver=1"`
	MediaRateInteger  int16  `mp4:"4,size=16"`
	MediaRateFraction int16  `mp4:"5,size=16,const=0"`
}

type Emsg

type Emsg struct {
	FullBox               `mp4:"0,extend"`
	SchemeIdUri           string `mp4:"1,string"`
	Value                 string `mp4:"2,string"`
	Timescale             uint32 `mp4:"3,size=32"`
	PresentationTimeDelta uint32 `mp4:"4,size=32,ver=0"`
	PresentationTime      uint64 `mp4:"5,size=64,ver=1"`
	EventDuration         uint32 `mp4:"6,size=32"`
	Id                    uint32 `mp4:"7,size=32"`
	MessageData           []byte `mp4:"8,size=8,string"`
}

Emsg is ISOBMFF emsg box type

func (*Emsg) GetType

func (*Emsg) GetType() BoxType

GetType returns the BoxType

func (*Emsg) OnReadField added in v0.3.0

func (emsg *Emsg) OnReadField(name string, r bitio.ReadSeeker, leftBits uint64, ctx Context) (rbits uint64, override bool, err error)

func (*Emsg) OnWriteField added in v0.3.0

func (emsg *Emsg) OnWriteField(name string, w bitio.Writer, ctx Context) (wbits uint64, override bool, err error)

type Esds

type Esds struct {
	FullBox     `mp4:"0,extend"`
	Descriptors []Descriptor `mp4:"1,array"`
}

Esds is ES descripter box

func (*Esds) GetType

func (*Esds) GetType() BoxType

GetType returns the BoxType

type Fiel added in v0.9.0

type Fiel struct {
	Box
	FieldCount    uint8 `mp4:"0,size=8"`
	FieldOrdering uint8 `mp4:"1,size=8"`
}

func (Fiel) GetType added in v0.9.0

func (Fiel) GetType() BoxType

type FraProbeInfo deprecated

type FraProbeInfo = ProbeInfo

Deprecated: replace with ProbeInfo

func ProbeFra

func ProbeFra(r io.ReadSeeker) (*FraProbeInfo, error)

ProbeFra probes fragmented MP4 file Deprecated: replace with Probe

type Free

type Free FreeSpace

func (*Free) GetType

func (*Free) GetType() BoxType

type FreeSpace

type FreeSpace struct {
	Box
	Data []uint8 `mp4:"0,size=8"`
}

type Frma added in v0.4.0

type Frma struct {
	Box
	DataFormat [4]byte `mp4:"0,size=8,string"`
}

Frma is ISOBMFF frma box type

func (*Frma) GetType added in v0.4.0

func (*Frma) GetType() BoxType

GetType returns the BoxType

type Ftyp

type Ftyp struct {
	Box
	MajorBrand       [4]byte               `mp4:"0,size=8,string"`
	MinorVersion     uint32                `mp4:"1,size=32"`
	CompatibleBrands []CompatibleBrandElem `mp4:"2,size=32"` // reach to end of the box
}

Ftyp is ISOBMFF ftyp box type

func (*Ftyp) AddCompatibleBrand added in v0.6.0

func (ftyp *Ftyp) AddCompatibleBrand(cb [4]byte)

func (*Ftyp) GetType

func (*Ftyp) GetType() BoxType

GetType returns the BoxType

func (*Ftyp) HasCompatibleBrand added in v0.6.0

func (ftyp *Ftyp) HasCompatibleBrand(cb [4]byte) bool

func (*Ftyp) RemoveCompatibleBrand added in v0.6.0

func (ftyp *Ftyp) RemoveCompatibleBrand(cb [4]byte)

type FullBox

type FullBox struct {
	BaseCustomFieldObject
	Version uint8   `mp4:"0,size=8"`
	Flags   [3]byte `mp4:"1,size=8"`
}

FullBox is ISOBMFF FullBox

func (*FullBox) AddFlag

func (box *FullBox) AddFlag(flag uint32)

AddFlag adds the flag

func (*FullBox) CheckFlag

func (box *FullBox) CheckFlag(flag uint32) bool

CheckFlag checks the flag status

func (*FullBox) GetFlags

func (box *FullBox) GetFlags() uint32

GetFlags returns the flags

func (*FullBox) GetVersion

func (box *FullBox) GetVersion() uint8

GetVersion returns the box version

func (*FullBox) RemoveFlag

func (box *FullBox) RemoveFlag(flag uint32)

RemoveFlag removes the flag

func (*FullBox) SetFlags

func (box *FullBox) SetFlags(flags uint32)

SetFlags sets the flags

func (*FullBox) SetVersion

func (box *FullBox) SetVersion(version uint8)

SetVersion sets the box version

type HEVCNalu added in v0.9.0

type HEVCNalu struct {
	BaseCustomFieldObject
	Length  uint16 `mp4:"0,size=16"`
	NALUnit []byte `mp4:"1,size=8,len=dynamic"`
}

func (HEVCNalu) GetFieldLength added in v0.9.0

func (s HEVCNalu) GetFieldLength(name string, ctx Context) uint

type HEVCNaluArray added in v0.9.0

type HEVCNaluArray struct {
	BaseCustomFieldObject
	Completeness bool       `mp4:"0,size=1"`
	Reserved     bool       `mp4:"1,size=1"`
	NaluType     uint8      `mp4:"2,size=6"`
	NumNalus     uint16     `mp4:"3,size=16"`
	Nalus        []HEVCNalu `mp4:"4,len=dynamic"`
}

func (HEVCNaluArray) GetFieldLength added in v0.9.0

func (a HEVCNaluArray) GetFieldLength(name string, ctx Context) uint

type Hdlr

type Hdlr struct {
	FullBox `mp4:"0,extend"`
	// Predefined corresponds to component_type of QuickTime.
	// pre_defined of ISO-14496 has always zero,
	// however component_type has "mhlr" or "dhlr".
	PreDefined  uint32    `mp4:"1,size=32"`
	HandlerType [4]byte   `mp4:"2,size=8,string"`
	Reserved    [3]uint32 `mp4:"3,size=32,const=0"`
	Name        string    `mp4:"4,string"`
}

Hdlr is ISOBMFF hdlr box type

func (*Hdlr) GetType

func (*Hdlr) GetType() BoxType

GetType returns the BoxType

func (*Hdlr) OnReadField added in v0.6.0

func (hdlr *Hdlr) OnReadField(name string, r bitio.ReadSeeker, leftBits uint64, ctx Context) (rbits uint64, override bool, err error)

func (*Hdlr) OnReadName added in v0.6.0

func (hdlr *Hdlr) OnReadName(r bitio.ReadSeeker, leftBits uint64, ctx Context) (rbits uint64, override bool, err error)

type HvcC added in v0.9.0

type HvcC struct {
	Box
	ConfigurationVersion        uint8           `mp4:"0,size=8"`
	GeneralProfileSpace         uint8           `mp4:"1,size=2"`
	GeneralTierFlag             bool            `mp4:"2,size=1"`
	GeneralProfileIdc           uint8           `mp4:"3,size=5"`
	GeneralProfileCompatibility [32]bool        `mp4:"4,size=1"`
	GeneralConstraintIndicator  [6]uint8        `mp4:"5,size=8"`
	GeneralLevelIdc             uint8           `mp4:"6,size=8"`
	Reserved1                   uint8           `mp4:"7,size=4,const=15"`
	MinSpatialSegmentationIdc   uint16          `mp4:"8,size=12"`
	Reserved2                   uint8           `mp4:"9,size=6,const=63"`
	ParallelismType             uint8           `mp4:"10,size=2"`
	Reserved3                   uint8           `mp4:"11,size=6,const=63"`
	ChromaFormatIdc             uint8           `mp4:"12,size=2"`
	Reserved4                   uint8           `mp4:"13,size=5,const=31"`
	BitDepthLumaMinus8          uint8           `mp4:"14,size=3"`
	Reserved5                   uint8           `mp4:"15,size=5,const=31"`
	BitDepthChromaMinus8        uint8           `mp4:"16,size=3"`
	AvgFrameRate                uint16          `mp4:"17,size=16"`
	ConstantFrameRate           uint8           `mp4:"18,size=2"`
	NumTemporalLayers           uint8           `mp4:"19,size=2"`
	TemporalIdNested            uint8           `mp4:"20,size=2"`
	LengthSizeMinusOne          uint8           `mp4:"21,size=2"`
	NumOfNaluArrays             uint8           `mp4:"22,size=8"`
	NaluArrays                  []HEVCNaluArray `mp4:"23,len=dynamic"`
}

func (HvcC) GetFieldLength added in v0.9.0

func (hvcc HvcC) GetFieldLength(name string, ctx Context) uint

func (HvcC) GetType added in v0.9.0

func (HvcC) GetType() BoxType

type IAnyType

type IAnyType interface {
	IBox
	SetType(BoxType)
}

type IBox

type IBox interface {
	IImmutableBox

	// SetVersion sets the box version
	SetVersion(uint8)

	// SetFlags sets the flags
	SetFlags(uint32)

	// AddFlag adds the flag
	AddFlag(uint32)

	// RemoveFlag removes the flag
	RemoveFlag(uint32)
}

IBox is common interface of box

func UnmarshalAny

func UnmarshalAny(r io.ReadSeeker, boxType BoxType, payloadSize uint64, ctx Context) (box IBox, n uint64, err error)

type ICustomFieldObject

type ICustomFieldObject interface {
	// GetFieldSize returns size of dynamic field
	GetFieldSize(name string, ctx Context) uint

	// GetFieldLength returns length of dynamic field
	GetFieldLength(name string, ctx Context) uint

	// IsOptFieldEnabled check whether if the optional field is enabled
	IsOptFieldEnabled(name string, ctx Context) bool

	// StringifyField returns field value as string
	StringifyField(name string, indent string, depth int, ctx Context) (string, bool)

	IsPString(name string, bytes []byte, remainingSize uint64, ctx Context) bool

	BeforeUnmarshal(r io.ReadSeeker, size uint64, ctx Context) (n uint64, override bool, err error)

	OnReadField(name string, r bitio.ReadSeeker, leftBits uint64, ctx Context) (rbits uint64, override bool, err error)

	OnWriteField(name string, w bitio.Writer, ctx Context) (wbits uint64, override bool, err error)
}

type IImmutableBox

type IImmutableBox interface {
	ICustomFieldObject

	// GetVersion returns the box version
	GetVersion() uint8

	// GetFlags returns the flags
	GetFlags() uint32

	// CheckFlag checks the flag status
	CheckFlag(uint32) bool

	// GetType returns the BoxType
	GetType() BoxType
}

IImmutableBox is common interface of box

type Ilst added in v0.3.0

type Ilst struct {
	Box
}

func (*Ilst) GetType added in v0.3.0

func (*Ilst) GetType() BoxType

GetType returns the BoxType

type IlstMetaContainer added in v0.4.0

type IlstMetaContainer struct {
	AnyTypeBox
}

type Item added in v1.2.0

type Item struct {
	AnyTypeBox
	Version  uint8   `mp4:"0,size=8"`
	Flags    [3]byte `mp4:"1,size=8"`
	ItemName []byte  `mp4:"2,size=8,len=4"`
	Data     Data    `mp4:"3"`
}

Item is a numbered item under an item list atom https://developer.apple.com/documentation/quicktime-file-format/metadata_item_list_atom/item_list

func (*Item) StringifyField added in v1.2.0

func (i *Item) StringifyField(name string, indent string, depth int, ctx Context) (string, bool)

StringifyField returns field value as string

type Key added in v1.2.0

type Key struct {
	BaseCustomFieldObject
	KeySize      int32  `mp4:"0,size=32"`
	KeyNamespace []byte `mp4:"1,size=8,len=4"`
	KeyValue     []byte `mp4:"2,size=8,len=dynamic"`
}

Key is a key value field in the Keys BoxType https://developer.apple.com/documentation/quicktime-file-format/metadata_item_keys_atom/key_value_key_size-8

func (*Key) GetFieldLength added in v1.2.0

func (k *Key) GetFieldLength(name string, ctx Context) uint

GetFieldLength implements the ICustomFieldObject interface and returns the length of dynamic fields

func (*Key) StringifyField added in v1.2.0

func (k *Key) StringifyField(name string, indent string, depth int, ctx Context) (string, bool)

StringifyField returns field value as string

type Keys added in v1.2.0

type Keys struct {
	FullBox    `mp4:"0,extend"`
	EntryCount int32 `mp4:"1,size=32"`
	Entries    []Key `mp4:"2,len=dynamic"`
}

Keys is the Keys BoxType https://developer.apple.com/documentation/quicktime-file-format/metadata_item_keys_atom

func (*Keys) GetFieldLength added in v1.2.0

func (k *Keys) GetFieldLength(name string, ctx Context) uint

GetFieldLength implements the ICustomFieldObject interface and returns the length of dynamic fields

func (*Keys) GetType added in v1.2.0

func (*Keys) GetType() BoxType

GetType implements the IBox interface and returns the BoxType

type MP4AInfo added in v0.6.0

type MP4AInfo struct {
	OTI          uint8
	AudOTI       uint8
	ChannelCount uint16
}

type Mdat

type Mdat struct {
	Box
	Data []byte `mp4:"0,size=8"`
}

Mdat is ISOBMFF mdat box type

func (*Mdat) GetType

func (*Mdat) GetType() BoxType

GetType returns the BoxType

type Mdhd

type Mdhd struct {
	FullBox            `mp4:"0,extend"`
	CreationTimeV0     uint32 `mp4:"1,size=32,ver=0"`
	ModificationTimeV0 uint32 `mp4:"2,size=32,ver=0"`
	CreationTimeV1     uint64 `mp4:"3,size=64,ver=1"`
	ModificationTimeV1 uint64 `mp4:"4,size=64,ver=1"`
	Timescale          uint32 `mp4:"5,size=32"`
	DurationV0         uint32 `mp4:"6,size=32,ver=0"`
	DurationV1         uint64 `mp4:"7,size=64,ver=1"`
	//
	Pad        bool    `mp4:"8,size=1,hidden"`
	Language   [3]byte `mp4:"9,size=5,iso639-2"` // ISO-639-2/T language code
	PreDefined uint16  `mp4:"10,size=16"`
}

Mdhd is ISOBMFF mdhd box type

func (*Mdhd) GetCreationTime added in v0.8.0

func (mdhd *Mdhd) GetCreationTime() uint64

func (*Mdhd) GetDuration added in v0.8.0

func (mdhd *Mdhd) GetDuration() uint64

func (*Mdhd) GetModificationTime added in v0.8.0

func (mdhd *Mdhd) GetModificationTime() uint64

func (*Mdhd) GetType

func (*Mdhd) GetType() BoxType

GetType returns the BoxType

type Mdia

type Mdia struct {
	Box
}

Mdia is ISOBMFF mdia box type

func (*Mdia) GetType

func (*Mdia) GetType() BoxType

GetType returns the BoxType

type Mehd

type Mehd struct {
	FullBox            `mp4:"0,extend"`
	FragmentDurationV0 uint32 `mp4:"1,size=32,ver=0"`
	FragmentDurationV1 uint64 `mp4:"2,size=64,ver=1"`
}

Mehd is ISOBMFF mehd box type

func (*Mehd) GetFragmentDuration added in v0.8.0

func (mdhd *Mehd) GetFragmentDuration() uint64

func (*Mehd) GetType

func (*Mehd) GetType() BoxType

GetType returns the BoxType

type Meta

type Meta struct {
	FullBox `mp4:"0,extend"`
}

Meta is ISOBMFF meta box type

func (*Meta) BeforeUnmarshal

func (meta *Meta) BeforeUnmarshal(r io.ReadSeeker, size uint64, ctx Context) (n uint64, override bool, err error)

func (*Meta) GetType

func (*Meta) GetType() BoxType

GetType returns the BoxType

type Mfhd

type Mfhd struct {
	FullBox        `mp4:"0,extend"`
	SequenceNumber uint32 `mp4:"1,size=32"`
}

Mfhd is ISOBMFF mfhd box type

func (*Mfhd) GetType

func (*Mfhd) GetType() BoxType

GetType returns the BoxType

type Mfra

type Mfra struct {
	Box
}

Mfra is ISOBMFF mfra box type

func (*Mfra) GetType

func (*Mfra) GetType() BoxType

GetType returns the BoxType

type Mfro

type Mfro struct {
	FullBox `mp4:"0,extend"`
	Size    uint32 `mp4:"1,size=32"`
}

Mfro is ISOBMFF mfro box type

func (*Mfro) GetType

func (*Mfro) GetType() BoxType

GetType returns the BoxType

type Minf

type Minf struct {
	Box
}

Minf is ISOBMFF minf box type

func (*Minf) GetType

func (*Minf) GetType() BoxType

GetType returns the BoxType

type Moof

type Moof struct {
	Box
}

Moof is ISOBMFF moof box type

func (*Moof) GetType

func (*Moof) GetType() BoxType

GetType returns the BoxType

type Moov

type Moov struct {
	Box
}

Moov is ISOBMFF moov box type

func (*Moov) GetType

func (*Moov) GetType() BoxType

GetType returns the BoxType

type Mvex

type Mvex struct {
	Box
}

Mvex is ISOBMFF mvex box type

func (*Mvex) GetType

func (*Mvex) GetType() BoxType

GetType returns the BoxType

type Mvhd

type Mvhd struct {
	FullBox            `mp4:"0,extend"`
	CreationTimeV0     uint32    `mp4:"1,size=32,ver=0"`
	ModificationTimeV0 uint32    `mp4:"2,size=32,ver=0"`
	CreationTimeV1     uint64    `mp4:"3,size=64,ver=1"`
	ModificationTimeV1 uint64    `mp4:"4,size=64,ver=1"`
	Timescale          uint32    `mp4:"5,size=32"`
	DurationV0         uint32    `mp4:"6,size=32,ver=0"`
	DurationV1         uint64    `mp4:"7,size=64,ver=1"`
	Rate               int32     `mp4:"8,size=32"` // fixed-point 16.16 - template=0x00010000
	Volume             int16     `mp4:"9,size=16"` // template=0x0100
	Reserved           int16     `mp4:"10,size=16,const=0"`
	Reserved2          [2]uint32 `mp4:"11,size=32,const=0"`
	Matrix             [9]int32  `mp4:"12,size=32,hex"` // template={ 0x00010000,0,0,0,0x00010000,0,0,0,0x40000000 }
	PreDefined         [6]int32  `mp4:"13,size=32"`
	NextTrackID        uint32    `mp4:"14,size=32"`
}

Mvhd is ISOBMFF mvhd box type

func (*Mvhd) GetCreationTime added in v0.8.0

func (mvhd *Mvhd) GetCreationTime() uint64

func (*Mvhd) GetDuration added in v0.8.0

func (mvhd *Mvhd) GetDuration() uint64

func (*Mvhd) GetModificationTime added in v0.8.0

func (mvhd *Mvhd) GetModificationTime() uint64

func (*Mvhd) GetRate added in v0.3.0

func (mvhd *Mvhd) GetRate() float64

GetRate returns value of rate as float64

func (*Mvhd) GetRateInt added in v0.3.0

func (mvhd *Mvhd) GetRateInt() int16

GetRateInt returns value of rate as int16

func (*Mvhd) GetType

func (*Mvhd) GetType() BoxType

GetType returns the BoxType

func (*Mvhd) StringifyField added in v0.3.0

func (mvhd *Mvhd) StringifyField(name string, indent string, depth int, ctx Context) (string, bool)

StringifyField returns field value as string

type PcmC added in v1.2.0

type PcmC struct {
	FullBox       `mp4:"0,extend"`
	FormatFlags   uint8 `mp4:"1,size=8"`
	PCMSampleSize uint8 `mp4:"1,size=8"`
}

func (PcmC) GetType added in v1.2.0

func (PcmC) GetType() BoxType

type PixelAspectRatioBox

type PixelAspectRatioBox struct {
	AnyTypeBox
	HSpacing uint32 `mp4:"0,size=32"`
	VSpacing uint32 `mp4:"1,size=32"`
}

type ProbeInfo added in v0.6.0

type ProbeInfo struct {
	MajorBrand       [4]byte
	MinorVersion     uint32
	CompatibleBrands [][4]byte
	FastStart        bool
	Timescale        uint32
	Duration         uint64
	Tracks           Tracks
	Segments         Segments
}

func Probe added in v0.6.0

func Probe(r io.ReadSeeker) (*ProbeInfo, error)

Probe probes MP4 file

type Pssh

type Pssh struct {
	FullBox  `mp4:"0,extend"`
	SystemID [16]byte  `mp4:"1,size=8,uuid"`
	KIDCount uint32    `mp4:"2,size=32,nver=0"`
	KIDs     []PsshKID `mp4:"3,nver=0,len=dynamic,size=128"`
	DataSize int32     `mp4:"4,size=32"`
	Data     []byte    `mp4:"5,size=8,len=dynamic"`
}

Pssh is ISOBMFF pssh box type

func (*Pssh) GetFieldLength

func (pssh *Pssh) GetFieldLength(name string, ctx Context) uint

GetFieldLength returns length of dynamic field

func (*Pssh) GetType

func (*Pssh) GetType() BoxType

GetType returns the BoxType

func (*Pssh) StringifyField

func (pssh *Pssh) StringifyField(name string, indent string, depth int, ctx Context) (string, bool)

StringifyField returns field value as string

type PsshKID

type PsshKID struct {
	KID [16]byte `mp4:"0,size=8,uuid"`
}

type ReadHandle

type ReadHandle struct {
	Params      []interface{}
	BoxInfo     BoxInfo
	Path        BoxPath
	ReadPayload func() (box IBox, n uint64, err error)
	ReadData    func(io.Writer) (n uint64, err error)
	Expand      func(params ...interface{}) (vals []interface{}, err error)
}

type ReadHandler

type ReadHandler func(handle *ReadHandle) (val interface{}, err error)

type RollDistanceWithLength added in v0.3.0

type RollDistanceWithLength struct {
	DescriptionLength uint32 `mp4:"0,size=32"`
	RollDistance      int16  `mp4:"1,size=16"`
}

type Saio added in v0.4.0

type Saio struct {
	FullBox              `mp4:"0,extend"`
	AuxInfoType          [4]byte  `mp4:"1,size=8,opt=0x000001,string"`
	AuxInfoTypeParameter uint32   `mp4:"2,size=32,opt=0x000001,hex"`
	EntryCount           uint32   `mp4:"3,size=32"`
	OffsetV0             []uint32 `mp4:"4,size=32,ver=0,len=dynamic"`
	OffsetV1             []uint64 `mp4:"5,size=64,nver=0,len=dynamic"`
}

func (*Saio) GetFieldLength added in v0.4.0

func (saio *Saio) GetFieldLength(name string, ctx Context) uint

func (*Saio) GetOffset added in v0.8.0

func (saio *Saio) GetOffset(index int) uint64

func (*Saio) GetType added in v0.4.0

func (*Saio) GetType() BoxType

type Saiz added in v0.4.0

type Saiz struct {
	FullBox               `mp4:"0,extend"`
	AuxInfoType           [4]byte `mp4:"1,size=8,opt=0x000001,string"`
	AuxInfoTypeParameter  uint32  `mp4:"2,size=32,opt=0x000001,hex"`
	DefaultSampleInfoSize uint8   `mp4:"3,size=8,dec"`
	SampleCount           uint32  `mp4:"4,size=32"`
	SampleInfoSize        []uint8 `mp4:"5,size=8,opt=dynamic,len=dynamic,dec"`
}

func (*Saiz) GetFieldLength added in v0.4.0

func (saiz *Saiz) GetFieldLength(name string, ctx Context) uint

func (*Saiz) GetType added in v0.4.0

func (*Saiz) GetType() BoxType

func (*Saiz) IsOptFieldEnabled added in v0.4.0

func (saiz *Saiz) IsOptFieldEnabled(name string, ctx Context) bool

type Sample added in v0.6.0

type Sample struct {
	Size                  uint32
	TimeDelta             uint32
	CompositionTimeOffset int64
}

type SampleEntry

type SampleEntry struct {
	AnyTypeBox
	Reserved           [6]uint8 `mp4:"0,size=8,const=0"`
	DataReferenceIndex uint16   `mp4:"1,size=16"`
}

type Samples added in v0.6.0

type Samples []*Sample

func (Samples) GetBitrate added in v0.6.0

func (samples Samples) GetBitrate(timescale uint32) uint64

func (Samples) GetMaxBitrate added in v0.6.0

func (samples Samples) GetMaxBitrate(timescale uint32, timeDelta uint64) uint64

type Sbgp

type Sbgp struct {
	FullBox               `mp4:"0,extend"`
	GroupingType          uint32      `mp4:"1,size=32"`
	GroupingTypeParameter uint32      `mp4:"2,size=32,ver=1"`
	EntryCount            uint32      `mp4:"3,size=32"`
	Entries               []SbgpEntry `mp4:"4,len=dynamic,size=64"`
}

func (*Sbgp) GetFieldLength

func (sbgp *Sbgp) GetFieldLength(name string, ctx Context) uint

func (*Sbgp) GetType

func (*Sbgp) GetType() BoxType

type SbgpEntry

type SbgpEntry struct {
	SampleCount           uint32 `mp4:"0,size=32"`
	GroupDescriptionIndex uint32 `mp4:"1,size=32"`
}

type Schi added in v0.3.0

type Schi struct {
	Box
}

func (*Schi) GetType added in v0.3.0

func (*Schi) GetType() BoxType

type Schm added in v0.4.0

type Schm struct {
	FullBox       `mp4:"0,extend"`
	SchemeType    [4]byte `mp4:"1,size=8,string"`
	SchemeVersion uint32  `mp4:"2,size=32,hex"`
	SchemeUri     []byte  `mp4:"3,size=8,opt=0x000001,string"`
}

func (*Schm) GetType added in v0.4.0

func (*Schm) GetType() BoxType

type Sdtp added in v0.4.0

type Sdtp struct {
	FullBox `mp4:"0,extend"`
	Samples []SdtpSampleElem `mp4:"1,size=8"`
}

func (*Sdtp) GetType added in v0.4.0

func (*Sdtp) GetType() BoxType

type SdtpSampleElem added in v0.4.0

type SdtpSampleElem struct {
	IsLeading           uint8 `mp4:"0,size=2"`
	SampleDependsOn     uint8 `mp4:"1,size=2"`
	SampleIsDependedOn  uint8 `mp4:"2,size=2"`
	SampleHasRedundancy uint8 `mp4:"3,size=2"`
}

type Segment added in v0.6.0

type Segment struct {
	TrackID               uint32
	MoofOffset            uint64
	BaseMediaDecodeTime   uint64
	DefaultSampleDuration uint32
	SampleCount           uint32
	Duration              uint32
	CompositionTimeOffset int32
	Size                  uint32
}

type SegmentInfo deprecated

type SegmentInfo = Segment

Deprecated: replace with Segment

type Segments added in v0.6.0

type Segments []*Segment

func (Segments) GetBitrate added in v0.6.0

func (segments Segments) GetBitrate(trackID uint32, timescale uint32) uint64

func (Segments) GetMaxBitrate added in v0.6.0

func (segments Segments) GetMaxBitrate(trackID uint32, timescale uint32) uint64

type Sgpd

type Sgpd struct {
	FullBox                       `mp4:"0,extend"`
	GroupingType                  [4]byte                    `mp4:"1,size=8,string"`
	DefaultLength                 uint32                     `mp4:"2,size=32,ver=1"`
	DefaultSampleDescriptionIndex uint32                     `mp4:"3,size=32,ver=2"`
	EntryCount                    uint32                     `mp4:"4,size=32"`
	RollDistances                 []int16                    `mp4:"5,size=16,opt=dynamic"`
	RollDistancesL                []RollDistanceWithLength   `mp4:"6,size=16,opt=dynamic"`
	AlternativeStartupEntries     []AlternativeStartupEntry  `mp4:"7,size=dynamic,len=dynamic,opt=dynamic"`
	AlternativeStartupEntriesL    []AlternativeStartupEntryL `mp4:"8,len=dynamic,opt=dynamic"`
	VisualRandomAccessEntries     []VisualRandomAccessEntry  `mp4:"9,len=dynamic,opt=dynamic"`
	VisualRandomAccessEntriesL    []VisualRandomAccessEntryL `mp4:"10,len=dynamic,opt=dynamic"`
	TemporalLevelEntries          []TemporalLevelEntry       `mp4:"11,len=dynamic,opt=dynamic"`
	TemporalLevelEntriesL         []TemporalLevelEntryL      `mp4:"12,len=dynamic,opt=dynamic"`
	Unsupported                   []byte                     `mp4:"13,size=8,opt=dynamic"`
}

func (*Sgpd) GetFieldLength added in v0.3.0

func (sgpd *Sgpd) GetFieldLength(name string, ctx Context) uint

func (*Sgpd) GetFieldSize

func (sgpd *Sgpd) GetFieldSize(name string, ctx Context) uint

func (*Sgpd) GetType

func (*Sgpd) GetType() BoxType

func (*Sgpd) IsOptFieldEnabled

func (sgpd *Sgpd) IsOptFieldEnabled(name string, ctx Context) bool

type Sidx added in v0.2.0

type Sidx struct {
	FullBox                    `mp4:"0,extend"`
	ReferenceID                uint32          `mp4:"1,size=32"`
	Timescale                  uint32          `mp4:"2,size=32"`
	EarliestPresentationTimeV0 uint32          `mp4:"3,size=32,ver=0"`
	FirstOffsetV0              uint32          `mp4:"4,size=32,ver=0"`
	EarliestPresentationTimeV1 uint64          `mp4:"5,size=64,nver=0"`
	FirstOffsetV1              uint64          `mp4:"6,size=64,nver=0"`
	Reserved                   uint16          `mp4:"7,size=16,const=0"`
	ReferenceCount             uint16          `mp4:"8,size=16"`
	References                 []SidxReference `mp4:"9,size=96,len=dynamic"`
}

func (*Sidx) GetEarliestPresentationTime added in v0.8.0

func (sidx *Sidx) GetEarliestPresentationTime() uint64

func (*Sidx) GetFieldLength added in v0.2.0

func (sidx *Sidx) GetFieldLength(name string, ctx Context) uint

func (*Sidx) GetFirstOffset added in v0.8.0

func (sidx *Sidx) GetFirstOffset() uint64

func (*Sidx) GetType added in v0.2.0

func (*Sidx) GetType() BoxType

type SidxReference added in v0.2.0

type SidxReference struct {
	ReferenceType      bool   `mp4:"0,size=1"`
	ReferencedSize     uint32 `mp4:"1,size=31"`
	SubsegmentDuration uint32 `mp4:"2,size=32"`
	StartsWithSAP      bool   `mp4:"3,size=1"`
	SAPType            uint32 `mp4:"4,size=3"`
	SAPDeltaTime       uint32 `mp4:"5,size=28"`
}

type Sinf added in v0.3.0

type Sinf struct {
	Box
}

func (*Sinf) GetType added in v0.3.0

func (*Sinf) GetType() BoxType

type Skip

type Skip FreeSpace

func (*Skip) GetType

func (*Skip) GetType() BoxType

type Smhd

type Smhd struct {
	FullBox  `mp4:"0,extend"`
	Balance  int16  `mp4:"1,size=16"` // fixed-point 8.8 template=0
	Reserved uint16 `mp4:"2,size=16,const=0"`
}

func (*Smhd) GetBalance added in v0.3.0

func (smhd *Smhd) GetBalance() float32

GetBalance returns value of width as float32

func (*Smhd) GetBalanceInt added in v0.3.0

func (smhd *Smhd) GetBalanceInt() int8

GetBalanceInt returns value of width as int8

func (*Smhd) GetType

func (*Smhd) GetType() BoxType

func (*Smhd) StringifyField added in v0.3.0

func (smhd *Smhd) StringifyField(name string, indent string, depth int, ctx Context) (string, bool)

StringifyField returns field value as string

type Stbl

type Stbl struct {
	Box
}

Stbl is ISOBMFF stbl box type

func (*Stbl) GetType

func (*Stbl) GetType() BoxType

GetType returns the BoxType

type Stco

type Stco struct {
	FullBox     `mp4:"0,extend"`
	EntryCount  uint32   `mp4:"1,size=32"`
	ChunkOffset []uint32 `mp4:"2,size=32,len=dynamic"`
}

Stco is ISOBMFF stco box type

func (*Stco) GetFieldLength

func (stco *Stco) GetFieldLength(name string, ctx Context) uint

GetFieldLength returns length of dynamic field

func (*Stco) GetType

func (*Stco) GetType() BoxType

GetType returns the BoxType

type StringData added in v0.4.0

type StringData struct {
	AnyTypeBox
	Data []byte `mp4:"0,size=8"`
}

func (*StringData) StringifyField added in v0.4.0

func (sd *StringData) StringifyField(name string, indent string, depth int, ctx Context) (string, bool)

StringifyField returns field value as string

type Stsc

type Stsc struct {
	FullBox    `mp4:"0,extend"`
	EntryCount uint32      `mp4:"1,size=32"`
	Entries    []StscEntry `mp4:"2,len=dynamic,size=96"`
}

Stsc is ISOBMFF stsc box type

func (*Stsc) GetFieldLength

func (stsc *Stsc) GetFieldLength(name string, ctx Context) uint

GetFieldLength returns length of dynamic field

func (*Stsc) GetType

func (*Stsc) GetType() BoxType

GetType returns the BoxType

type StscEntry

type StscEntry struct {
	FirstChunk             uint32 `mp4:"0,size=32"`
	SamplesPerChunk        uint32 `mp4:"1,size=32"`
	SampleDescriptionIndex uint32 `mp4:"2,size=32"`
}

type Stsd

type Stsd struct {
	FullBox    `mp4:"0,extend"`
	EntryCount uint32 `mp4:"1,size=32"`
}

Stsd is ISOBMFF stsd box type

func (*Stsd) GetType

func (*Stsd) GetType() BoxType

GetType returns the BoxType

type Stss

type Stss struct {
	FullBox      `mp4:"0,extend"`
	EntryCount   uint32   `mp4:"1,size=32"`
	SampleNumber []uint32 `mp4:"2,len=dynamic,size=32"`
}

func (*Stss) GetFieldLength

func (stss *Stss) GetFieldLength(name string, ctx Context) uint

GetFieldLength returns length of dynamic field

func (*Stss) GetType

func (*Stss) GetType() BoxType

GetType returns the BoxType

type Stsz

type Stsz struct {
	FullBox     `mp4:"0,extend"`
	SampleSize  uint32   `mp4:"1,size=32"`
	SampleCount uint32   `mp4:"2,size=32"`
	EntrySize   []uint32 `mp4:"3,size=32,len=dynamic"`
}

Stsz is ISOBMFF stsz box type

func (*Stsz) GetFieldLength

func (stsz *Stsz) GetFieldLength(name string, ctx Context) uint

GetFieldLength returns length of dynamic field

func (*Stsz) GetType

func (*Stsz) GetType() BoxType

GetType returns the BoxType

type Stts

type Stts struct {
	FullBox    `mp4:"0,extend"`
	EntryCount uint32      `mp4:"1,size=32"`
	Entries    []SttsEntry `mp4:"2,len=dynamic,size=64"`
}

Stts is ISOBMFF stts box type

func (*Stts) GetFieldLength

func (stts *Stts) GetFieldLength(name string, ctx Context) uint

GetFieldLength returns length of dynamic field

func (*Stts) GetType

func (*Stts) GetType() BoxType

GetType returns the BoxType

type SttsEntry

type SttsEntry struct {
	SampleCount uint32 `mp4:"0,size=32"`
	SampleDelta uint32 `mp4:"1,size=32"`
}

type Styp added in v0.2.0

type Styp struct {
	Box
	MajorBrand       [4]byte               `mp4:"0,size=8,string"`
	MinorVersion     uint32                `mp4:"1,size=32"`
	CompatibleBrands []CompatibleBrandElem `mp4:"2,size=32"` // reach to end of the box
}

func (*Styp) GetType added in v0.2.0

func (*Styp) GetType() BoxType

type TemporalLevelEntry

type TemporalLevelEntry struct {
	LevelIndependentlyDecodable bool  `mp4:"0,size=1"`
	Reserved                    uint8 `mp4:"1,size=7,const=0"`
}

type TemporalLevelEntryL added in v0.3.0

type TemporalLevelEntryL struct {
	DescriptionLength  uint32 `mp4:"0,size=32"`
	TemporalLevelEntry `mp4:"1,extend"`
}

type Tenc added in v0.4.0

type Tenc struct {
	FullBox                `mp4:"0,extend"`
	Reserved               uint8    `mp4:"1,size=8,dec"`
	DefaultCryptByteBlock  uint8    `mp4:"2,size=4,dec"` // always 0 on version 0
	DefaultSkipByteBlock   uint8    `mp4:"3,size=4,dec"` // always 0 on version 0
	DefaultIsProtected     uint8    `mp4:"4,size=8,dec"`
	DefaultPerSampleIVSize uint8    `mp4:"5,size=8,dec"`
	DefaultKID             [16]byte `mp4:"6,size=8,uuid"`
	DefaultConstantIVSize  uint8    `mp4:"7,size=8,opt=dynamic,dec"`
	DefaultConstantIV      []byte   `mp4:"8,size=8,opt=dynamic,len=dynamic"`
}

Tenc is ISOBMFF tenc box type

func (*Tenc) GetFieldLength added in v0.4.0

func (tenc *Tenc) GetFieldLength(name string, ctx Context) uint

func (*Tenc) GetType added in v0.4.0

func (*Tenc) GetType() BoxType

GetType returns the BoxType

func (*Tenc) IsOptFieldEnabled added in v0.4.0

func (tenc *Tenc) IsOptFieldEnabled(name string, ctx Context) bool

type Tfdt

type Tfdt struct {
	FullBox               `mp4:"0,extend"`
	BaseMediaDecodeTimeV0 uint32 `mp4:"1,size=32,ver=0"`
	BaseMediaDecodeTimeV1 uint64 `mp4:"2,size=64,ver=1"`
}

Tfdt is ISOBMFF tfdt box type

func (*Tfdt) GetBaseMediaDecodeTime added in v0.8.0

func (tfdt *Tfdt) GetBaseMediaDecodeTime() uint64

func (*Tfdt) GetType

func (*Tfdt) GetType() BoxType

GetType returns the BoxType

type Tfhd

type Tfhd struct {
	FullBox `mp4:"0,extend"`
	TrackID uint32 `mp4:"1,size=32"`

	// optional
	BaseDataOffset         uint64 `mp4:"2,size=64,opt=0x000001"`
	SampleDescriptionIndex uint32 `mp4:"3,size=32,opt=0x000002"`
	DefaultSampleDuration  uint32 `mp4:"4,size=32,opt=0x000008"`
	DefaultSampleSize      uint32 `mp4:"5,size=32,opt=0x000010"`
	DefaultSampleFlags     uint32 `mp4:"6,size=32,opt=0x000020,hex"`
}

Tfhd is ISOBMFF tfhd box type

func (*Tfhd) GetType

func (*Tfhd) GetType() BoxType

GetType returns the BoxType

type Tfra

type Tfra struct {
	FullBox               `mp4:"0,extend"`
	TrackID               uint32      `mp4:"1,size=32"`
	Reserved              uint32      `mp4:"2,size=26,const=0"`
	LengthSizeOfTrafNum   byte        `mp4:"3,size=2"`
	LengthSizeOfTrunNum   byte        `mp4:"4,size=2"`
	LengthSizeOfSampleNum byte        `mp4:"5,size=2"`
	NumberOfEntry         uint32      `mp4:"6,size=32"`
	Entries               []TfraEntry `mp4:"7,len=dynamic,size=dynamic"`
}

Tfra is ISOBMFF tfra box type

func (*Tfra) GetFieldLength

func (tfra *Tfra) GetFieldLength(name string, ctx Context) uint

GetFieldLength returns length of dynamic field

func (*Tfra) GetFieldSize

func (tfra *Tfra) GetFieldSize(name string, ctx Context) uint

GetFieldSize returns size of dynamic field

func (*Tfra) GetMoofOffset added in v0.8.0

func (tfra *Tfra) GetMoofOffset(index int) uint64

func (*Tfra) GetTime added in v0.8.0

func (tfra *Tfra) GetTime(index int) uint64

func (*Tfra) GetType

func (*Tfra) GetType() BoxType

GetType returns the BoxType

type TfraEntry

type TfraEntry struct {
	TimeV0       uint32 `mp4:"0,size=32,ver=0"`
	MoofOffsetV0 uint32 `mp4:"1,size=32,ver=0"`
	TimeV1       uint64 `mp4:"2,size=64,ver=1"`
	MoofOffsetV1 uint64 `mp4:"3,size=64,ver=1"`
	TrafNumber   uint32 `mp4:"4,size=dynamic"`
	TrunNumber   uint32 `mp4:"5,size=dynamic"`
	SampleNumber uint32 `mp4:"6,size=dynamic"`
}

type Tkhd

type Tkhd struct {
	FullBox            `mp4:"0,extend"`
	CreationTimeV0     uint32 `mp4:"1,size=32,ver=0"`
	ModificationTimeV0 uint32 `mp4:"2,size=32,ver=0"`
	CreationTimeV1     uint64 `mp4:"3,size=64,ver=1"`
	ModificationTimeV1 uint64 `mp4:"4,size=64,ver=1"`
	TrackID            uint32 `mp4:"5,size=32"`
	Reserved0          uint32 `mp4:"6,size=32,const=0"`
	DurationV0         uint32 `mp4:"7,size=32,ver=0"`
	DurationV1         uint64 `mp4:"8,size=64,ver=1"`
	//
	Reserved1      [2]uint32 `mp4:"9,size=32,const=0"`
	Layer          int16     `mp4:"10,size=16"` // template=0
	AlternateGroup int16     `mp4:"11,size=16"` // template=0
	Volume         int16     `mp4:"12,size=16"` // template={if track_is_audio 0x0100 else 0}
	Reserved2      uint16    `mp4:"13,size=16,const=0"`
	Matrix         [9]int32  `mp4:"14,size=32,hex"` // template={ 0x00010000,0,0,0,0x00010000,0,0,0,0x40000000 };
	Width          uint32    `mp4:"15,size=32"`     // fixed-point 16.16
	Height         uint32    `mp4:"16,size=32"`     // fixed-point 16.16
}

Tkhd is ISOBMFF tkhd box type

func (*Tkhd) GetCreationTime added in v0.8.0

func (tkhd *Tkhd) GetCreationTime() uint64

func (*Tkhd) GetDuration added in v0.8.0

func (tkhd *Tkhd) GetDuration() uint64

func (*Tkhd) GetHeight added in v0.3.0

func (tkhd *Tkhd) GetHeight() float64

GetHeight returns value of height as float64

func (*Tkhd) GetHeightInt added in v0.3.0

func (tkhd *Tkhd) GetHeightInt() uint16

GetHeightInt returns value of height as uint16

func (*Tkhd) GetModificationTime added in v0.8.0

func (tkhd *Tkhd) GetModificationTime() uint64

func (*Tkhd) GetType

func (*Tkhd) GetType() BoxType

GetType returns the BoxType

func (*Tkhd) GetWidth added in v0.3.0

func (tkhd *Tkhd) GetWidth() float64

GetWidth returns value of width as float64

func (*Tkhd) GetWidthInt added in v0.3.0

func (tkhd *Tkhd) GetWidthInt() uint16

GetWidthInt returns value of width as uint16

func (*Tkhd) StringifyField added in v0.3.0

func (tkhd *Tkhd) StringifyField(name string, indent string, depth int, ctx Context) (string, bool)

StringifyField returns field value as string

type Track added in v0.6.0

type Track struct {
	TrackID   uint32
	Timescale uint32
	Duration  uint64
	Codec     Codec
	Encrypted bool
	EditList  EditList
	Samples   Samples
	Chunks    Chunks
	AVC       *AVCDecConfigInfo
	MP4A      *MP4AInfo
}

type TrackInfo deprecated

type TrackInfo = Track

Deprecated: replace with Track

type Tracks added in v0.6.0

type Tracks []*Track

type Traf

type Traf struct {
	Box
}

Traf is ISOBMFF traf box type

func (*Traf) GetType

func (*Traf) GetType() BoxType

GetType returns the BoxType

type Trak

type Trak struct {
	Box
}

Trak is ISOBMFF trak box type

func (*Trak) GetType

func (*Trak) GetType() BoxType

GetType returns the BoxType

type Trep added in v0.4.0

type Trep struct {
	FullBox `mp4:"0,extend"`
	TrackID uint32 `mp4:"1,size=32"`
}

Trep is ISOBMFF trep box type

func (*Trep) GetType added in v0.4.0

func (*Trep) GetType() BoxType

GetType returns the BoxType

type Trex

type Trex struct {
	FullBox                       `mp4:"0,extend"`
	TrackID                       uint32 `mp4:"1,size=32"`
	DefaultSampleDescriptionIndex uint32 `mp4:"2,size=32"`
	DefaultSampleDuration         uint32 `mp4:"3,size=32"`
	DefaultSampleSize             uint32 `mp4:"4,size=32"`
	DefaultSampleFlags            uint32 `mp4:"5,size=32,hex"`
}

Trex is ISOBMFF trex box type

func (*Trex) GetType

func (*Trex) GetType() BoxType

GetType returns the BoxType

type Trun

type Trun struct {
	FullBox     `mp4:"0,extend"`
	SampleCount uint32 `mp4:"1,size=32"`

	// optional fields
	DataOffset       int32       `mp4:"2,size=32,opt=0x000001"`
	FirstSampleFlags uint32      `mp4:"3,size=32,opt=0x000004,hex"`
	Entries          []TrunEntry `mp4:"4,len=dynamic,size=dynamic"`
}

Trun is ISOBMFF trun box type

func (*Trun) GetFieldLength

func (trun *Trun) GetFieldLength(name string, ctx Context) uint

GetFieldLength returns length of dynamic field

func (*Trun) GetFieldSize

func (trun *Trun) GetFieldSize(name string, ctx Context) uint

GetFieldSize returns size of dynamic field

func (*Trun) GetSampleCompositionTimeOffset added in v0.8.0

func (trun *Trun) GetSampleCompositionTimeOffset(index int) int64

func (*Trun) GetType

func (*Trun) GetType() BoxType

GetType returns the BoxType

type TrunEntry

type TrunEntry struct {
	SampleDuration                uint32 `mp4:"0,size=32,opt=0x000100"`
	SampleSize                    uint32 `mp4:"1,size=32,opt=0x000200"`
	SampleFlags                   uint32 `mp4:"2,size=32,opt=0x000400,hex"`
	SampleCompositionTimeOffsetV0 uint32 `mp4:"3,size=32,opt=0x000800,ver=0"`
	SampleCompositionTimeOffsetV1 int32  `mp4:"4,size=32,opt=0x000800,nver=0"`
}

type Udta

type Udta struct {
	Box
}

Udta is ISOBMFF udta box type

func (*Udta) GetType

func (*Udta) GetType() BoxType

GetType returns the BoxType

type Udta3GppString added in v0.4.0

type Udta3GppString struct {
	AnyTypeBox
	FullBox  `mp4:"0,extend"`
	Pad      bool    `mp4:"1,size=1,hidden"`
	Language [3]byte `mp4:"2,size=5,iso639-2"` // ISO-639-2/T language code
	Data     []byte  `mp4:"3,size=8,string"`
}

type Url

type Url struct {
	FullBox  `mp4:"0,extend"`
	Location string `mp4:"1,string,nopt=0x000001"`
}

func (*Url) GetType

func (*Url) GetType() BoxType

type Urn

type Urn struct {
	FullBox  `mp4:"0,extend"`
	Name     string `mp4:"1,string,nopt=0x000001"`
	Location string `mp4:"2,string,nopt=0x000001"`
}

func (*Urn) GetType

func (*Urn) GetType() BoxType

type VisualRandomAccessEntry

type VisualRandomAccessEntry struct {
	NumLeadingSamplesKnown bool  `mp4:"0,size=1"`
	NumLeadingSamples      uint8 `mp4:"1,size=7"`
}

type VisualRandomAccessEntryL added in v0.3.0

type VisualRandomAccessEntryL struct {
	DescriptionLength       uint32 `mp4:"0,size=32"`
	VisualRandomAccessEntry `mp4:"1,extend"`
}

type VisualSampleEntry

type VisualSampleEntry struct {
	SampleEntry     `mp4:"0,extend"`
	PreDefined      uint16    `mp4:"1,size=16"`
	Reserved        uint16    `mp4:"2,size=16,const=0"`
	PreDefined2     [3]uint32 `mp4:"3,size=32"`
	Width           uint16    `mp4:"4,size=16"`
	Height          uint16    `mp4:"5,size=16"`
	Horizresolution uint32    `mp4:"6,size=32"`
	Vertresolution  uint32    `mp4:"7,size=32"`
	Reserved2       uint32    `mp4:"8,size=32,const=0"`
	FrameCount      uint16    `mp4:"9,size=16"`
	Compressorname  [32]byte  `mp4:"10,size=8"`
	Depth           uint16    `mp4:"11,size=16"`
	PreDefined3     int16     `mp4:"12,size=16"`
}

func (*VisualSampleEntry) StringifyField

func (vse *VisualSampleEntry) StringifyField(name string, indent string, depth int, ctx Context) (string, bool)

StringifyField returns field value as string

type Vmhd

type Vmhd struct {
	FullBox      `mp4:"0,extend"`
	Graphicsmode uint16    `mp4:"1,size=16"` // template=0
	Opcolor      [3]uint16 `mp4:"2,size=16"` // template={0, 0, 0}
}

Vmhd is ISOBMFF vmhd box type

func (*Vmhd) GetType

func (*Vmhd) GetType() BoxType

GetType returns the BoxType

type VpcC added in v0.13.0

type VpcC struct {
	FullBox                     `mp4:"0,extend"`
	Profile                     uint8   `mp4:"1,size=8"`
	Level                       uint8   `mp4:"2,size=8"`
	BitDepth                    uint8   `mp4:"3,size=4"`
	ChromaSubsampling           uint8   `mp4:"4,size=3"`
	VideoFullRangeFlag          uint8   `mp4:"5,size=1"`
	ColourPrimaries             uint8   `mp4:"6,size=8"`
	TransferCharacteristics     uint8   `mp4:"7,size=8"`
	MatrixCoefficients          uint8   `mp4:"8,size=8"`
	CodecInitializationDataSize uint16  `mp4:"9,size=16"`
	CodecInitializationData     []uint8 `mp4:"10,size=8,len=dynamic"`
}

func (VpcC) GetFieldLength added in v0.13.0

func (vpcc VpcC) GetFieldLength(name string, ctx Context) uint

func (VpcC) GetType added in v0.13.0

func (VpcC) GetType() BoxType

type Wave added in v0.4.0

type Wave struct {
	Box
}

Wave is QuickTime wave box

func (*Wave) GetType added in v0.4.0

func (*Wave) GetType() BoxType

GetType returns the BoxType

type Writer added in v0.6.0

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

func NewWriter added in v0.6.0

func NewWriter(w io.WriteSeeker) *Writer

func (*Writer) CopyBox added in v0.6.0

func (w *Writer) CopyBox(r io.ReadSeeker, bi *BoxInfo) error

func (*Writer) EndBox added in v0.6.0

func (w *Writer) EndBox() (*BoxInfo, error)

func (*Writer) Seek added in v0.6.0

func (w *Writer) Seek(offset int64, whence int) (int64, error)

func (*Writer) StartBox added in v0.6.0

func (w *Writer) StartBox(bi *BoxInfo) (*BoxInfo, error)

func (*Writer) Write added in v0.6.0

func (w *Writer) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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