Documentation
¶
Index ¶
- Constants
- Variables
- func DecryptBytesCTR(data []byte, key []byte, iv []byte) ([]byte, error)
- func DecryptSampleCenc(sample []byte, key []byte, iv []byte, subSamplePatterns []SubSamplePattern) ([]byte, error)
- func EncodeContainer(c ContainerBox, w io.Writer) error
- func EncodeHeader(b Box, w io.Writer) error
- func EncodeHeaderSW(b Box, sw mp4ff.SliceWriter) error
- func EncodeHeaderWithSize(boxType string, boxSize uint64, largeSize bool, w io.Writer) error
- func EncodeHeaderWithSizeSW(boxType string, boxSize uint64, largeSize bool, sw mp4ff.SliceWriter) error
- type AlstSampleGroupEntry
- type Box
- func DecodeBox(startPos uint64, r io.Reader) (Box, error)
- func DecodeBoxSR(startPos uint64, sr mp4ff.SliceReader) (Box, error)
- func DecodeClapSR(hdr BoxHeader, startPos uint64, sr mp4ff.SliceReader) (Box, error)
- func DecodeContainerChildren(hdr BoxHeader, startPos, endPos uint64, r io.Reader) ([]Box, error)
- func DecodeContainerChildrenSR(hdr BoxHeader, startPos, endPos uint64, sr mp4ff.SliceReader) ([]Box, error)
- func DecodeMdat(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeMoof(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeMoofSR(hdr BoxHeader, startPos uint64, sr mp4ff.SliceReader) (Box, error)
- func DecodeSenc(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeSencSR(hdr BoxHeader, startPos uint64, sr mp4ff.SliceReader) (Box, error)
- func DecodeTfdtSR(hdr BoxHeader, startPos uint64, sr mp4ff.SliceReader) (Box, error)
- func DecodeTfhd(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeTfhdSR(hdr BoxHeader, startPos uint64, sr mp4ff.SliceReader) (Box, error)
- func DecodeTrafSR(hdr BoxHeader, startPos uint64, sr mp4ff.SliceReader) (Box, error)
- func DecodeTrunSR(hdr BoxHeader, startPos uint64, sr mp4ff.SliceReader) (Box, error)
- func DecodeUnknown(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)
- func DecodeUnknownSR(hdr BoxHeader, startPos uint64, sr mp4ff.SliceReader) (Box, error)
- type BoxDecoder
- type BoxDecoderSR
- type BoxHeader
- type BoxStructure
- type BtrtBox
- type CTooBox
- type ClapBox
- type Co64Box
- type ContainerBox
- type CttsBox
- type DataBox
- type DataRange
- type DecFileMode
- type EncFragFileMode
- type EncOptimize
- type File
- type Fixed16
- type Fixed32
- type Fragment
- func (f *Fragment) AddChild(b Box)
- func (f *Fragment) AddFullSample(s FullSample)
- func (f *Fragment) AddSample(s Sample, baseMediaDecodeTime uint64)
- func (f *Fragment) AddSamples(ss []Sample, baseMediaDecodeTime uint64)
- func (f *Fragment) Encode(w io.Writer) error
- func (f *Fragment) GetChildren() []Box
- func (f *Fragment) GetFullSamples() ([]FullSample, error)
- func (f *Fragment) SetTrunDataOffsets()
- func (f *Fragment) Size() uint64
- type FullSample
- type HdlrBox
- type IlstBox
- type Informer
- type InitializationVector
- type MdatBox
- func (m *MdatBox) AddSampleData(s []byte)
- func (m *MdatBox) AddSampleDataPart(s []byte)
- func (m *MdatBox) DataLength() uint64
- func (m *MdatBox) Encode(w io.Writer) error
- func (m *MdatBox) HeaderSize() uint64
- func (m *MdatBox) IsLazy() bool
- func (m *MdatBox) PayloadAbsoluteOffset() uint64
- func (m *MdatBox) Size() uint64
- func (m *MdatBox) Type() string
- type MdhdBox
- type MediaSegment
- type MetaBox
- type MfhdBox
- type MoofBox
- type NmhdBox
- type PiffData
- type RapSampleGroupEntry
- type RollSampleGroupEntry
- type SaioBox
- type SaizBox
- type Sample
- type SampleGroupEntry
- func DecodeAlstSampleGroupEntry(name string, length uint32, sr mp4ff.SliceReader) (SampleGroupEntry, error)
- func DecodeRapSampleGroupEntry(name string, length uint32, sr mp4ff.SliceReader) (SampleGroupEntry, error)
- func DecodeSeigSampleGroupEntry(name string, length uint32, sr mp4ff.SliceReader) (SampleGroupEntry, error)
- func DecodeUnknownSampleGroupEntry(name string, length uint32, sr mp4ff.SliceReader) (SampleGroupEntry, error)
- type SampleGroupEntryDecoder
- type SampleInterval
- type SeigSampleGroupEntry
- type SencBox
- func (s *SencBox) AddSample(sample SencSample) error
- func (s *SencBox) Encode(w io.Writer) error
- func (s *SencBox) EncodeSW(sw mp4ff.SliceWriter) error
- func (s *SencBox) GetPerSampleIVSize() int
- func (s *SencBox) ParseReadBox(perSampleIVSize byte) error
- func (s *SencBox) Size() uint64
- func (s *SencBox) Type() string
- type SencSample
- type SgpdBox
- type SthdBox
- type StssBox
- type SubSamplePattern
- type TfdtBox
- type TfhdBox
- func (t *TfhdBox) DefaultBaseIfMoof() bool
- func (t *TfhdBox) DurationIsEmpty() bool
- func (t *TfhdBox) Encode(w io.Writer) error
- func (t *TfhdBox) EncodeSW(sw mp4ff.SliceWriter) 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 TrafBox
- func (t *TrafBox) AddChild(b Box) error
- func (t *TrafBox) ContainsSencBox() (ok, parsed bool)
- func (t *TrafBox) Encode(w io.Writer) error
- func (t *TrafBox) GetChildren() []Box
- func (t *TrafBox) OptimizeTfhdTrun() error
- func (t *TrafBox) ParseReadSenc(defaultIVSize byte, moofStartPos uint64) error
- func (t *TrafBox) RemoveEncryptionBoxes() uint64
- func (t *TrafBox) Size() uint64
- func (t *TrafBox) Type() string
- type TrunBox
- func (t *TrunBox) AddFullSample(s *FullSample)
- func (t *TrunBox) AddSample(s Sample)
- func (t *TrunBox) AddSampleDefaultValues(tfhd *TfhdBox) (totalDur uint64)
- func (t *TrunBox) AddSamples(s []Sample)
- func (t *TrunBox) Duration(defaultSampleDuration uint32) uint64
- func (t *TrunBox) Encode(w io.Writer) error
- func (t *TrunBox) EncodeSW(sw mp4ff.SliceWriter) error
- func (t *TrunBox) FirstSampleFlags() (flags uint32, present bool)
- func (t *TrunBox) GetFullSamples(offsetInMdat uint32, baseDecodeTime uint64, mdat *MdatBox) []FullSample
- func (t *TrunBox) GetSampleInterval(startSampleNr, endSampleNr uint32, baseDecodeTime uint64, mdat *MdatBox, ...) (SampleInterval, error)
- func (t *TrunBox) GetSampleRange(startSampleNr, endSampleNr uint32) []Sample
- func (t *TrunBox) GetSamples() []Sample
- func (t *TrunBox) HasDataOffset() bool
- func (t *TrunBox) HasFirstSampleFlags() bool
- func (t *TrunBox) HasSampleCompositionTimeOffset() bool
- func (t *TrunBox) HasSampleDuration() bool
- func (t *TrunBox) HasSampleFlags() bool
- func (t *TrunBox) HasSampleSize() bool
- func (t *TrunBox) RemoveFirstSampleFlags()
- func (t *TrunBox) SampleCount() uint32
- func (t *TrunBox) SetFirstSampleFlags(flags uint32)
- func (t *TrunBox) Size() uint64
- func (t *TrunBox) SizeOfData() (totalSize uint64)
- func (t *TrunBox) Type() string
- type UUID
- type UnknownBox
- type UnknownSampleGroupEntry
- type VmhdBox
Constants ¶
const ( // EncModeSegment - only encode boxes that are part of Init and MediaSegments EncModeSegment = EncFragFileMode(0) // EncModeBoxTree - encode all boxes in file tree EncModeBoxTree = EncFragFileMode(1) )
const ( // OptimizeNone - no optimization OptimizeNone = EncOptimize(0) // OptimizeTrun - optimize trun box by moving default values to tfhd OptimizeTrun = EncOptimize(1 << 0) )
const ( UUIDFairPlay = "94CE86FB-07FF-4F43-ADB8-93D2FA968CA2" UUIDPlayReady = "9a04f079-9840-4286-ab92-e65be0885f95" UUIDWidevine = "edef8ba9-79d6-4ace-a3c8-27dcd51d21ed" UUID_VCAS = "9a27dd82-fde2-4725-8cbc-4234aa06ec09" )
UUIDs for different DRM systems
const DefaultTrakID = 1
DefaultTrakID - trakID used when generating new fragmented content
const NonSyncSampleFlags uint32 = 0x00010000
NonSyncSampleFlags - flags for non-sync sample
const SyncSampleFlags uint32 = 0x02000000
SyncSampleFlags - flags for I-frame or other sync sample
const TrunDataOffsetPresentFlag uint32 = 0x01
const TrunFirstSampleFlagsPresentFlag uint32 = 0x04
const TrunSampleCompositionTimeOffsetPresentFlag uint32 = 0x800
const TrunSampleDurationPresentFlag uint32 = 0x100
const TrunSampleFlagsPresentFlag uint32 = 0x400
const TrunSampleSizePresentFlag uint32 = 0x200
const UseSubSampleEncryption = 0x2
UseSubSampleEncryption - flag for subsample encryption
Variables ¶
var AC3SampleRates = []int{48000, 44100, 32000}
AC3SampleRates - Sample rates as defined in ETSI TS 102 366 V1.4.1 (2017) section 4.4.1.3 Signaled in fscod - Sample rate code - 2 bits
Functions ¶
func DecryptBytesCTR ¶
DecryptBytesCTR - decrypt or encrypt sample using CTR mode, provided key, iv and sumsamplePattern
func DecryptSampleCenc ¶
func DecryptSampleCenc(sample []byte, key []byte, iv []byte, subSamplePatterns []SubSamplePattern) ([]byte, error)
DecryptSampleCenc - decrypt cenc-mode encrypted sample
func EncodeContainer ¶
func EncodeContainer(c ContainerBox, w io.Writer) error
EncodeContainer - marshal container c to w
func EncodeHeader ¶
EncodeHeader - encode a box header to a writer
func EncodeHeaderSW ¶
func EncodeHeaderSW(b Box, sw mp4ff.SliceWriter) error
EncodeHeaderSW - encode a box header to a SliceWriter
func EncodeHeaderWithSize ¶
EncodeHeaderWithSize - encode a box header to a writer and allow for largeSize
func EncodeHeaderWithSizeSW ¶
func EncodeHeaderWithSizeSW(boxType string, boxSize uint64, largeSize bool, sw mp4ff.SliceWriter) error
EncodeHeaderWithSize - encode a box header to a writer and allow for largeSize
Types ¶
type AlstSampleGroupEntry ¶
type AlstSampleGroupEntry struct {
RollCount uint16
FirstOutputSample uint16
SampleOffset []uint32
NumOutputSamples []uint16
NumTotalSamples []uint16
}
AlstSampleGroupEntry - Alternative Startup Entry "alst"
ISO/IEC 14496-12 Ed. 6 2020 Section 10.3 - AlternativeStartupEntry
func (*AlstSampleGroupEntry) Encode ¶
func (s *AlstSampleGroupEntry) Encode(sw mp4ff.SliceWriter)
Encode SampleGroupEntry to SliceWriter
func (*AlstSampleGroupEntry) Size ¶
func (s *AlstSampleGroupEntry) Size() uint64
Size of sample group entry
func (*AlstSampleGroupEntry) Type ¶
func (s *AlstSampleGroupEntry) Type() string
Type - GroupingType SampleGroupEntry (uint32 according to spec)
type Box ¶
type Box interface {
// Type of box, normally 4 asccii characters, but is uint32 according to spec
Type() string
// Size of box including header and all children if any
Size() uint64
// Encode box to writer
Encode(w io.Writer) error
}
Box is the general interface to any ISOBMFF box or similar
func DecodeBoxSR ¶
func DecodeBoxSR(startPos uint64, sr mp4ff.SliceReader) (Box, error)
DecodeBoxSR - decode a box from SliceReader
func DecodeClapSR ¶
DecodeClapSR - box-specific decode
func DecodeContainerChildren ¶
DecodeContainerChildren decodes a container box
func DecodeContainerChildrenSR ¶
func DecodeContainerChildrenSR(hdr BoxHeader, startPos, endPos uint64, sr mp4ff.SliceReader) ([]Box, error)
DecodeContainerChildren decodes a container box
func DecodeMdat ¶
DecodeMdat - box-specific decode
func DecodeMoof ¶
DecodeMoof - box-specific decode
func DecodeMoofSR ¶
DecodeMoofSR - box-specific decode
func DecodeSenc ¶
DecodeSenc - box-specific decode
func DecodeSencSR ¶
DecodeSencSR - box-specific decode
func DecodeTfdtSR ¶
DecodeTfdtSR - box-specific decode
func DecodeTfhd ¶
DecodeTfhd - box-specific decode
func DecodeTfhdSR ¶
DecodeTfhdSR - box-specific decode
func DecodeTrafSR ¶
DecodeTrafSR - box-specific decode
func DecodeTrunSR ¶
DecodeTrun - box-specific decode
func DecodeUnknown ¶
DecodeUnknown - decode an unknown box
func DecodeUnknownSR ¶
DecodeUnknown - decode an unknown box
type BoxDecoder ¶
BoxDecoder is function signature of the Box Decode method
type BoxDecoderSR ¶
BoxDecoderSR is function signature of the Box DecodeSR method
type BoxHeader ¶
BoxHeader - 8 or 16 bytes depending on size
func DecodeHeader ¶
DecodeHeader decodes a box header (size + box type + possiible largeSize)
func DecodeHeaderSR ¶
func DecodeHeaderSR(sr mp4ff.SliceReader) (BoxHeader, error)
DecodeHeaderSR - decode a box header (size + box type + possible largeSize) from sr
type BoxStructure ¶
BoxStructure represent a box or similar entity such as a Segment
type BtrtBox ¶
BtrtBox - BitRateBox - ISO/IEC 14496-12 Section 8.5.2.2
type CTooBox ¶
type CTooBox struct {
Children []Box
}
CTooBox - ©too box defines the ffmpeg encoding tool information
type ClapBox ¶
type ClapBox struct {
CleanApertureWidthN uint32
CleanApertureWidthD uint32
CleanApertureHeightN uint32
CleanApertureHeightD uint32
HorizOffN uint32
HorizOffD uint32
VertOffN uint32
VertOffD uint32
}
ClapBox - Clean Aperture Box, ISO/IEC 14496-12 2020 Sec. 12.1.4
type Co64Box ¶
Co64Box - Chunk Large Offset Box
Contained in : Sample Table box (stbl)
64-bit version of StcoBox
type ContainerBox ¶
type ContainerBox interface {
Encode(w io.Writer) error
GetChildren() []Box
Size() uint64
Type() string
}
ContainerBox is interface for ContainerBoxes
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)
type DataBox ¶
type DataBox struct {
Data []byte
}
DataBox - data box used by ffmpeg for providing information.
type DecFileMode ¶
type DecFileMode byte
DecFileMode - mode for decoding file
const ( // DecModeNormal - read Mdat data into memory during file decoding. DecModeNormal DecFileMode = iota // DecModeLazyMdat - do not read mdat data into memory. // Thus, decode process requires less memory and faster. DecModeLazyMdat )
type File ¶
type File struct {
Segments []*MediaSegment // Media segments
// contains filtered or unexported fields
}
func (*File) AddMediaSegment ¶
func (f *File) AddMediaSegment(m *MediaSegment)
AddMediaSegment - add a mediasegment to file f
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 {
Moof *MoofBox
Mdat *MdatBox
Children []Box // All top-level boxes in order
EncOptimize EncOptimize // Bit field with optimizations being done at encoding
// contains filtered or unexported fields
}
Fragment - MP4 Fragment ([prft] + moof + mdat)
func (*Fragment) AddFullSample ¶
func (f *Fragment) AddFullSample(s FullSample)
AddFullSample - add a full sample to the first (and only) trun of a track AddFullSampleToTrack is the more general function
func (*Fragment) AddSample ¶
AddSample - add a sample to the first (and only) trun of a track AddSampleToTrack is the more general function
func (*Fragment) AddSamples ¶
AddSamples - add a slice of Sample to the first (and only) trun of a track
func (*Fragment) GetChildren ¶
GetChildren - return children boxes
func (*Fragment) GetFullSamples ¶
func (f *Fragment) GetFullSamples() ([]FullSample, error)
GetFullSamples - Get full samples including media and accumulated time
func (*Fragment) SetTrunDataOffsets ¶
func (f *Fragment) SetTrunDataOffsets()
SetTrunDataOffsets - set DataOffset in trun depending on size and writeOrder
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
type HdlrBox ¶
type HdlrBox struct {
Version byte
Flags uint32
PreDefined uint32
HandlerType string
Name string // Null-terminated UTF-8 string according to ISO/IEC 14496-12 Sec. 8.4.3.3
LacksNullTermination bool // This should be true, but we allow false as well
}
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). clcp (Closed Captions (QuickTime))
type IlstBox ¶
type IlstBox struct {
Children []Box
}
IlstBox - iTunes Metadata Item List Atom (ilst) See https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/Metadata/Metadata.html
type Informer ¶
type Informer interface {
// Info - write details via Info method
// spedificBoxLevels is a comma-separated list box:level or all:level where level >= 0.
// Higher levels give more details. 0 is default
// indent is indent at this box level.
// indentStep is how much to indent at each level
Info(w io.Writer, specificBoxLevels, indent, indentStep string) error
}
Informer - write box, segment or file details
type MdatBox ¶
type MdatBox struct {
StartPos uint64
Data []byte
DataParts [][]byte
LargeSize bool
// contains filtered or unexported fields
}
MdatBox - Media Data Box (mdat) The mdat box contains media chunks/samples. DataParts is to be able to gather output data without new allocations
func (*MdatBox) AddSampleData ¶
AddSampleData - a sample data to an mdat box
func (*MdatBox) AddSampleDataPart ¶
AddSampleDataPart - add a data part (for output)
func (*MdatBox) DataLength ¶
DataLength - length of data stored in box either as one or multiple parts
func (*MdatBox) Encode ¶
Encode - write box to w. If m.lazyDataSize > 0, the mdat data needs to be written separately
func (*MdatBox) HeaderSize ¶
HeaderSize - 8 or 16 (bytes) depending o whether largeSize is used
func (*MdatBox) PayloadAbsoluteOffset ¶
PayloadAbsoluteOffset - position of mdat payload start (works after header)
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) EncodeSW ¶
func (m *MdhdBox) EncodeSW(sw mp4ff.SliceWriter) error
EncodeSW - box-specific encode to slicewriter
func (*MdhdBox) GetLanguage ¶
GetLanguage - Get three-byte language string
func (*MdhdBox) SetLanguage ¶
SetLanguage - Set three-byte language string
type MediaSegment ¶
type MediaSegment struct {
EncOptimize EncOptimize
Fragments []*Fragment
}
MediaSegment - MP4 Media Segment
func NewMediaSegment ¶
func NewMediaSegment() *MediaSegment
NewMediaSegment - create empty MediaSegment with CMAF styp box
func (*MediaSegment) AddFragment ¶
func (s *MediaSegment) AddFragment(f *Fragment)
AddFragment - Add a fragment to a MediaSegment
func (*MediaSegment) Encode ¶
func (s *MediaSegment) Encode(w io.Writer) error
Encode - Write MediaSegment via writer
func (*MediaSegment) LastFragment ¶
func (s *MediaSegment) LastFragment() *Fragment
LastFragment - Currently last fragment
func (*MediaSegment) Size ¶
func (s *MediaSegment) Size() uint64
Size - return size of media segment
type MfhdBox ¶
MfhdBox - Media Fragment Header Box (mfhd)
Contained in : Movie Fragment box (moof))
type MoofBox ¶
type MoofBox struct {
Children []Box
//Pssh *PsshBox
//Psshs []*PsshBox
StartPos uint64
Traf *TrafBox // The first traf child box
Trafs []*TrafBox
}
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 NmhdBox ¶
NmhdBox - Null Media Header Box (nmhd - often used instead of sthd for subtitle tracks)
type RapSampleGroupEntry ¶
RapSampleGroupEntry - Random Access Point "rap "
ISO/IEC 14496-12 Ed. 6 2020 Section 10.4 - VisualRandomAccessEntry
func (*RapSampleGroupEntry) Encode ¶
func (s *RapSampleGroupEntry) Encode(sw mp4ff.SliceWriter)
Encode SampleGroupEntry to SliceWriter
func (*RapSampleGroupEntry) Size ¶
func (s *RapSampleGroupEntry) Size() uint64
Size of sample group entry
func (*RapSampleGroupEntry) Type ¶
func (s *RapSampleGroupEntry) Type() string
Type - GroupingType SampleGroupEntry (uint32 according to spec)
type RollSampleGroupEntry ¶
type RollSampleGroupEntry struct {
RollDistance int16
}
RollSampleGroupEntry - Gradual Decoding Refresh "roll"
ISO/IEC 14496-12 Ed. 6 2020 Section 10.1
VisualRollRecoveryEntry / AudioRollRecoveryEntry / AudioPreRollEntry
func (*RollSampleGroupEntry) Encode ¶
func (s *RollSampleGroupEntry) Encode(sw mp4ff.SliceWriter)
Encode SampleGroupEntry to SliceWriter
func (*RollSampleGroupEntry) Size ¶
func (s *RollSampleGroupEntry) Size() uint64
Size of sample group entry
func (*RollSampleGroupEntry) Type ¶
func (s *RollSampleGroupEntry) Type() string
Type - GroupingType SampleGroupEntry (uint32 according to spec)
type SaioBox ¶
type SaioBox struct {
Version byte
Flags uint32
AuxInfoType string // Used for Common Encryption Scheme (4-bytes uint32 according to spec)
AuxInfoTypeParameter uint32
Offset []int64
}
SaioBox - Sample Auxiliary Information Offsets Box (saiz) (in stbl or traf box)
type SaizBox ¶
type SaizBox struct {
Version byte
Flags uint32
AuxInfoType string // Used for Common Encryption Scheme (4-bytes uint32 according to spec)
AuxInfoTypeParameter uint32
SampleCount uint32
SampleInfo []byte
DefaultSampleInfoSize byte
}
SaizBox - Sample Auxiliary Information Sizes Box (saiz) (in stbl or traf box)
type Sample ¶
type Sample struct {
Flags uint32 // interpreted as SampleFlags
Dur uint32 // Sample duration in mdhd timescale
Size uint32 // Size of sample data
CompositionTimeOffset int32 // Signed composition time offset
}
Sample - sample as used in trun box (mdhd timescale)
type SampleGroupEntry ¶
type SampleGroupEntry interface {
// Type - GroupingType SampleGroupEntry (uint32 according to spec)
Type() string // actually
// Size of SampleGroup Entry
Size() uint64
// Encode SampleGroupEntry to SliceWriter
Encode(sw mp4ff.SliceWriter)
}
SampleGroupEntry - like a box, but size and type are not in a header
func DecodeAlstSampleGroupEntry ¶
func DecodeAlstSampleGroupEntry(name string, length uint32, sr mp4ff.SliceReader) (SampleGroupEntry, error)
DecodeAlstSampleGroupEntry - decode ALST Sample Group Entry
func DecodeRapSampleGroupEntry ¶
func DecodeRapSampleGroupEntry(name string, length uint32, sr mp4ff.SliceReader) (SampleGroupEntry, error)
DecodeRapSampleGroupEntry - decode Rap Sample Sample Group Entry
func DecodeSeigSampleGroupEntry ¶
func DecodeSeigSampleGroupEntry(name string, length uint32, sr mp4ff.SliceReader) (SampleGroupEntry, error)
DecodeSeigSampleGroupEntry - decode Common Encryption Sample Group Entry
func DecodeUnknownSampleGroupEntry ¶
func DecodeUnknownSampleGroupEntry(name string, length uint32, sr mp4ff.SliceReader) (SampleGroupEntry, error)
DecodeUnknownSampleGroupEntry - decode an unknown sample group entry
type SampleGroupEntryDecoder ¶
type SampleGroupEntryDecoder func(name string, length uint32, sr mp4ff.SliceReader) (SampleGroupEntry, error)
SampleGroupEntryDecoder is function signature of the SampleGroupEntry Decode method
type SampleInterval ¶
type SampleInterval struct {
FirstDecodeTime uint64
Samples []Sample
OffsetInMdat uint32 // Offset relative start of mdat box
Size uint32 // total size of all samples in interval
Data []byte // If set, should be relevant mdat range
}
SampleInterval - an interval of samples including reference to or concatenated binary media data
type SeigSampleGroupEntry ¶
type SeigSampleGroupEntry struct {
CryptByteBlock byte
SkipByteBlock byte
IsProtected byte
PerSampleIVSize byte
KID UUID
// ConstantIVSize byte given by len(ConstantIV)
ConstantIV []byte
}
SeigSampleGroupEntry - CencSampleEncryptionInformationGroupEntry as defined in CEF ISO/IEC 23001-7 3rd edition 2016
func (*SeigSampleGroupEntry) ConstantIVSize ¶
func (s *SeigSampleGroupEntry) ConstantIVSize() byte
ConstantIVSize - non-zero if protected and perSampleIVSize == 0
func (*SeigSampleGroupEntry) Encode ¶
func (s *SeigSampleGroupEntry) Encode(sw mp4ff.SliceWriter)
Encode SampleGroupEntry to SliceWriter
func (*SeigSampleGroupEntry) Size ¶
func (s *SeigSampleGroupEntry) Size() uint64
Size of SampleGroup Entry
func (*SeigSampleGroupEntry) Type ¶
func (s *SeigSampleGroupEntry) Type() string
Type - GroupingType SampleGroupEntry (uint32 according to spec)
type SencBox ¶
type SencBox struct {
Version byte
Flags uint32
SampleCount uint32
StartPos uint64
IVs []InitializationVector // 8 or 16 bytes if present
SubSamples [][]SubSamplePattern
// contains filtered or unexported fields
}
SencBox - Sample Encryption Box (senc) (in trak or traf box) Should only be decoded after saio and saiz provide relevant offset and sizes Here we make a two-step decode, with first step reading, and other parsing. See ISO/IEC 23001-7 Section 7.2 and CMAF specification 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) EncodeSW ¶
func (s *SencBox) EncodeSW(sw mp4ff.SliceWriter) error
EncodeSW - box-specific encode to slicewriter
func (*SencBox) GetPerSampleIVSize ¶
GetPerSampleIVSize - return perSampleIVSize
func (*SencBox) ParseReadBox ¶
ParseReadBox - second phase when perSampleIVSize should be known from tenc or sgpd boxes if perSampleIVSize is 0, we try to find the appropriate error given data length
type SencSample ¶
type SencSample struct {
IV InitializationVector // 0,8,16 byte length
SubSamples []SubSamplePattern
}
SencSample - sample in SencBox
type SgpdBox ¶
type SgpdBox struct {
Version byte
Flags uint32
GroupingType string // uint32, but takes values such as seig
DefaultLength uint32
DefaultGroupDescriptionIndex uint32
DescriptionLengths []uint32
SampleGroupEntries []SampleGroupEntry
}
SgpdBox - Sample Group Description Box, ISO/IEC 14496-12 6'th edition 2020 Section 8.9.3 Version 0 is deprecated
type StssBox ¶
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.
type SubSamplePattern ¶
SubSamplePattern - pattern of subsample encryption
type TfdtBox ¶
TfdtBox - Track Fragment Decode Time (tfdt)
Contained in : Track Fragment box (traf)
func (*TfdtBox) EncodeSW ¶
func (t *TfdtBox) EncodeSW(sw mp4ff.SliceWriter) error
EncodeSW - box-specific encode to slicewriter
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) EncodeSW ¶
func (t *TfhdBox) EncodeSW(sw mp4ff.SliceWriter) error
EncodeSW - box-specific encode to slicewriter
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 TrafBox ¶
type TrafBox struct {
Children []Box
Saio *SaioBox
Saiz *SaizBox
//Sbgp *SbgpBox
Senc *SencBox
Sgpd *SgpdBox
Tfdt *TfdtBox
Tfhd *TfhdBox
Trun *TrunBox // The first TrunBox
Truns []*TrunBox
}
TrafBox - Track Fragment Box (traf)
Contained in : Movie Fragment Box (moof)
func (*TrafBox) ContainsSencBox ¶
ContainsSencBox - is there a senc box in traf and is it parsed If not parsed, call ParseReadSenc to parse it
func (*TrafBox) GetChildren ¶
GetChildren - list of child boxes
func (*TrafBox) OptimizeTfhdTrun ¶
OptimizeTfhdTrun - optimize trun by default values in tfhd box Only look at first trun, even if there is more than one Don't optimize again, if already done so that no data is present
func (*TrafBox) ParseReadSenc ¶
func (*TrafBox) RemoveEncryptionBoxes ¶
RemoveEncryptionBoxes - remove encryption boxes and return number of bytes removed
type TrunBox ¶
type TrunBox struct {
Version byte
Flags uint32
DataOffset int32
Samples []Sample
// contains filtered or unexported fields
}
TrunBox - Track Fragment Run Box (trun)
Contained in : Track Fragmnet Box (traf)
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 Return total duration
func (*TrunBox) AddSamples ¶
AddSamples - add a a slice of Sample
func (*TrunBox) Duration ¶
Duration - calculate total duration of all samples given defaultSampleDuration
func (*TrunBox) EncodeSW ¶
func (t *TrunBox) EncodeSW(sw mp4ff.SliceWriter) error
EncodeSW - box-specific encode to slicewriter
func (*TrunBox) FirstSampleFlags ¶
FirstSampleFlags - return firstSampleFlags and indicator if present
func (*TrunBox) GetFullSamples ¶
func (t *TrunBox) GetFullSamples(offsetInMdat uint32, baseDecodeTime uint64, mdat *MdatBox) []FullSample
GetFullSamples - get all sample data including accumulated time and binary media data offsetInMdat is offset in mdat data (data normally starts 8 or 16 bytes after start of mdat box) baseDecodeTime is decodeTime in tfdt in track timescale (timescale in mfhd) To fill missing individual values from tfhd and trex defaults, call trun.AddSampleDefaultValues() before this call
func (*TrunBox) GetSampleInterval ¶
func (t *TrunBox) GetSampleInterval(startSampleNr, endSampleNr uint32, baseDecodeTime uint64, mdat *MdatBox, offsetInMdat uint32) (SampleInterval, error)
GetSampleInterval - get sample interval [startSampleNr, endSampleNr] (1-based and inclusive) This includes mdat data (if not lazy), in which case only offsetInMdat is given. baseDecodeTime is decodeTime in tfdt in track timescale (timescale from mfhd). To fill missing individual values from tfhd and trex defaults, call AddSampleDefaultValues() before this call.
func (*TrunBox) GetSampleRange ¶
GetSampleRange - get a one-based range of samples To fill missing individual values from tfhd and trex defaults, call AddSampleDefaultValues() before this call
func (*TrunBox) GetSamples ¶
GetSamples - get all trun sample data To fill missing individual values from tfhd and trex defaults, call AddSampleDefaultValues() before this call
func (*TrunBox) HasDataOffset ¶
HasDataOffset - interpreted dataOffsetPresent flag
func (*TrunBox) HasFirstSampleFlags ¶
HasFirstSampleFlags - interpreted firstSampleFlagsPresent flag
func (*TrunBox) HasSampleCompositionTimeOffset ¶
HasSampleCompositionTimeOffset - 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) RemoveFirstSampleFlags ¶
func (t *TrunBox) RemoveFirstSampleFlags()
RemoveFirstSampleFlags - remove firstSampleFlags and its indicator
func (*TrunBox) SampleCount ¶
SampleCount - return how many samples are defined
func (*TrunBox) SetFirstSampleFlags ¶
SetFirstSampleFlags - set firstSampleFlags and bit indicating its presence
func (*TrunBox) SizeOfData ¶
SizeOfData - size of mediasamples in bytes
type UnknownBox ¶
type UnknownBox struct {
// contains filtered or unexported fields
}
UnknownBox - box that we don't know how to parse
func (*UnknownBox) EncodeSW ¶
func (b *UnknownBox) EncodeSW(sw mp4ff.SliceWriter) error
EncodeSW - box-specific encode to slicewriter
type UnknownSampleGroupEntry ¶
UnknownSampleGroupEntry - unknown or not implemented SampleGroupEntry
func (*UnknownSampleGroupEntry) Encode ¶
func (s *UnknownSampleGroupEntry) Encode(sw mp4ff.SliceWriter)
Encode SampleGroupEntry to SliceWriter
func (*UnknownSampleGroupEntry) Size ¶
func (s *UnknownSampleGroupEntry) Size() uint64
Size of SampleGroup Entry
func (*UnknownSampleGroupEntry) Type ¶
func (s *UnknownSampleGroupEntry) Type() string
Type - GroupingType SampleGroupEntry (uint32 according to spec)