Documentation
¶
Overview ¶
Package mp4 - library for parsing and writing MP4/ISOBMFF files with a focus on fragmented files.
Most boxes have their own file named after the box four-letter name in the ISO/IEC 14996-12 standard, but in some cases, there may be multiple boxes that have the same content, and the code is then having a generic name like visualsampleentry.go.
The Box interface is specified in box.go. It decodes box size and type in the box header and dispatched decode for each individual box depending on its type.
Implement a new box ¶
To implement a new box "fooo", the following is needed:
Create a file fooo.go and with struct type FoooBox.
FoooBox should then implement the Box{} interface methods:
Type() Size() Encode()
but also its own decode method `DecodeFooo`, and register that method in the `decoders` map in `box.go`. For a simple example, look at the `prft` box in `prft.go`.
Container Boxes ¶
Container boxes like moof, have a list of all their children called "boxes", but also direct pointers to the children with appropriate names, like `Mfhd` and `Traf`. This makes it easy to chain box paths to reach an element like a TfhdBox via its parent MoofBox moof as
moof.Traf.Tfhd
Media Sample Data Structures ¶
To handle media sample data there are two structures:
1. `Sample` stores the sample information used in trun
2. `FullSample` also carries a slice with the samples binary data as well as decode time
Fragmenting segments ¶
A MediaSegment can be fragmented into multiple fragments by the method
func (s *MediaSegment) Fragmentify(timescale uint64, trex *TrexBox, duration uint32) ([]*Fragment, error)
Index ¶
- Constants
- func DumpContainer(c ContainerBox, w io.Writer, indent, indentStep string) error
- func EncodeContainer(c ContainerBox, w io.Writer) error
- func EncodeHeader(b Box, w io.Writer) error
- func IsSyncSampleFlags(flags uint32) bool
- func SetNonSyncSampleFlags(flags uint32) uint32
- func SetSyncSampleFlags(flags uint32) uint32
- type AudioSampleEntryBox
- type AudioSpecificConfig
- type AvcCBox
- type Box
- func DecodeAudioSampleEntry(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeAvcC(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeBox(startPos uint64, r io.Reader) (Box, error)
- func DecodeBtrt(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeContainerChildren(hdr *boxHeader, startPos, endPos uint64, r io.Reader) ([]Box, error)
- func DecodeCtim(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeCtts(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeDinf(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeDref(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeEdts(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeElng(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeElst(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeEmsg(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeEsds(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeFree(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeFtyp(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeHdlr(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeIden(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeMdat(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeMdhd(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeMdia(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeMfhd(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeMinf(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeMoof(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeMoov(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeMvex(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeMvhd(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeNmhd(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodePayl(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodePrft(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeSenc(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeSidx(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeSmhd(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeStbl(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeStco(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeSthd(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeStpp(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeStsc(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeStsd(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeStss(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeStsz(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeSttg(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeStts(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeStyp(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeSubs(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeTfdt(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeTfhd(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeTkhd(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeTraf(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeTrak(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeTrex(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeTrun(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeURLBox(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeUUID(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeUnknown(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeVisualSampleEntry(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeVlab(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeVmhd(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeVsid(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeVttC(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeVtta(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeVttc(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeVtte(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeWvtt(hdr *boxHeader, startPos uint64, r io.Reader) (Box, error)
- type BoxDecoder
- type BtrtBox
- type ContainerBox
- type CtimBox
- type CttsBox
- type DinfBox
- type DrefBox
- type EdtsBox
- type ElngBox
- type ElstBox
- type EmsgBox
- type EsdsBox
- type File
- func (f *File) AddChild(box Box, boxStartPos uint64)
- func (f *File) AddMediaSegment(m *MediaSegment)
- func (f *File) Dump(w io.Writer, indent string) error
- func (f *File) DumpWithSampleData(w io.Writer) error
- func (f *File) Encode(w io.Writer) error
- func (f *File) IsFragmented() bool
- func (f *File) LastSegment() *MediaSegment
- type Fixed16
- type Fixed32
- type Fragment
- func (f *Fragment) AddChild(b Box)
- func (f *Fragment) AddFullSample(s *FullSample)
- func (f *Fragment) Dump(w io.Writer, indent string) error
- func (f *Fragment) DumpSampleData(w io.Writer, trex *TrexBox) error
- func (f *Fragment) Encode(w io.Writer) error
- func (f *Fragment) GetChildren() []Box
- func (f *Fragment) GetFullSamples(trex *TrexBox) ([]*FullSample, error)
- type FreeBox
- type FtypBox
- type FullSample
- type HdlrBox
- type IdenBox
- type InitSegment
- type InitializationVector
- type MdatBox
- type MdhdBox
- type MdiaBox
- type MediaSegment
- func (s *MediaSegment) AddFragment(f *Fragment)
- func (m *MediaSegment) Dump(w io.Writer, indent string) error
- func (s *MediaSegment) Encode(w io.Writer) error
- func (s *MediaSegment) Fragmentify(timescale uint64, trex *TrexBox, duration uint32) ([]*Fragment, error)
- func (s *MediaSegment) LastFragment() *Fragment
- type MfhdBox
- type MinfBox
- type MoofBox
- type MoovBox
- type MvexBox
- type MvhdBox
- type NmhdBox
- type PaylBox
- type PrftBox
- type Sample
- type SampleFlags
- type SencBox
- type SencSample
- type SidxBox
- type SidxRef
- type SliceReader
- func (s *SliceReader) GetPos() int
- func (s *SliceReader) Length() int
- func (s *SliceReader) NrRemainingBytes() int
- func (s *SliceReader) ReadBytes(n int) []byte
- func (s *SliceReader) ReadFixedLengthString(length int) string
- func (s *SliceReader) ReadInt16() int16
- func (s *SliceReader) ReadInt32() int32
- func (s *SliceReader) ReadInt64() int64
- func (s *SliceReader) ReadUint8() byte
- func (s *SliceReader) ReadUint16() uint16
- func (s *SliceReader) ReadUint32() uint32
- func (s *SliceReader) ReadUint64() uint64
- func (s *SliceReader) ReadZeroTerminatedString() (string, error)
- func (s *SliceReader) RemainingBytes() []byte
- func (s *SliceReader) SetPos(pos int)
- func (s *SliceReader) SkipBytes(n int)
- type SliceWriter
- func (b *SliceWriter) WriteBytes(byteSlice []byte)
- func (b *SliceWriter) WriteInt16(n int16)
- func (b *SliceWriter) WriteInt32(n int32)
- func (b *SliceWriter) WriteInt64(n int64)
- func (b *SliceWriter) WriteString(s string, addZeroEnd bool)
- func (b *SliceWriter) WriteUint8(n byte)
- func (b *SliceWriter) WriteUint16(n uint16)
- func (b *SliceWriter) WriteUint32(n uint32)
- func (b *SliceWriter) WriteUint64(n uint64)
- func (b *SliceWriter) WriteUnityMatrix()
- func (b *SliceWriter) WriteZeroBytes(n int)
- type SmhdBox
- type StblBox
- type StcoBox
- type SthdBox
- type StppBox
- type StscBox
- type StsdBox
- func (s *StsdBox) AddChild(box Box)
- func (s *StsdBox) Dump(w io.Writer, indent, indentStep string) error
- func (s *StsdBox) Encode(w io.Writer) error
- func (s *StsdBox) GetSampleDescription(index int) (Box, error)
- func (s *StsdBox) ReplaceChild(box Box)
- func (s *StsdBox) Size() uint64
- func (s *StsdBox) Type() string
- type StssBox
- type StszBox
- type SttgBox
- type SttsBox
- func (s *SttsBox) Dump(w io.Writer, indent, indentStep string) error
- func (b *SttsBox) Encode(w io.Writer) error
- func (b *SttsBox) GetDecodeTime(sampleNr uint32) (decTime uint64, dur uint32)
- func (b *SttsBox) GetTimeCode(sample, timescale uint32) time.Duration
- func (b *SttsBox) Size() uint64
- func (b *SttsBox) Type() string
- type StypBox
- type SubSamplePattern
- type SubsBox
- type SubsEntry
- type SubsSample
- type TfdtBox
- type TfhdBox
- func (t *TfhdBox) DefaultBaseIfMoof() bool
- func (t *TfhdBox) Dump(w io.Writer, indent, indentStep string) error
- func (t *TfhdBox) DurationIsEmpty() bool
- func (t *TfhdBox) Encode(w io.Writer) error
- func (t *TfhdBox) HasBaseDataOffset() bool
- func (t *TfhdBox) HasDefaultSampleDuration() bool
- func (t *TfhdBox) HasDefaultSampleFlags() bool
- func (t *TfhdBox) HasDefaultSampleSize() bool
- func (t *TfhdBox) HasSampleDescriptionIndex() bool
- func (t *TfhdBox) Size() uint64
- func (t *TfhdBox) Type() string
- type TfrfData
- type TfxdData
- type TkhdBox
- type TrafBox
- type TrakBox
- func (t *TrakBox) AddChild(box Box)
- func (t *TrakBox) Dump(w io.Writer, indent, indentStep string) error
- func (t *TrakBox) Encode(w io.Writer) error
- func (t *TrakBox) GetChildren() []Box
- func (t *TrakBox) SetAACDescriptor(objType byte, samplingFrequency int) error
- func (t *TrakBox) SetAVCDescriptor(sampleDescriptorType string, spsNALU []byte, ppsNALUs [][]byte)
- func (t *TrakBox) Size() uint64
- func (t *TrakBox) Type() string
- type TrexBox
- type TrunBox
- func (t *TrunBox) AddFullSample(s *FullSample)
- func (t *TrunBox) AddSample(s *Sample)
- func (t *TrunBox) AddSampleDefaultValues(tfhd *TfhdBox, trex *TrexBox)
- func (t *TrunBox) Dump(w io.Writer, indent, indentStep string) error
- func (t *TrunBox) Duration(defaultSampleDuration uint32) uint64
- func (t *TrunBox) Encode(w io.Writer) error
- func (t *TrunBox) GetFullSamples(baseOffset uint32, baseTime uint64, mdat *MdatBox) []*FullSample
- func (t *TrunBox) GetSamples() []*Sample
- func (t *TrunBox) HasDataOffset() bool
- func (t *TrunBox) HasFirstSampleFlags() bool
- func (t *TrunBox) HasSampleCTO() bool
- func (t *TrunBox) HasSampleDuration() bool
- func (t *TrunBox) HasSampleFlags() bool
- func (t *TrunBox) HasSampleSize() bool
- func (t *TrunBox) SampleCount() uint32
- func (t *TrunBox) Size() uint64
- func (t *TrunBox) Type() string
- type URLBox
- type UUIDBox
- type UnknownBox
- type VisualSampleEntryBox
- type VlabBox
- type VmhdBox
- type VsidBox
- type VttCBox
- type VttaBox
- type VttcBox
- type VtteBox
- type WvttBox
Constants ¶
const ( // AAClc - AAC-LC Low Complexity AAClc = 2 // HEAACv1 - HE-AAC version 1 with SBR HEAACv1 = 5 // HEAACv2 - HE-AAC version 2 with SBR and PS HEAACv2 = 29 )
const DefaultTrakID = 1
DefaultTrakID - trakID used when generating new fragmented content
const NonSyncSampleFlags uint32 = 0x01000000
NonSyncSampleFlags - flags for non-sync sample
const SyncSampleFlags uint32 = 0x02010000
SyncSampleFlags - flags for I-frame or other sync sample
const UseSubSampleEncryption = 0x2
UseSubSampleEncryption - flag for subsample encryption
Variables ¶
This section is empty.
Functions ¶
func DumpContainer ¶
func DumpContainer(c ContainerBox, w io.Writer, indent, indentStep string) error
func EncodeContainer ¶
func EncodeContainer(c ContainerBox, w io.Writer) error
EncodeContainer - marshal container c to w
func EncodeHeader ¶
EncodeHeader encodes a box header to a writer
func IsSyncSampleFlags ¶
IsSyncSampleFlags - flags is set correctly for sync sample
func SetNonSyncSampleFlags ¶
SetNonSyncSampleFlags - return flags with nonsyncsample pattern
func SetSyncSampleFlags ¶
SetSyncSampleFlags - return flags with syncsample pattern
Types ¶
type AudioSampleEntryBox ¶
type AudioSampleEntryBox struct {
DataReferenceIndex uint16
ChannelCount uint16
SampleSize uint16
SampleRate uint16 // Integer part
Esds *EsdsBox
Children []Box
// contains filtered or unexported fields
}
AudioSampleEntryBox according to ISO/IEC 14496-12
func CreateAudioSampleEntryBox ¶
func CreateAudioSampleEntryBox(name string, nrChannels, sampleSize, sampleRate uint16, child Box) *AudioSampleEntryBox
CreateAudioSampleEntryBox - Create new AudioSampleEntry such as mp4
func NewAudioSampleEntryBox ¶
func NewAudioSampleEntryBox(name string) *AudioSampleEntryBox
NewAudioSampleEntryBox - Create new empty mp4a box
func (*AudioSampleEntryBox) AddChild ¶
func (a *AudioSampleEntryBox) AddChild(b Box)
AddChild - add a child box (avcC normally, but clap and pasp could be part of visual entry)
func (*AudioSampleEntryBox) Dump ¶
func (a *AudioSampleEntryBox) Dump(w io.Writer, indent, indentStep string) error
func (*AudioSampleEntryBox) Encode ¶
func (a *AudioSampleEntryBox) Encode(w io.Writer) error
Encode - write box to w
func (*AudioSampleEntryBox) Size ¶
func (a *AudioSampleEntryBox) Size() uint64
Size - return calculated size
func (*AudioSampleEntryBox) Type ¶
func (a *AudioSampleEntryBox) Type() string
Type - return box type
type AudioSpecificConfig ¶
type AudioSpecificConfig struct {
ObjectType byte
ChannelConfiguration byte // Defined in Table 1.19
SamplingFrequency int
ExtensionFrequency int
SBRPresentFlag bool
PSPresentFlag bool
}
AudioSpecificConfig according to ISO/IES 14496-3 Syntax specified in Table 1.15
func DecodeAudioSpecificConfig ¶
func DecodeAudioSpecificConfig(r io.Reader) (AudioSpecificConfig, error)
DecodeAudioSpecificConfig -
type AvcCBox ¶
type AvcCBox struct {
avc.AVCDecConfRec
}
AvcCBox - AVCConfigurationBox (ISO/IEC 14496-15 5.4.2.1.2 and 5.3.3.1.2) Contains one AVCDecoderConfigurationRecord
func CreateAvcC ¶
CreateAvcC - Create an avcC box based on SPS and PPS
type Box ¶
type Box interface {
Type() string
Size() uint64
Encode(w io.Writer) error
Dump(w io.Writer, indent, indentStep string) error
}
Box is the general interface
func DecodeAudioSampleEntry ¶
DecodeAudioSampleEntry - decode mp4a... box
func DecodeAvcC ¶
DecodeAvcC - box-specific decode
func DecodeBtrt ¶
DecodeBtrt - box-specific decode
func DecodeContainerChildren ¶
DecodeContainerChildren decodes a container box
func DecodeCtim ¶
DecodeCtim - box-specific decode
func DecodeCtts ¶
DecodeCtts - box-specific decode
func DecodeDinf ¶
DecodeDinf - box-specific decode
func DecodeDref ¶
DecodeDref - box-specific decode
func DecodeEdts ¶
DecodeEdts - box-specific decode
func DecodeElng ¶
DecodeElng - box-specific decode
func DecodeElst ¶
DecodeElst - box-specific decode
func DecodeEmsg ¶
DecodeEmsg - box-specific decode
func DecodeEsds ¶
DecodeEsds - box-specific decode
func DecodeFree ¶
DecodeFree - box-specific decode
func DecodeFtyp ¶
DecodeFtyp - box-specific decode
func DecodeHdlr ¶
DecodeHdlr - box-specific decode
func DecodeIden ¶
DecodeIden - box-specific decode
func DecodeMdat ¶
DecodeMdat - box-specific decode
func DecodeMdhd ¶
DecodeMdhd - Decode box
func DecodeMdia ¶
DecodeMdia - box-specific decode
func DecodeMfhd ¶
DecodeMfhd - box-specific decode
func DecodeMinf ¶
DecodeMinf - box-specific decode
func DecodeMoof ¶
DecodeMoof - box-specific decode
func DecodeMoov ¶
DecodeMoov - box-specific decode
func DecodeMvex ¶
DecodeMvex - box-specific decode
func DecodeMvhd ¶
DecodeMvhd - box-specific decode
func DecodeNmhd ¶
DecodeNmhd - box-specific decode
func DecodePayl ¶
DecodePayl - box-specific decode
func DecodePrft ¶
DecodePrft - box-specific decode
func DecodeSenc ¶
DecodeSenc - box-specific decode
func DecodeSidx ¶
DecodeSidx - box-specific decode
func DecodeSmhd ¶
DecodeSmhd - box-specific decode
func DecodeStbl ¶
DecodeStbl - box-specific decode
func DecodeStco ¶
DecodeStco - box-specific decode
func DecodeSthd ¶
DecodeSthd - box-specific decode
func DecodeStpp ¶
DecodeStpp - Decode XMLSubtitleSampleEntry (stpp)
func DecodeStsc ¶
DecodeStsc - box-specific decode
func DecodeStsd ¶
DecodeStsd - box-specific decode
func DecodeStss ¶
DecodeStss - box-specific decode
func DecodeStsz ¶
DecodeStsz - box-specific decode
func DecodeSttg ¶
DecodeSttg - box-specific decode
func DecodeStts ¶
DecodeStts - box-specific decode
func DecodeStyp ¶
DecodeStyp - box-specific decode
func DecodeSubs ¶
DecodeSubs - box-specific decode
func DecodeTfdt ¶
DecodeTfdt - box-specific decode
func DecodeTfhd ¶
DecodeTfhd - box-specific decode
func DecodeTkhd ¶
DecodeTkhd - box-specific decode
func DecodeTraf ¶
DecodeTraf - box-specific decode
func DecodeTrak ¶
DecodeTrak - box-specific decode
func DecodeTrex ¶
DecodeTrex - box-specific decode
func DecodeTrun ¶
DecodeTrun - box-specific decode
func DecodeURLBox ¶
DecodeURLBox - box-specific decode
func DecodeUUID ¶
DecodeUUIDBox - decode a UUID box including tfxd or tfrf
func DecodeUnknown ¶
DecodeUnknown - decode an unknown box
func DecodeVisualSampleEntry ¶
DecodeVisualSampleEntry - decode avc1/avc3/... box
func DecodeVlab ¶
DecodeVlab - box-specific decode
func DecodeVmhd ¶
DecodeVmhd - box-specific decode
func DecodeVsid ¶
DecodeVsid - box-specific decode
func DecodeVttC ¶
DecodeVttC - box-specific decode
func DecodeVtta ¶
DecodeVtta - box-specific decode
func DecodeVttc ¶
DecodeVttc - box-specific decode
func DecodeVtte ¶
DecodeVtte - box-specific decode
type BoxDecoder ¶
BoxDecoder is function signature of the Box Decode method
type ContainerBox ¶
type ContainerBox interface {
Type() string
Size() uint64
Encode(w io.Writer) error
GetChildren() []Box
Dump(w io.Writer, indent, indentStep string) error
}
ContainerBox is interface for ContainerBoxes
type CtimBox ¶
type CtimBox struct {
CueCurrentTime string
}
CtimBox - CueTimeBox (ctim) CueCurrentTime is current time indication (for split cues)
type CttsBox ¶
type CttsBox struct {
Version byte
Flags uint32
SampleCount []uint32
SampleOffset []int32 // int32 to handle version 1
}
CttsBox - Composition Time to Sample Box (ctts - optional)
Contained in: Sample Table Box (stbl)
func (*CttsBox) GetCompositionTimeOffset ¶
GetCompositionTimeOffset - composition time offset for sampleNr in track timescale
type DinfBox ¶
DinfBox - Data Information Box (dinf - mandatory)
Contained in : Media Information Box (minf) or Meta Box (meta)
func (*DinfBox) GetChildren ¶
GetChildren - list of child boxes
type DrefBox ¶
DrefBox - Data Reference Box (dref - mandatory)
Contained id: Data Information Box (dinf)
Defines the location of the media data. If the data for the track is located in the same file it contains nothing useful.
func CreateDref ¶
func CreateDref() *DrefBox
CreateDref - Create an DataReferenceBox for selfcontained content
type EdtsBox ¶
EdtsBox - Edit Box (edts - optional)
Contained in: Track Box ("trak")
The edit box maps the presentation timeline to the media-time line
func (*EdtsBox) GetChildren ¶
GetChildren - list of child boxes
type ElngBox ¶
type ElngBox struct {
Language string
}
ElngBox - Extended Language Box
func CreateElng ¶
CreateElng - Create an Extended Language Box
type ElstBox ¶
type ElstBox struct {
Version byte
Flags uint32
SegmentDuration []uint64
MediaTime []int64
MediaRateInteger []int16
MediaRateFraction []int16
}
ElstBox - Edit List Box (elst - optional)
Contained in : Edit Box (edts)
type EmsgBox ¶
type EmsgBox struct {
Version byte
Flags uint32
TimeScale uint32
PresentationTimeDelta uint32
PresentationTime uint64
EventDuration uint32
Id uint32
SchemeIdURI string
Value string
}
EmsgBox - DASHEventMessageBox as defined in ISO/IEC 23009-1
type EsdsBox ¶
type EsdsBox struct {
Version byte
Flags uint32
EsDescrTag byte
EsID uint16
FlagsAndPriority byte
DecoderConfigDescrTag byte
ObjectType byte
StreamType byte
BufferSizeDB uint32
MaxBitrate uint32
AvgBitrate uint32
DecSpecificInfoTag byte
DecConfig []byte
SLConfigDescrTag byte
SLConfigValue byte
// contains filtered or unexported fields
}
EsdsBox as used for MPEG-audio, see ISO 14496-1 Section 7.2.6.6 for DecoderConfigDescriptor
func CreateEsdsBox ¶
CreateEsdsBox - Create an EsdsBox geiven decConfig
type File ¶
type File struct {
Ftyp *FtypBox // Only used for non-fragmented files
Moov *MoovBox // Only used for non-fragmented files
Mdat *MdatBox // Only used for non-fragmented files
Init *InitSegment // Init data (ftyp + moov for fragmented file)
Sidx *SidxBox // SidxBox for a DASH OnDemand file
Segments []*MediaSegment // Media segment
Children []Box // All top-level boxes in order
// contains filtered or unexported fields
}
File - an MPEG-4 file asset
A MPEG-4 media contains three main boxes if progressive :
ftyp : the file type box moov : the movie box (meta-data) mdat : the media data (chunks and samples)
If fragmented, the data is instead in Init and/or Segments.
segments.
func DecodeFile ¶
DecodeFile - parse and decode a file from reader r
func (*File) AddMediaSegment ¶
func (f *File) AddMediaSegment(m *MediaSegment)
AddMediaSegment - add a mediasegment to file f
func (*File) DumpWithSampleData ¶
DumpWithSampleData - print information about file and its children boxes
func (*File) IsFragmented ¶
IsFragmented - is file made of multiple segments (Mp4 fragments)
func (*File) LastSegment ¶
func (f *File) LastSegment() *MediaSegment
LastSegment - Currently last segment
type Fragment ¶
type Fragment struct {
Prft *PrftBox
Moof *MoofBox
Mdat *MdatBox
Children []Box // All top-level boxes in order
}
Fragment - MP4 Fragment ([prft] + moof + mdat)
func CreateFragment ¶
CreateFragment - create emtpy fragment with one single track for output
func (*Fragment) AddFullSample ¶
func (f *Fragment) AddFullSample(s *FullSample)
AddFullSample - add a full sample to a fragment
func (*Fragment) DumpSampleData ¶
DumpSampleData - Get Sample data and print out
func (*Fragment) GetChildren ¶
GetChildren - return children boxes
func (*Fragment) GetFullSamples ¶
func (f *Fragment) GetFullSamples(trex *TrexBox) ([]*FullSample, error)
GetFullSamples - Get full samples including media and accumulated time
type FtypBox ¶
FtypBox - File Type Box (ftyp - mandatory)
func CreateFtyp ¶
func CreateFtyp() *FtypBox
CreateFtyp - Create an Ftyp box suitaable for DASH/CMAF
type FullSample ¶
type FullSample struct {
Sample
DecodeTime uint64 // Absolute decode time (offset + accumulated sample Dur)
Data []byte // Sample data
}
FullSample - include accumulated time and data. Times in mdhd timescale
func (*FullSample) PresentationTime ¶
func (s *FullSample) PresentationTime() uint64
PresentationTime - DecodeTime displaced by composition time offset (possibly negative)
type HdlrBox ¶
HdlrBox - Handler Reference Box (hdlr - mandatory)
Contained in: Media Box (mdia) or Meta Box (meta)
This box describes the type of data contained in the trak. HandlerType can be : "vide" (video track), "soun" (audio track), "subt" (subtitle track) Other types are: "hint" (hint track), "meta" (timed Metadata track), "auxv" (auxiliary video track).
func CreateHdlr ¶
CreateHdlr - create mediaType-specific hdlr box
type IdenBox ¶
type IdenBox struct {
CueID string
}
IdenBox - CueIDBox (iden)
type InitSegment ¶
type InitSegment struct {
MediaType string
Ftyp *FtypBox
Moov *MoovBox
Children []Box // All top-level boxes in order
}
InitSegment - MP4/CMAF init segment
func CreateEmptyMP4Init ¶
func CreateEmptyMP4Init(timeScale uint32, mediaType, language string) *InitSegment
CreateEmptyMP4Init - Create a one-track MP4 init segment with empty stsd box The trak has trackID = 1. The irrelevant mdhd timescale is set to 90000 and duration = 0
func (*InitSegment) AddChild ¶
func (s *InitSegment) AddChild(b Box)
AddChild - Add a top-level box to InitSegment
func (*InitSegment) Dump ¶
func (i *InitSegment) Dump(w io.Writer, indent string) error
Dump - write box tree with indent for each level
func (*InitSegment) Encode ¶
func (s *InitSegment) Encode(w io.Writer) error
Encode - encode an initsegment to a Writer
func (*InitSegment) GetMediaType ¶
func (s *InitSegment) GetMediaType() string
GetMediaType - should return video or audio (at present)
type MdatBox ¶
MdatBox - Media Data Box (mdat) The mdat box contains media chunks/samples.
func (*MdatBox) AddSampleData ¶
AddSampleData - a sample data to an mdat box
func (*MdatBox) HeaderLength ¶
HeaderLength - length of box header including possible largeSize
type MdhdBox ¶
type MdhdBox struct {
Version byte // Only version 0
Flags uint32
CreationTime uint64 // Typically not set
ModificationTime uint64 // Typically not set
Timescale uint32 // Media timescale for this track
Duration uint64 // Trak duration, 0 for fragmented files
Language uint16 // Three-letter ISO-639-2/T language code
}
MdhdBox - Media Header Box (mdhd - mandatory)
Contained in : Media Box (mdia)
Timescale defines the timescale used for this track. Language is a ISO-639-2/T language code stored as 1bit padding + [3]int5
func (*MdhdBox) GetLanguage ¶
GetLanguage - Get three-byte language string
func (*MdhdBox) SetLanguage ¶
SetLanguage - Set three-byte language string
type MdiaBox ¶
type MdiaBox struct {
Mdhd *MdhdBox
Hdlr *HdlrBox
Elng *ElngBox
Minf *MinfBox
Elst *ElstBox
Children []Box
}
MdiaBox - Media Box (mdia)
Contained in : Track Box (trak) Contains all information about the media data.
func (*MdiaBox) GetChildren ¶
GetChildren - list of child boxes
type MediaSegment ¶
type MediaSegment struct {
Styp *StypBox
Sidx *SidxBox // Sidx for a segment
Fragments []*Fragment
}
MediaSegment - MP4 Media Segment
func NewMediaSegment ¶
func NewMediaSegment() *MediaSegment
NewMediaSegment - New empty MediaSegment
func (*MediaSegment) AddFragment ¶
func (s *MediaSegment) AddFragment(f *Fragment)
AddFragment - Add a fragment to a MediaSegment
func (*MediaSegment) Dump ¶
func (m *MediaSegment) Dump(w io.Writer, indent string) error
Dump - write box tree with indent for each level
func (*MediaSegment) Encode ¶
func (s *MediaSegment) Encode(w io.Writer) error
Encode - Write MediaSegment via writer
func (*MediaSegment) Fragmentify ¶
func (s *MediaSegment) Fragmentify(timescale uint64, trex *TrexBox, duration uint32) ([]*Fragment, error)
Fragmentify - Split into multiple fragments. Assume single mdat and trun for now
func (*MediaSegment) LastFragment ¶
func (s *MediaSegment) LastFragment() *Fragment
LastFragment - Currently last fragment
type MinfBox ¶
type MinfBox struct {
Vmhd *VmhdBox
Smhd *SmhdBox
Stbl *StblBox
Dinf *DinfBox
Hdlr *HdlrBox
Children []Box
}
MinfBox - Media Information Box (minf - mandatory)
Contained in : Media Box (mdia)
func (*MinfBox) GetChildren ¶
GetChildren - list of child boxes
type MoofBox ¶
type MoofBox struct {
Mfhd *MfhdBox
Traf *TrafBox // A single traf child box
Children []Box
StartPos uint64
}
MoofBox - Movie Fragment Box (moof)
Contains all meta-data. To be able to stream a file, the moov box should be placed before the mdat box.
func (*MoofBox) GetChildren ¶
GetChildren - list of child boxes
type MoovBox ¶
MoovBox - Movie Box (moov - mandatory)
Contains all meta-data. To be able to stream a file, the moov box should be placed before the mdat box.
func (*MoovBox) GetChildren ¶
GetChildren - list of child boxes
type MvexBox ¶
MvexBox - MovieExtendsBox (mevx)
Contained in : Movie Box (moov)
Its presence signals a fragmented asset
func (*MvexBox) GetChildren ¶
GetChildren - list of child boxes
type MvhdBox ¶
type MvhdBox struct {
Version byte
Flags uint32
CreationTime uint64
ModificationTime uint64
Timescale uint32
Duration uint64
NextTrackID int32
Rate Fixed32
Volume Fixed16
}
MvhdBox - Movie Header Box (mvhd - mandatory)
Contained in : Movie Box (‘moov’)
Contains all media information (duration, ...).
Duration is measured in "time units", and timescale defines the number of time units per second.
type NmhdBox ¶
NmhdBox - Null Media Header Box (nmhd - often used instead ofsthd for subtitle tracks)
type PaylBox ¶
type PaylBox struct {
CueText string
}
PaylBox - CuePayloadBox (payl)
type PrftBox ¶
PrftBox - Producer Reference Box (prft)
Contained in File before moof box
func CreatePrftBox ¶
CreatePrftBox - Create a new PrftBox
type Sample ¶
type Sample struct {
Flags uint32 // Flag sync sample etc
Dur uint32 // Sample duration in mdhd timescale
Size uint32 // Size of sample data
Cto int32 // Signed composition time offset
}
Sample - sample as used in trun box (mdhd timescale)
type SampleFlags ¶
type SampleFlags struct {
IsLeading uint32
SampleDependsOn uint32
SampleIsDependedOn uint32
SampleHasRedundancy uint32
SampleDegradationPriority uint16
SampleIsNonSync bool
}
SampleFlags according to 14496-12 Sec. 8.8.3.1
func DecodeSampleFlags ¶
func DecodeSampleFlags(u uint32) *SampleFlags
DecodeSampleFlags - decode a uint32 flags field
type SencBox ¶
type SencBox struct {
Version byte
Flags uint32
SampleCount uint32
IVs []InitializationVector // 8 or 16 bytes if present
SubSamples [][]SubSamplePattern
}
SencBox - Sample Encryption Box (senc) See ISO/IEC 23001-7 Section 7.2 Full Box + SampleCount
func (*SencBox) AddSample ¶
func (s *SencBox) AddSample(sample SencSample) error
AddSample - add a senc sample with possible IV and subsamples
func (*SencBox) GetPerSampleIVSize ¶
type SencSample ¶
type SencSample struct {
IV InitializationVector // 0,8,16 byte length
SubSamples []SubSamplePattern
}
SencSample - sample in SencBox
type SidxBox ¶
type SidxBox struct {
Version byte
Flags uint32
ReferenceID uint32
Timescale uint32
EarliestPresentationTime uint64
FirstOffset uint64
SidxRefs []SidxRef
}
SidxBox - SegmentIndexBox
func CreateSidx ¶
CreateSidx - Create a new TfdtBox with baseMediaDecodeTime
type SidxRef ¶
type SidxRef struct {
ReferencedSize uint32
SubSegmentDuration uint32
SAPDeltaTime uint32
ReferenceType uint8 // 1-bit
StartsWithSAP uint8 // 1-bit
SAPType uint8
}
SidxRef - reference as used inside SidxBox
type SliceReader ¶
type SliceReader struct {
// contains filtered or unexported fields
}
SliceReader - read integers from a slice
func NewSliceReader ¶
func NewSliceReader(data []byte) *SliceReader
NewSliceReader - create a new slice reader reading from data
func (*SliceReader) NrRemainingBytes ¶
func (s *SliceReader) NrRemainingBytes() int
NrRemaingingByts - return number of bytes remaining
func (*SliceReader) ReadBytes ¶
func (s *SliceReader) ReadBytes(n int) []byte
ReadBytes - read a slice of bytes
func (*SliceReader) ReadFixedLengthString ¶
func (s *SliceReader) ReadFixedLengthString(length int) string
ReadFixedLengthString - read string of specified length
func (*SliceReader) ReadInt16 ¶
func (s *SliceReader) ReadInt16() int16
ReadInt16 - read int16 from slice
func (*SliceReader) ReadInt32 ¶
func (s *SliceReader) ReadInt32() int32
ReadInt32 - read int32 from slice
func (*SliceReader) ReadInt64 ¶
func (s *SliceReader) ReadInt64() int64
ReadInt64 - read int64 from slice
func (*SliceReader) ReadUint8 ¶
func (s *SliceReader) ReadUint8() byte
ReadUint8 - read uint8 from slice
func (*SliceReader) ReadUint16 ¶
func (s *SliceReader) ReadUint16() uint16
ReadUint16 - read uint16 from slice
func (*SliceReader) ReadUint32 ¶
func (s *SliceReader) ReadUint32() uint32
ReadUint32 - read uint32 from slice
func (*SliceReader) ReadUint64 ¶
func (s *SliceReader) ReadUint64() uint64
ReadUint64 - read uint64 from slice
func (*SliceReader) ReadZeroTerminatedString ¶
func (s *SliceReader) ReadZeroTerminatedString() (string, error)
ReadZeroTerminatedString - read string until zero
func (*SliceReader) RemainingBytes ¶
func (s *SliceReader) RemainingBytes() []byte
RemainingBytes - return remaining bytes of this slice
func (*SliceReader) SetPos ¶
func (s *SliceReader) SetPos(pos int)
SetPos - set read position is slice
func (*SliceReader) SkipBytes ¶
func (s *SliceReader) SkipBytes(n int)
SkipBytes - skip passed n bytes
type SliceWriter ¶
type SliceWriter struct {
// contains filtered or unexported fields
}
SliceWriter - write numbers to a []byte slice
func NewSliceWriter ¶
func NewSliceWriter(data []byte) *SliceWriter
NewSliceWriter - create writer around slice
func (*SliceWriter) WriteBytes ¶
func (b *SliceWriter) WriteBytes(byteSlice []byte)
WriteBytes - write []byte
func (*SliceWriter) WriteInt16 ¶
func (b *SliceWriter) WriteInt16(n int16)
WriteInt16 - write int16 to slice
func (*SliceWriter) WriteInt32 ¶
func (b *SliceWriter) WriteInt32(n int32)
WriteInt32 - write int32 to slice
func (*SliceWriter) WriteInt64 ¶
func (b *SliceWriter) WriteInt64(n int64)
WriteInt64 - write int64 to slice
func (*SliceWriter) WriteString ¶
func (b *SliceWriter) WriteString(s string, addZeroEnd bool)
WriteString - write string to slice with or without zero end
func (*SliceWriter) WriteUint8 ¶
func (b *SliceWriter) WriteUint8(n byte)
WriteUint8 - write byte to slice
func (*SliceWriter) WriteUint16 ¶
func (b *SliceWriter) WriteUint16(n uint16)
WriteUint16 - write uint16 to slice
func (*SliceWriter) WriteUint32 ¶
func (b *SliceWriter) WriteUint32(n uint32)
WriteUint32 - write uint32 to slice
func (*SliceWriter) WriteUint64 ¶
func (b *SliceWriter) WriteUint64(n uint64)
WriteUint64 - write uint64 to slice
func (*SliceWriter) WriteUnityMatrix ¶
func (b *SliceWriter) WriteUnityMatrix()
WriteUnityMatrix - write a unity matrix for mvhd or tkhd
func (*SliceWriter) WriteZeroBytes ¶
func (b *SliceWriter) WriteZeroBytes(n int)
WriteZeroBytes - write n byte of zeroes
type SmhdBox ¶
SmhdBox - Sound Media Header Box (smhd - mandatory for sound tracks)
Contained in : Media Information Box (minf)
func CreateSmhd ¶
func CreateSmhd() *SmhdBox
CreateSmhd - Create Sound Media Header Box (all is zero)
type StblBox ¶
type StblBox struct {
Stsd *StsdBox
Stts *SttsBox
Stss *StssBox
Stsc *StscBox
Stsz *StszBox
Stco *StcoBox
Ctts *CttsBox
Children []Box
}
StblBox - Sample Table Box (stbl - mandatory)
Contained in : Media Information Box (minf)
The table contains all information relevant to data samples (times, chunks, sizes, ...)
func (*StblBox) GetChildren ¶
GetChildren - list of child boxes
type StcoBox ¶
StcoBox - Chunk Offset Box (stco - mandatory)
Contained in : Sample Table box (stbl)
This is the 32bits version of the box, the 64bits version (co64) is not decoded.
The table contains the offsets (starting at the beginning of the file) for each chunk of data for the current track. A chunk contains samples, the table defining the allocation of samples to each chunk is stsc.
type StppBox ¶
type StppBox struct {
Namespace string // Mandatory
SchemaLocation string // Optional
AuxiliaryMimeTypes string // Required if auxiliary types present
Btrt *BtrtBox // Optional
Children []Box
DataReferenceIndex uint16
}
StppBox - XMLSubtitleSampleEntryr Box (stpp)
Contained in : Media Information Box (minf)
func NewStppBox ¶
NewStppBox - Create new stpp box
type StscBox ¶
type StscBox struct {
Version byte
Flags uint32
FirstChunk []uint32
SamplesPerChunk []uint32
SampleDescriptionID []uint32
}
StscBox - Sample To Chunk Box (stsc - mandatory)
A chunk contains samples. This table defines to which chunk a sample is associated. Each entry is defined by :
- first chunk : all chunks starting at this index up to the next first chunk have the same sample count/description
- samples per chunk : number of samples in the chunk
- description id : description (see the sample description box - stsd)
func (*StscBox) ChunkNrFromSampleNr ¶
ChunkNrFromSampleNr - get chunk number from sampleNr (1-based)
type StsdBox ¶
type StsdBox struct {
Version byte
Flags uint32
SampleCount uint32
AvcX *VisualSampleEntryBox
Mp4a *AudioSampleEntryBox
Children []Box
}
StsdBox - Sample Description Box (stsd - manatory) See ISO/IEC 14496-12 Section 8.5.2.2 Full Box + SampleCount
func (*StsdBox) GetSampleDescription ¶
GetSampleDescription - get one of multiple descriptions
func (*StsdBox) ReplaceChild ¶
AddChild - Replace a child box with one of the same type
type StssBox ¶
type StssBox struct {
Version byte
Flags uint32
SampleNumber []uint32
// contains filtered or unexported fields
}
StssBox - Sync Sample Box (stss - optional)
Contained in : Sample Table box (stbl)
This lists all sync samples (key frames for video tracks) in the data. If absent, all samples are sync samples.
func (*StssBox) IsSyncSample ¶
IsSyncSample - check if a sample is a sync sample
type StszBox ¶
type StszBox struct {
Version byte
Flags uint32
SampleUniformSize uint32
SampleNumber uint32
SampleSize []uint32
}
StszBox - Sample Size Box (stsz - mandatory)
Contained in : Sample Table box (stbl)
For each track, either stsz of the more compact stz2 must be present. stz2 variant is not supported.
This table lists the size of each sample. If all samples have the same size, it can be defined in the SampleUniformSize attribute.
func (*StszBox) GetSampleSize ¶
GetSampleSize returns the size (in bytes) of a sample
type SttgBox ¶
type SttgBox struct {
Settings string
}
SttgBox - CueSettingsBox (sttg)
type SttsBox ¶
SttsBox - Decoding Time to Sample Box (stts - mandatory)
This table contains the duration in time units for each sample.
- SampleCount : the number of consecutive samples having the same duration
- SampleTimeDelta : duration in time units
func (*SttsBox) GetDecodeTime ¶
GetDecodeTime - decode time and duration for sampleNr in track timescale
func (*SttsBox) GetTimeCode ¶
GetTimeCode - return the timecode (duration since the beginning of the media) of the beginning of a sample
type SubSamplePattern ¶
SubSamplePattern - pattern of subsample encryption
type SubsEntry ¶
type SubsEntry struct {
SampleDelta uint32
SubSamples []SubsSample
}
SubsEntry - entry in SubsBox
type SubsSample ¶
type SubsSample struct {
SubsampleSize uint32
CodecSpecificParameters uint32
SubsamplePriority uint8
Discardable uint8
}
SubsSample - sample in SubsEntry
type TfdtBox ¶
TfdtBox - Track Fragment Decode Time (tfdt)
Contained in : Track Fragment box (traf)
func CreateTfdt ¶
CreateTfdt - Create a new TfdtBox with baseMediaDecodeTime
func (*TfdtBox) SetBaseMediaDecodeTime ¶
SetBaseMediaDecodeTime - Set time of TfdtBox
type TfhdBox ¶
type TfhdBox struct {
Version byte
Flags uint32
TrackID uint32
BaseDataOffset uint64
SampleDescriptionIndex uint32
DefaultSampleDuration uint32
DefaultSampleSize uint32
DefaultSampleFlags uint32
}
TfhdBox - Track Fragment Header Box (tfhd)
Contained in : Track Fragment box (traf))
func CreateTfhd ¶
CreateTfhd - Create a new TfdtBox with baseMediaDecodeTime
func (*TfhdBox) DefaultBaseIfMoof ¶
DefaultBaseIfMoof - interpreted flags value
func (*TfhdBox) DurationIsEmpty ¶
DurationIsEmpty - interpreted flags value
func (*TfhdBox) HasBaseDataOffset ¶
HasBaseDataOffset - interpreted flags value
func (*TfhdBox) HasDefaultSampleDuration ¶
HasDefaultSampleDuration - interpreted flags value
func (*TfhdBox) HasDefaultSampleFlags ¶
HasDefaultSampleFlags - interpreted flags value
func (*TfhdBox) HasDefaultSampleSize ¶
HasDefaultSampleSize - interpreted flags value
func (*TfhdBox) HasSampleDescriptionIndex ¶
HasSampleDescriptionIndex - interpreted flags value
type TfrfData ¶
type TfrfData struct {
Version byte
Flags uint32
FragmentCount byte
FragmentAbsoluteTimes []uint64
FragmentAbsoluteDurations []uint64
}
TfrfData - MSS TfrfBox data after UUID part Defined in MSS-SSTR v20180912 section 2.2.4.5
type TfxdData ¶
type TfxdData struct {
Version byte
Flags uint32
FragmentAbsoluteTime uint64
FragmentAbsoluteDuration uint64
}
TfxdData - MSS TfxdBox data after UUID part Defined in MSS-SSTR v20180912 section 2.2.4.4
type TkhdBox ¶
type TkhdBox struct {
Version byte
Flags uint32
CreationTime uint64
ModificationTime uint64
TrackID uint32
Duration uint64
Layer int16
AlternateGroup int16 // should be int16
Volume Fixed16
Width, Height Fixed32
}
TkhdBox - Track Header Box (tkhd - mandatory)
This box describes the track. Duration is measured in time units (according to the time scale defined in the movie header box). Duration is 0 for fragmented files.
Volume (relevant for audio tracks) is a fixed point number (8 bits + 8 bits). Full volume is 1.0. Width and Height (relevant for video tracks) are fixed point numbers (16 bits + 16 bits). Video pixels are not necessarily square.
type TrafBox ¶
TrafBox - Track Fragment Box (traf)
Contained in : Movie Fragment Box (moof)
func (*TrafBox) GetChildren ¶
GetChildren - list of child boxes
func (*TrafBox) OptimizeTfhdTrun ¶
OptimizeTfhdTrun - optimize trun by default values in tfhd box
type TrakBox ¶
TrakBox - Track Box (tkhd - mandatory)
Contained in : Movie Box (moov)
A media file can contain one or more tracks.
func (*TrakBox) GetChildren ¶
GetChildren - list of child boxes
func (*TrakBox) SetAACDescriptor ¶
SetAACDescriptor - Modify a TrakBox by adding AAC SampleDescriptor objType is one of AAClc, HEAACv1, HEAACv2 For HEAAC, the samplingFrequency is the base frequency (normally 24000)
func (*TrakBox) SetAVCDescriptor ¶
SetAVCDescriptor - Modify a TrakBox by adding AVC SampleDescriptor from one SPS and multiple PPS Get width and height from SPS and fill into tkhd box.
type TrexBox ¶
type TrexBox struct {
Version byte
Flags uint32
TrackID uint32
DefaultSampleDescriptionIndex uint32
DefaultSampleDuration uint32
DefaultSampleSize uint32
DefaultSampleFlags uint32
}
TrexBox - Track Extends Box
Contained in : Mvex Box (mvex)
func CreateTrex ¶
func CreateTrex() *TrexBox
CreateTrex - create trex box with good default parameters
type TrunBox ¶
type TrunBox struct {
Version byte
DataOffset int32
Samples []*Sample
// contains filtered or unexported fields
}
TrunBox - Track Fragment Run Box (trun)
Contained in : Track Fragmnet Box (traf)
func CreateTrun ¶
func CreateTrun() *TrunBox
CreateTrun - create a TrunBox for filling up with samples
func (*TrunBox) AddFullSample ¶
func (t *TrunBox) AddFullSample(s *FullSample)
AddFullSample - add Sample part of FullSample
func (*TrunBox) AddSampleDefaultValues ¶
AddSampleDefaultValues - add values from tfhd and trex boxes if needed
func (*TrunBox) GetFullSamples ¶
func (t *TrunBox) GetFullSamples(baseOffset uint32, baseTime uint64, mdat *MdatBox) []*FullSample
GetFullSamples - get all sample data including accumulated time and binary media baseOffset is offset in mdat (normally 8) baseTime is offset in track timescale (from mfhd) To fill missing individual values from thd and trex defaults, call AddSampleDefaultValues() before this call
func (*TrunBox) GetSamples ¶
GetSamples - get all trun sample data To fill missing individual values from thd and trex defaults, call AddSampleDefaultValues() before this call
func (*TrunBox) HasDataOffset ¶
HasDataOffset - interpreted dataOffsetPresent flag
func (*TrunBox) HasFirstSampleFlags ¶
HasFirstSampleFlags - interpreted firstSampleFlagsPresent flag
func (*TrunBox) HasSampleCTO ¶
HasSampleCTO - interpreted sampleCompositionTimeOffset flag
func (*TrunBox) HasSampleDuration ¶
HasSampleDuration - interpreted sampleDurationPresent flag
func (*TrunBox) HasSampleFlags ¶
HasSampleFlags - interpreted sampleFlagsPresent flag
func (*TrunBox) HasSampleSize ¶
HasSampleSize - interpreted sampleSizePresent flag
func (*TrunBox) SampleCount ¶
SampleCount - return how many samples are defined
type UUIDBox ¶
UUIDBox - Used as container for MSS boxes tfxd and tfrf
type UnknownBox ¶
type UnknownBox struct {
// contains filtered or unexported fields
}
UnknownBox - box that we don't know how to parse
type VisualSampleEntryBox ¶
type VisualSampleEntryBox struct {
DataReferenceIndex uint16
Width uint16
Height uint16
Horizresolution uint32
Vertresolution uint32
FrameCount uint16
CompressorName string
AvcC *AvcCBox
Btrt *BtrtBox
Children []Box
// contains filtered or unexported fields
}
VisualSampleEntryBox - Video Sample Description box (avc1/avc3)
func CreateVisualSampleEntryBox ¶
func CreateVisualSampleEntryBox(name string, width, height uint16, avcC *AvcCBox) *VisualSampleEntryBox
CreateVisualSampleEntryBox - Create new VisualSampleEntry box such as avc1, avc3
func NewVisualSampleEntryBox ¶
func NewVisualSampleEntryBox(name string) *VisualSampleEntryBox
NewVisualSampleEntryBox - Create new empty avc1 or avc3 box
func (*VisualSampleEntryBox) AddChild ¶
func (a *VisualSampleEntryBox) AddChild(b Box)
AddChild - add a child box (avcC normally, but clap and pasp could be part of visual entry)
func (*VisualSampleEntryBox) Dump ¶
func (a *VisualSampleEntryBox) Dump(w io.Writer, indent, indentStep string) error
func (*VisualSampleEntryBox) Encode ¶
func (a *VisualSampleEntryBox) Encode(w io.Writer) error
Encode - write box to w
func (*VisualSampleEntryBox) Size ¶
func (a *VisualSampleEntryBox) Size() uint64
Size - return calculated size
func (*VisualSampleEntryBox) Type ¶
func (a *VisualSampleEntryBox) Type() string
Type - return box type
type VlabBox ¶
type VlabBox struct {
SourceLabel string
}
VlabBox - WebVTTSourceLabelBox (vlab)
type VmhdBox ¶
VmhdBox - Video Media Header Box (vhmd - mandatory for video tracks)
Contained in : Media Information Box (minf)
type VsidBox ¶
type VsidBox struct {
SourceID uint32
}
VsidBox - CueSourceIDBox (iden)
type VttCBox ¶
type VttCBox struct {
Config string
}
VttCBox - WebVTTConfigurationBox (vttC)
type VttaBox ¶
type VttaBox struct {
CueAdditionalText string
}
VttaBox - VTTAdditionalTextBox (vtta) (corresponds to NOTE in WebVTT)
type VttcBox ¶
type VttcBox struct {
Vsid *VsidBox
Iden *IdenBox
Ctim *CtimBox
Sttg *SttgBox
Payl *PaylBox
Children []Box
}
func (*VttcBox) GetChildren ¶
GetChildren - list of child boxes
type VtteBox ¶
type VtteBox struct {
}
VtteBox - VTTEmptyBox (vtte)
type WvttBox ¶
type WvttBox struct {
VttC *VttCBox
Vlab *VlabBox
Btrt *BtrtBox
Children []Box
DataReferenceIndex uint16
}
WvttBox - WVTTSampleEntry (wvtt) Extends PlainTextSampleEntry which extends SampleEntry
Source Files
¶
- aac.go
- audiosamplentry.go
- avcc.go
- box.go
- btrt.go
- container.go
- ctts.go
- dinf.go
- doc.go
- dref.go
- edts.go
- elng.go
- elst.go
- emsg.go
- esds.go
- file.go
- fragment.go
- free.go
- ftyp.go
- hdlr.go
- initsegment.go
- mdat.go
- mdhd.go
- mdia.go
- mediasegment.go
- mfhd.go
- minf.go
- moof.go
- moov.go
- mvex.go
- mvhd.go
- nmhd.go
- prft.go
- sample.go
- sampleflags.go
- senc.go
- sidx.go
- slicereader.go
- slicewriter.go
- smhd.go
- stbl.go
- stco.go
- sthd.go
- stpp.go
- stsc.go
- stsd.go
- stss.go
- stsz.go
- stts.go
- styp.go
- subs.go
- test_helpers.go
- tfdt.go
- tfhd.go
- tkhd.go
- traf.go
- trak.go
- trex.go
- trun.go
- unknown.go
- url.go
- uuid.go
- visualsampleentry.go
- vmhd.go
- wvtt.go