mp4

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: MIT, MIT Imports: 20 Imported by: 81

Documentation ¶

Overview ¶

Package mp4 is a 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.

Structure and usage ¶

The top level structure for both non-fragmented and fragmented mp4 files is File.

In a progressive (non-fragmented) File, the top-level attributes "Ftyp", "Moov", and "Mdat" point to the corresponding top level boxes.

A fragmented File can be more or less complete, like a single init segment, one or more media segments, or a combination of both, like a CMAF track which renders into a playable one-track asset. It can also have multiple tracks. For fragmented files, the following high-level attributes are used:

  • Init is an *mp4.InitSegment and contains a ftyp and a moov box and provides the general metadata for a fragmented file, track definitions including time scale and sample descriptors. It corresponds to a CMAF header. It can also contain one or more `sidx` boxes.
  • Segments is a slice of mp4.MediaSegment which start with an optional mp4.StypBox, possibly one or more mp4.SidxBox and then one or more mp4.Fragment.
  • mp4.Fragment is a mp4 fragment with exactly one mp4.MoofBox followed by a mp4.MdatBox where the latter contains the media data. It should have one or more mp4.TrunBox containing the metadata for the samples. The fragment can start with one or more mp4.EmsgBox.

It should be noted that it is sometimes hard to decide what should belong to a Segment or Fragment.

All child boxes of container boxes such as mp4.MoofBox are listed in the Children attribute, but the most prominent child boxes have direct links with names which makes it possible to write a path such as

fragment.Moof.Traf.Trun

to access the (single or first) mp4.TrunBox in a fragment inside the (single or first) mp4.TrafBox of a fragment.

There are corresponding structures with a plural form for accessing later boxes of the same type, e.g.

fragment.Moof.Trafs[1].Trun[1]

to get the second mp4.TrunBox of the second mp4.TrafBox (provided that they exist). Care must be taken to assert that none of the intermediate pointers are nil to avoid panic.

Creating new fragmented files ¶

A typical use case is to generate a fragmented file consisting of an init segment followed by a series of media segments.

The first step is to create the init segment. This is done in three steps as can be seen in examples/initcreator:

init := mp4.CreateEmptyInit()
init.AddEmptyTrack(timescale, mediatype, language)
init.Moov.Trak.SetHEVCDescriptor("hvc1", vpsNALUs, spsNALUs, ppsNALUs)

Here the third step fills in codec-specific parameters into the sample descriptor of the single track.

The second step is to start producing media segments. They should use the timescale that was set when creating the init segment. Generally, that timescale should be chosen so that the sample durations have exact values without rounding errors, e.g. 48000 for 48kHz audio.

A media segment contains one or more fragments. If all samples are available before the segment is created, one can use a single fragment in each segment. Example code for this can be found in examples/segmenter. For low-latency MPEG-DASH generation, short-duration fragments are added to the segment as the corresponding media samples become available.

A simple, but not optimal, way of creating a media segment is to first create a slice of mp4.FullSample with the data needed.

The mp4.Sample part is what will be written into the mp4.TrunBox. Once a number of such full samples are available, they can be added to a media segment like

seg := mp4.NewMediaSegment()
frag := mp4.CreateFragment(uint32(segNr), mp4.DefaultTrakID)
seg.AddFragment(frag)

for _, sample := range samples {
	frag.AddFullSample(sample)
}

This segment can finally be output to a io.Writer as

err := seg.Encode(w)

or to a bits.SliceWriter as

err := seg.EncodeSW(sw)

For multi-track segments, the code is a bit more involved. Please have a look at examples/segmenter to see how it is done. A more optimal way of handling media sample is to handle them lazily, or using intervals, as explained next.

Lazy decoding and writing of mdat data ¶

For video and audio, the dominating part of a mp4 file is the media data which is stored in one or more mp4.MdatBox. In some cases, for example when segmenting large progressive files, it is much more memory efficient to just read the movie or fragment metadata from the mp4.MoovBox or mp4.MoofBox and defer the reading of the media data from the mp4.MdatBox to later.

For decoding, this is supported by running DecodeFile in lazy mode as

parsedMp4, err = mp4.DecodeFile(ifd, mp4.WithDecodeMode(mp4.DecModeLazyMdat))

In this case, the media data of the mp4.MdatBox box will not be read, but only its size is being saved. To read or copy the actual data corresponding to a sample, one must calculate the corresponding byte range and either call

func (m *MdatBox) ReadData(start, size int64, rs io.ReadSeeker) ([]byte, error)

or

func (m *MdatBox) CopyData(start, size int64, rs io.ReadSeeker, w io.Writer) (nrWritten int64, err error)

Example code for this, including lazy writing of mp4.MdatBox, can be found in examples/segmenter with the lazy mode set.

More efficient I/O using SliceReader and SliceWriter ¶

The use of the interfaces io.Reader and io.Writer for reading and writing boxes gives a lot of flexibility, but is not optimal when it comes to memory allocation. In particular, the Read(p []byte) method needs a slice "p" of the proper size to read data, which leads to a lot of allocations and copying of data. In order to achieve better performance, it is advantageous to read the full top level boxes into one, or a few, slices and decode these. This is the reason that bits.SliceReader and bits.SliceWriter were introduced and that there are double methods for decoding and encoding all boxes using either of the interfaces. For benchmarks, see the README.md of the mp4ff module.

Fur further reduction of memory allocation, use a buffered top-level reader, especially when when reading the mp4.MdatBox box of a progressive file.

More about mp4 boxes ¶

The mp4 package contains a lot of box implementations.

The Box interface is specified in box.go. It decodes box size and type in the box header and dispatches decode for each individual box depending on its type.

There is also a ContainerBox interface which is used for boxes that contain other boxes.d

Most boxes have their own file named after the box, but in some cases, there may be multiple boxes that have the same content, and the box structure and the source code file then has a generic name like mp4.VisualSampleEntryBox

The interfaces define common Box methods including encode (writing), but not the decode (parsing) methods which have distinct names for each box type and are dispatched from the parsed box name.

That dispatch based on box name is defined by the tables "mp4.decodersSR" and "mp4.decoders" for the functions "mp4.DecodeBoxSR" and "mp4.DecodeBox", respectively. The "SR" variant that uses bits/SliceReader should normally be used for better performance. If a box name is unknown, it will result in an mp4.UnknownBox being created.

How to implement a new box ¶

To implement a new box "fooo", the following is needed.

  1. Create a new file "fooo.go" and create a struct type "FoooBox".
  2. "FoooBox" must implement the mp4.Box interface methods
  3. It also needs its own decode methods "DecodeFoooSR" and "DecodeFooo", which must be added in the "decodersSR" map and "decoders" map, respectively For a simple example, look at the mp4.PrftBox.
  4. A test file `fooo_test.go` should also have a test using the method "boxDiffAfterEncodeAndDecode" to check that the box information is equal after encoding and decoding.

Direct changes of attributes ¶

Many attributes are public and can therefore be changed in freely. The advantage of this is that it is possible to write code that can manipulate boxes in many different ways, but one must be cautious to avoid breaking links to sub boxes or create inconsistent states in the boxes.

As an example, container boxes such as mp4.TrafBox have a method "AddChild" which adds a box to "Children", its slice of children boxes, but also sets a specific member reference such as "Tfdt" to point to that box. If "Children" is manipulated directly, that link may no longer be valid.

Encoding modes and optimizations ¶

For fragmented files, one can choose to either encode all boxes in a mp4.File, or only code the ones which are included in the init and media segments. The attribute that controls that is called mp4.FragEncMode. Another attribute mp4.EncOptimize controls possible optimizations of the file encoding process. Currently, there is only one possible optimization called mp4.OptimizeTrun. It can reduce the size of the mp4.TrunBox by finding and writing default values in the mp4.TfhdBox and omitting the corresponding values from the mp4.TrunBox. Note that this may change the size of all ancestor boxes of the mp4.TrunBox.

Sample Number Offset ¶

Following the ISOBMFF standard, sample numbers and other numbers start at 1 (one-based). This applies to arguments of functions and methods. The actual storage in slices is zero-based, so sample nr 1 has index 0 in the corresponding slice.

Index ¶

Examples ¶

Constants ¶

View Source
const (
	ColorTypeOnScreenColors          = "nclx" // on-screen colours acc. to ISO/IEC 14496-12 Sec. 12.1.5.2
	ColorTypeRestrictedICCProfile    = "rICC" // restricted ICC profile acc. to ISO/IEC 14496-12 Sec. 12.1.5.2
	ColorTypeUnrestrictedICCTProfile = "prof" // unrestricted ICC profile acc. to ISO/IEC 14496-12 Sec. 12.1.5.2
	// QuickTimeColorParameters defined in [nclc]
	//
	// [nclc]: https://developer.apple.com/library/archive/technotes/tn2162/_index.html#//apple_ref/doc/uid/DTS40013070-CH1-TNTAG10
	QuickTimeColorParameters = "nclc"
)
View Source
const (
	// Following Table 1 of Class Tags for descriptors in ISO/IEC 14496-1. There are more types
	ObjectDescrTag        = 1
	InitialObjectDescrTag = 2
	ES_DescrTag           = 3
	DecoderConfigDescrTag = 4
	DecSpecificInfoTag    = 5
	SLConfigDescrTag      = 6
)
View Source
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)
)
View Source
const (
	// OptimizeNone - no optimization
	OptimizeNone = EncOptimize(0)
	// OptimizeTrun - optimize trun box by moving default values to tfhd
	OptimizeTrun = EncOptimize(1 << 0)
)
View Source
const (
	PrftTimeEncoderInput       = 0
	PrftTimeEncoderOutput      = 1
	PrftTimeMoofFinalized      = 2
	PrftTimeMoofWritten        = 4
	PrftTimeArbitraryConsitent = 8
	PrftTimeCaptured           = 24
)
View Source
const (
	UUIDPlayReady   = "9a04f079-9840-4286-ab92-e65be0885f95"
	UUIDWidevine    = "edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"
	UUIDFairPlay    = "94ce86fb-07ff-4f43-adb8-93d2fa968ca2"
	UUID_VCAS       = "9a27dd82-fde2-4725-8cbc-4234aa06ec09"
	UUID_W3C_COMMON = "1077efec-c0b2-4d02-ace3-3c1e52e2fb4b"
)

UUIDs for different DRM systems

View Source
const (

	// UUIDMssSm - MSS StreamManifest UUID [MS-SSTR 2.2.7.2]
	UUIDMssSm = "3c2fe51b-efee-40a3-ae815300199dc348"

	// UUIDMssLs - MSS LiveServerManifest UUID [MS-SSTR 2.2.7.3]
	UUIDMssLsm = "a5d40b30-e814-11dd-ba2f-0800200c9a66"

	// UUIDTfxd - MSS tfxd UUID [MS-SSTR 2.2.4.4]
	UUIDTfxd = "6d1d9b05-42d5-44e6-80e2-141daff757b2"

	// UUIDTfrf - MSS tfrf UUID [MS-SSTR 2.2.4.5]
	UUIDTfrf = "d4807ef2-ca39-4695-8e54-26cb9e46a79f"

	// UUIDPiffSenc - PIFF UUID for Sample Encryption Box (PIFF 1.1 spec)
	UUIDPiffSenc = "a2394f52-5a9b-4f14-a244-6c427c648df4"
)
View Source
const DefaultTrakID = 1

DefaultTrakID - trakID used when generating new fragmented content

View Source
const EpochDiffS = int64((66*365 + 17) * 24 * 3600)

EpochDiffS is the difference in seconds between Jan 1, 1904 and Jan 1, 1970

View Source
const (
	NTPEpochOffset = 2208988800 // NTP epoch is 1900, Unix epoch is 1970
)
View Source
const NonSyncSampleFlags uint32 = 0x00010000

NonSyncSampleFlags - flags for non-sync sample

View Source
const SampleDependsOn1 uint32 = 0x01000000

SampleDependsOn1 - this sample depends on others (not an I picture)

View Source
const SyncSampleFlags uint32 = 0x02000000

SyncSampleFlags - flags for I-frame or other sync sample

View Source
const TfhdBaseDataOffsetPresentFlag uint32 = 0x000001
View Source
const TfhdDefaultBaseIsMoofFlag uint32 = 0x020000
View Source
const TfhdDefaultSampleDurationPresentFlag uint32 = 0x000008
View Source
const TfhdDefaultSampleFlagsPresentFlag uint32 = 0x000020
View Source
const TfhdDefaultSampleSizePresentFlag uint32 = 0x000010
View Source
const TfhdDurationIsEmptyFlag uint32 = 0x010000
View Source
const TfhdSampleDescriptionIndexPresentFlag uint32 = 0x000002
View Source
const TrunDataOffsetPresentFlag uint32 = 0x01
View Source
const TrunFirstSampleFlagsPresentFlag uint32 = 0x04
View Source
const TrunSampleCompositionTimeOffsetPresentFlag uint32 = 0x800
View Source
const TrunSampleDurationPresentFlag uint32 = 0x100
View Source
const TrunSampleFlagsPresentFlag uint32 = 0x400
View Source
const TrunSampleSizePresentFlag uint32 = 0x200
View Source
const UseSubSampleEncryption = 0x2

UseSubSampleEncryption - flag for subsample encryption

Variables ¶

View Source
var AC3BitrateCodesKbps = []uint16{
	32,
	40,
	48,
	56,
	64,
	80,
	96,
	112,
	128,
	160,
	192,
	224,
	256,
	320,
	384,
	448,
	512,
	576,
	640,
}

AC3BitrateCodesKbps - Bitrates in kbps ETSI TS 102 366 V1.4.1 Table F.4.1 (2017)

View Source
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

View Source
var AC3acmodChannelTable = []string{
	"L/R",
	"C",
	"L/R",
	"L/C/R",
	"L/R/Cs",
	"L/C/R/Cs",
	"L/R/Ls/Rs",
	"L/C/R/Ls/Rs",
}

AX3acmodChanneTable - channel configurations from ETSI TS 102 366 V1.4.1 (2017) section 4.4.2.3A Signaled in acmod - audio coding mode - 3 bits

View Source
var CustomChannelMapLocations = map[string]uint16{
	"L":       1 << 15,
	"C":       1 << 14,
	"R":       1 << 13,
	"Ls":      1 << 12,
	"Rs":      1 << 11,
	"Lc/Rc":   1 << 10,
	"Lrs/Rrs": 1 << 9,
	"Cs":      1 << 8,
	"Ts":      1 << 7,
	"Lsd/Rsd": 1 << 6,
	"Lw/Rw":   1 << 5,
	"Vhl/Vhr": 1 << 4,
	"Vhc":     1 << 3,
	"Lts/Rts": 1 << 2,
	"LFE2":    1 << 1,
	"LFE":     1 << 0,
}

ETSI TS 102 366 V1.4.1 (2017) Table E.1.4 chanmap - Custom channel map - 16 bits

View Source
var EC3ChannelLocationBits = []string{
	"Lc/Rc",
	"Lrs/Rrs",
	"Cs",
	"Ts",
	"Lsd/Rsd",
	"Lw/Rw",
	"Lvh/Rvh",
	"Cvh",
	"LFE2",
}

EC3ChannelLocationBits - channel location signal in 9bits Table F.6.1

View Source
var PrftFlagsInterpretation = map[uint32]string{
	PrftTimeEncoderInput:       "time_encoder_input",
	PrftTimeEncoderOutput:      "time_encoder_output",
	PrftTimeMoofFinalized:      "time_moof_finalized",
	PrftTimeMoofWritten:        "time_moof_written",
	PrftTimeArbitraryConsitent: "time_arbitrary_consistent",
	PrftTimeCaptured:           "time_captured",
}

Functions ¶

func ContainerInfo ¶

func ContainerInfo(c ContainerBox, w io.Writer, specificBoxLevels, indent, indentStep string) error

ContainerInfo - write container-box information

func CryptSampleCenc ¶ added in v0.40.0

func CryptSampleCenc(sample []byte, key []byte, iv []byte, subSamplePatterns []SubSamplePattern) error

CryptSampleCenc encrypts/decrypts cenc-schema sample in place provided key, iv, and subSamplePatterns.

func DecryptFragment ¶ added in v0.40.0

func DecryptFragment(frag *Fragment, di DecryptInfo, key []byte) error

DecryptFragment decrypts a fragment in place

func DecryptSampleCbcs ¶

func DecryptSampleCbcs(sample []byte, key []byte, iv []byte, subSamplePatterns []SubSamplePattern, tenc *TencBox) error

DecryptSampleCenc does in-place decryption of cbcs-schema encrypted sample. Each protected byte range is striped with with pattern defined by pattern in tenc.

func DecryptSegment ¶ added in v0.40.0

func DecryptSegment(seg *MediaSegment, di DecryptInfo, key []byte) error

DecryptSegment decrypts a media segment in place

func EncodeContainer ¶

func EncodeContainer(c ContainerBox, w io.Writer) error

EncodeContainer - marshal container c to w

func EncodeContainerSW ¶

func EncodeContainerSW(c ContainerBox, sw bits.SliceWriter) error

EncodeContainerSW - marshal container c to sw

func EncodeHeader ¶

func EncodeHeader(b Box, w io.Writer) error

EncodeHeader - encode a box header to a writer

func EncodeHeaderSW ¶

func EncodeHeaderSW(b Box, sw bits.SliceWriter) error

EncodeHeaderSW - encode a box header to a SliceWriter

func EncodeHeaderWithSize ¶

func EncodeHeaderWithSize(boxType string, boxSize uint64, largeSize bool, w io.Writer) error

EncodeHeaderWithSize - encode a box header to a writer and allow for largeSize

func EncodeHeaderWithSizeSW ¶

func EncodeHeaderWithSizeSW(boxType string, boxSize uint64, largeSize bool, sw bits.SliceWriter) error

EncodeHeaderWithSize - encode a box header to a writer and allow for largeSize

func EncryptFragment ¶ added in v0.40.0

func EncryptFragment(f *Fragment, key, iv []byte, ipd *InitProtectData) error

func EncryptSampleCbcs ¶ added in v0.40.0

func EncryptSampleCbcs(sample []byte, key []byte, iv []byte, subSamplePatterns []SubSamplePattern, tenc *TencBox) error

EncryptSampleCenc does in-place encryption using cbcs schema. Each protected byte range is striped with with pattern defined by pattern in tenc.

func GetChannelListFromACMod ¶

func GetChannelListFromACMod(acmod byte) []string

GetChannelListFromACMod - get list of channels from acmod byte

func IsSyncSampleFlags ¶

func IsSyncSampleFlags(flags uint32) bool

IsSyncSampleFlags - flags is set correctly for sync sample

func ProtectionSystemName ¶ added in v0.42.0

func ProtectionSystemName(systemID UUID) string

ProtectionSystemName returns name of protection system if known.

func RemoveBoxDecoder ¶ added in v0.33.0

func RemoveBoxDecoder(boxType string)

RemoveBoxDecoder removes the decode of boxType. It will be treated as unknown instead.

This is a global change, so use with care.

func SetBoxDecoder ¶ added in v0.33.0

func SetBoxDecoder(boxType string, dec BoxDecoder, decSR BoxDecoderSR)

SetBoxDecoder sets decoder functions for a specific boxType.

This is a global change, so use with care.

func SetNonSyncSampleFlags ¶

func SetNonSyncSampleFlags(flags uint32) uint32

SetNonSyncSampleFlags - return flags with nonsyncsample pattern

func SetSyncSampleFlags ¶

func SetSyncSampleFlags(flags uint32) uint32

SetSyncSampleFlags - return flags with syncsample pattern

func TagType ¶ added in v0.45.0

func TagType(tag byte) string

func UnpackKey ¶ added in v0.48.0

func UnpackKey(inKey string) (key []byte, err error)

UnpackKey unpacks a hex or base64 encoded 16-byte key. The key can be in uuid formats with hyphens at positions 8, 13, 18, 23.

func WriteToFile ¶

func WriteToFile(boxStructure BoxStructure, filePath string) error

WriteToFile - write a box structure to a file at filePath

Types ¶

type AC4Presentation ¶ added in v0.50.0

type AC4Presentation struct {
	PresentationVersion uint8  // 8 bits - presentation version
	PresBytes           uint8  // 8 bits - presentation data length
	AddPresBytes        uint16 // 16 bits - additional length (if PresBytes == 255)
	PresentationData    []byte // Raw presentation data
}

AC4Presentation represents a presentation in the DSI

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 bits.SliceWriter)

Encode SampleGroupEntry to SliceWriter

func (*AlstSampleGroupEntry) Info ¶

func (s *AlstSampleGroupEntry) Info(w io.Writer, specificBoxLevels, indent, indentStep string) (err error)

Info - write box info to w

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 AudioSampleEntryBox ¶

type AudioSampleEntryBox struct {
	DataReferenceIndex uint16
	ChannelCount       uint16
	SampleSize         uint16
	SampleRate         uint16 // Integer part
	Esds               *EsdsBox
	Dac3               *Dac3Box
	Dac4               *Dac4Box
	Dec3               *Dec3Box
	Dops               *DopsBox
	MhaC               *MhaCBox
	Btrt               *BtrtBox
	Sinf               *SinfBox
	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(child Box)

AddChild - add a child box (avcC normally, but clap and pasp could be part of visual entry)

func (*AudioSampleEntryBox) Encode ¶

func (a *AudioSampleEntryBox) Encode(w io.Writer) error

Encode - write box to w

func (*AudioSampleEntryBox) EncodeSW ¶

func (a *AudioSampleEntryBox) EncodeSW(sw bits.SliceWriter) error

Encode - write box to sw

func (*AudioSampleEntryBox) Info ¶

func (a *AudioSampleEntryBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box info to w

func (*AudioSampleEntryBox) RemoveEncryption ¶

func (a *AudioSampleEntryBox) RemoveEncryption() (*SinfBox, error)

RemoveEncryption - remove sinf box and set type to unencrypted type

func (*AudioSampleEntryBox) SetType ¶ added in v0.35.0

func (a *AudioSampleEntryBox) SetType(name string)

SetType sets the type (name) of the box

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 Av1CBox ¶ added in v0.40.0

type Av1CBox struct {
	av1.CodecConfRec
}

func (*Av1CBox) Encode ¶ added in v0.40.0

func (b *Av1CBox) Encode(w io.Writer) error

Encode - write box to w

func (*Av1CBox) EncodeSW ¶ added in v0.40.0

func (b *Av1CBox) EncodeSW(sw bits.SliceWriter) error

Encode - write box to sw

func (*Av1CBox) Info ¶ added in v0.40.0

func (b *Av1CBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - box-specific Info

func (*Av1CBox) Size ¶ added in v0.40.0

func (b *Av1CBox) Size() uint64

Size - return calculated size

func (*Av1CBox) Type ¶ added in v0.40.0

func (b *Av1CBox) Type() string

Type - return box type

type Av3cBox ¶ added in v0.50.0

type Av3cBox struct {
	Avs3Config Avs3DecoderConfigurationRecord
}

Av3cBox - AVS3 Configuration Box (av3c) Defined in AVS3-P6-TAI 109.6-2022-en.pdf Section 5.2.2.3

func (*Av3cBox) Encode ¶ added in v0.50.0

func (b *Av3cBox) Encode(w io.Writer) error

Encode - write box to w

func (*Av3cBox) EncodeSW ¶ added in v0.50.0

func (b *Av3cBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*Av3cBox) Info ¶ added in v0.50.0

func (b *Av3cBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box info to w

func (*Av3cBox) Size ¶ added in v0.50.0

func (b *Av3cBox) Size() uint64

Size - calculated size of box

func (*Av3cBox) Type ¶ added in v0.50.0

func (b *Av3cBox) Type() string

Type - box type

type AvcCBox ¶

type AvcCBox struct {
	avc.DecConfRec
}

AvcCBox - AVCConfigurationBox (ISO/IEC 14496-15 5.4.2.1.2 and 5.3.3.1.2) Contains one AVCDecoderConfigurationRecord

func CreateAvcC ¶

func CreateAvcC(spsNALUs [][]byte, ppsNALUs [][]byte, includePS bool) (*AvcCBox, error)

CreateAvcC - Create an avcC box based on SPS and PPS

func (*AvcCBox) Encode ¶

func (a *AvcCBox) Encode(w io.Writer) error

Encode - write box to w

func (*AvcCBox) EncodeSW ¶

func (a *AvcCBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*AvcCBox) Info ¶

func (a *AvcCBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*AvcCBox) Size ¶

func (a *AvcCBox) Size() uint64

Size - return calculated size

func (*AvcCBox) Type ¶

func (a *AvcCBox) Type() string

Type - return box type

type Avs3DecoderConfigurationRecord ¶ added in v0.50.0

type Avs3DecoderConfigurationRecord struct {
	ConfigurationVersion uint8
	SequenceHeaderLength uint16
	SequenceHeader       []byte
	LibraryDependencyIDC uint8 // 2 bits
}

Avs3DecoderConfigurationRecord - AVS3 Decoder Configuration Record Defined in AVS3-P6-TAI 109.6-2022-en.pdf Section 5.2.2.1

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
	// Encode box to SliceWriter
	EncodeSW(sw bits.SliceWriter) error
	// Info - write box details
	//   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
}

Box is the general interface to any ISOBMFF box or similar

func DecodeAudioSampleEntry ¶

func DecodeAudioSampleEntry(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeAudioSampleEntry - decode mp4a... box

func DecodeAudioSampleEntrySR ¶

func DecodeAudioSampleEntrySR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeAudioSampleEntry - decode mp4a... box

func DecodeAv1C ¶ added in v0.40.0

func DecodeAv1C(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeAv1C - box-specific decode

func DecodeAv1CSR ¶ added in v0.40.0

func DecodeAv1CSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeAv1CSR - box-specific decode

func DecodeAv3c ¶ added in v0.50.0

func DecodeAv3c(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeAv3c - box-specific decode

func DecodeAv3cSR ¶ added in v0.50.0

func DecodeAv3cSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeAv3cSR - box-specific decode

func DecodeAvcC ¶

func DecodeAvcC(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeAvcC - box-specific decode

func DecodeAvcCSR ¶

func DecodeAvcCSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeAvcCSR - box-specific decode

func DecodeBox ¶

func DecodeBox(startPos uint64, r io.Reader) (Box, error)

DecodeBox decodes a box

func DecodeBoxLazyMdat ¶

func DecodeBoxLazyMdat(startPos uint64, r io.ReadSeeker) (Box, error)

DecodeBoxLazyMdat decodes a box but doesn't read mdat into memory

func DecodeBoxSR ¶

func DecodeBoxSR(startPos uint64, sr bits.SliceReader) (Box, error)

DecodeBoxSR - decode a box from SliceReader

func DecodeBtrt ¶

func DecodeBtrt(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeBtrt - box-specific decode

func DecodeBtrtSR ¶

func DecodeBtrtSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeBtrtSR - box-specific decode

func DecodeCdat ¶

func DecodeCdat(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeCdat - box-specific decode

func DecodeCdatSR ¶

func DecodeCdatSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeCdat - box-specific decode

func DecodeClap ¶

func DecodeClap(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeClap - box-specific decode

func DecodeClapSR ¶

func DecodeClapSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeClapSR - box-specific decode

func DecodeCo64 ¶

func DecodeCo64(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeCo64 - box-specific decode

func DecodeCo64SR ¶

func DecodeCo64SR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeCo64 - box-specific decode

func DecodeCoLL ¶ added in v0.48.0

func DecodeCoLL(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeCoLL - box-specific decode

func DecodeCoLLSR ¶ added in v0.48.0

func DecodeCoLLSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeCoLLSR - decode box from SliceReader

func DecodeColr ¶ added in v0.34.0

func DecodeColr(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeColr decodes a ColrBox

func DecodeColrSR ¶ added in v0.34.0

func DecodeColrSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeColrSR decodes a ColrBox from a SliceReader

func DecodeContainerChildren ¶

func DecodeContainerChildren(hdr BoxHeader, startPos, endPos uint64, r io.Reader) ([]Box, error)

DecodeContainerChildren decodes a container box

func DecodeContainerChildrenSR ¶

func DecodeContainerChildrenSR(hdr BoxHeader, startPos, endPos uint64, sr bits.SliceReader) ([]Box, error)

DecodeContainerChildren decodes a container box

func DecodeCslg ¶

func DecodeCslg(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeCslg - box-specific decode

func DecodeCslgSR ¶

func DecodeCslgSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeCslgSR - box-specific decode

func DecodeCtim ¶

func DecodeCtim(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeCtim - box-specific decode

func DecodeCtimSR ¶

func DecodeCtimSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeCtimSR - box-specific decode

func DecodeCtts ¶

func DecodeCtts(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeCtts - box-specific decode

func DecodeCttsSR ¶

func DecodeCttsSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeCttsSR - box-specific decode

func DecodeDac3 ¶

func DecodeDac3(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeDac3 - box-specific decode

func DecodeDac3SR ¶

func DecodeDac3SR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeDac3SR - box-specific decode

func DecodeDac4 ¶ added in v0.50.0

func DecodeDac4(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeDac4 - box-specific decode

func DecodeDac4SR ¶ added in v0.50.0

func DecodeDac4SR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeDac4SR - box-specific decode

func DecodeData ¶

func DecodeData(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeData - decode Data (from mov_write_string_data_tag in movenc.c in ffmpeg)

func DecodeDataSR ¶

func DecodeDataSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeDataSR - decode Data (from mov_write_string_data_tag in movenc.c in ffmpeg)

func DecodeDec3 ¶

func DecodeDec3(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeDec3 - box-specific decode

func DecodeDec3SR ¶

func DecodeDec3SR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeDec3SR - box-specific decode

func DecodeDinf ¶

func DecodeDinf(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeDinf - box-specific decode

func DecodeDinfSR ¶

func DecodeDinfSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeDinfSR - box-specific decode

func DecodeDops ¶ added in v0.50.0

func DecodeDops(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeDops - box-specific decode

func DecodeDopsSR ¶ added in v0.50.0

func DecodeDopsSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeDopsSR - box-specific decode

func DecodeDref ¶

func DecodeDref(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeDref - box-specific decode

func DecodeDrefSR ¶

func DecodeDrefSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeDrefSR - box-specific decode

func DecodeEdts ¶

func DecodeEdts(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeEdts - box-specific decode

func DecodeEdtsSR ¶

func DecodeEdtsSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeEdtsSR - box-specific decode

func DecodeElng ¶

func DecodeElng(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeElng - box-specific decode

func DecodeElngSR ¶

func DecodeElngSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeElngSR - box-specific decode

func DecodeElst ¶

func DecodeElst(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeElst - box-specific decode

func DecodeElstSR ¶

func DecodeElstSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeElstSR - box-specific decode

func DecodeEmeb ¶ added in v0.46.0

func DecodeEmeb(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeEmeb - box-specific decode

func DecodeEmebSR ¶ added in v0.46.0

func DecodeEmebSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeEmebSR - box-specific decode

func DecodeEmib ¶ added in v0.46.0

func DecodeEmib(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeEmib - box-specific decode

func DecodeEmibSR ¶ added in v0.46.0

func DecodeEmibSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeEmibSR - box-specific decode

func DecodeEmsg ¶

func DecodeEmsg(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeEmsg - box-specific decode

func DecodeEmsgSR ¶

func DecodeEmsgSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeEmsgSR - box-specific decode

func DecodeEsds ¶

func DecodeEsds(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeEsds - box-specific decode

func DecodeEsdsSR ¶

func DecodeEsdsSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeEsdsSR - box-specific decode

func DecodeEvte ¶ added in v0.46.0

func DecodeEvte(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeEvte - Decode EventMessageSampleEntry (evte)

func DecodeEvteSR ¶ added in v0.46.0

func DecodeEvteSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeEvteSR - Decode EventMessageSampleEntry (evte)

func DecodeFree ¶

func DecodeFree(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeFree - box-specific decode

func DecodeFreeSR ¶

func DecodeFreeSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeFreeSR - box-specific decode

func DecodeFrma ¶

func DecodeFrma(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeFrma - box-specific decode

func DecodeFrmaSR ¶

func DecodeFrmaSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeFrmaSR - box-specific decode

func DecodeFtyp ¶

func DecodeFtyp(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeFtyp - box-specific decode

func DecodeFtypSR ¶

func DecodeFtypSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeFtypSR - box-specific decode

func DecodeGenericContainerBox ¶ added in v0.38.0

func DecodeGenericContainerBox(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeGenericContainerBox - box-specific decode

func DecodeGenericContainerBoxSR ¶ added in v0.38.0

func DecodeGenericContainerBoxSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeGenericContainerBoxSR - box-specific decode

func DecodeHdlr ¶

func DecodeHdlr(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeHdlr - box-specific decode

func DecodeHdlrSR ¶

func DecodeHdlrSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeHdlrSR - box-specific decode

func DecodeHvcC ¶

func DecodeHvcC(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeHvcC - box-specific decode

func DecodeHvcCSR ¶

func DecodeHvcCSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeHvcCSR - box-specific decode

func DecodeIden ¶

func DecodeIden(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeIden - box-specific decode

func DecodeIdenSR ¶

func DecodeIdenSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeIdenSR - box-specific decode

func DecodeIlst ¶

func DecodeIlst(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeIlst - box-specific decode

func DecodeIlstSR ¶

func DecodeIlstSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeIlstSR - box-specific decode

func DecodeKind ¶

func DecodeKind(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeKind - box-specific decode

func DecodeKindSR ¶

func DecodeKindSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeKindSR - box-specific decode

func DecodeLeva ¶ added in v0.45.0

func DecodeLeva(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeLeva - box-specific decode

func DecodeLevaSR ¶ added in v0.45.0

func DecodeLevaSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeLevaSR - box-specific decode

func DecodeLoudnessBaseBox ¶ added in v0.48.0

func DecodeLoudnessBaseBox(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeLoudnessBaseBox - box-specific decode

func DecodeLoudnessBaseBoxSR ¶ added in v0.48.0

func DecodeLoudnessBaseBoxSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeLoudnessBaseBoxSR - box-specific decode

func DecodeLudt ¶ added in v0.38.0

func DecodeLudt(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeLudt - box-specific decode

func DecodeLudtSR ¶ added in v0.38.0

func DecodeLudtSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeLudtSR - box-specific decode

func DecodeMdat ¶

func DecodeMdat(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeMdat - box-specific decode

func DecodeMdatLazily ¶

func DecodeMdatLazily(hdr BoxHeader, startPos uint64) (Box, error)

DecodeMdatLazily - box-specific decode but Data is not in memory

func DecodeMdatSR ¶

func DecodeMdatSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeMdatSR decodes an mdat box

Currently no content and no error is returned if not full length available. If not enough content, an accumulated error is stored in sr, though

func DecodeMdhd ¶

func DecodeMdhd(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeMdhd - Decode box

func DecodeMdhdSR ¶

func DecodeMdhdSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeMdhd - Decode box

func DecodeMdia ¶

func DecodeMdia(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeMdia - box-specific decode

func DecodeMdiaSR ¶

func DecodeMdiaSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeMdiaSR - box-specific decode

func DecodeMehd ¶

func DecodeMehd(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeMehd - box-specific decode

func DecodeMehdSR ¶

func DecodeMehdSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeMehdSR - box-specific decode

func DecodeMeta ¶

func DecodeMeta(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeMeta decodes a MetaBox in either MPEG or QuickTime version

func DecodeMetaSR ¶

func DecodeMetaSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeMetaSR decodes a MetaBox in either MPEG or QuickTime version

func DecodeMfhd ¶

func DecodeMfhd(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeMfhd - box-specific decode

func DecodeMfhdSR ¶

func DecodeMfhdSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeMfhdSR - box-specific decode

func DecodeMfra ¶

func DecodeMfra(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeMfra - box-specific decode

func DecodeMfraSR ¶

func DecodeMfraSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeMfraSR - box-specific decode

func DecodeMfro ¶

func DecodeMfro(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeMfro - box-specific decode

func DecodeMfroSR ¶

func DecodeMfroSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeMfroSR - box-specific decode

func DecodeMhaC ¶ added in v0.50.0

func DecodeMhaC(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeMhaC - box-specific decode

func DecodeMhaCSR ¶ added in v0.50.0

func DecodeMhaCSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeMhaCSR - box-specific decode

func DecodeMime ¶

func DecodeMime(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeMime - box-specific decode

func DecodeMimeSR ¶

func DecodeMimeSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeMimeSR - box-specific decode

func DecodeMinf ¶

func DecodeMinf(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeMinf - box-specific decode

func DecodeMinfSR ¶

func DecodeMinfSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeMinfSR - box-specific decode

func DecodeMoof ¶

func DecodeMoof(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeMoof - box-specific decode

func DecodeMoofSR ¶

func DecodeMoofSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeMoofSR - box-specific decode

func DecodeMoov ¶

func DecodeMoov(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeMoov - box-specific decode

func DecodeMoovSR ¶

func DecodeMoovSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeMoovSR - box-specific decode

func DecodeMvex ¶

func DecodeMvex(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeMvex - box-specific decode

func DecodeMvexSR ¶

func DecodeMvexSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeMvex - box-specific decode

func DecodeMvhd ¶

func DecodeMvhd(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeMvhd - box-specific decode

func DecodeMvhdSR ¶

func DecodeMvhdSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeMvhdSR - box-specific decode

func DecodeNmhd ¶

func DecodeNmhd(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeNmhd - box-specific decode

func DecodeNmhdSR ¶

func DecodeNmhdSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeNmhdSR - box-specific decode

func DecodePasp ¶

func DecodePasp(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodePasp - box-specific decode

func DecodePaspSR ¶

func DecodePaspSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodePaspSR - box-specific decode

func DecodePayl ¶

func DecodePayl(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodePayl - box-specific decode

func DecodePaylSR ¶

func DecodePaylSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodePaylSR - box-specific decode

func DecodePrft ¶

func DecodePrft(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodePrft - box-specific decode

func DecodePrftSR ¶

func DecodePrftSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodePrftSR - box-specific decode

func DecodePssh ¶

func DecodePssh(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodePssh - box-specific decode

func DecodePsshSR ¶

func DecodePsshSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodePsshSR - box-specific decode

func DecodeSaio ¶

func DecodeSaio(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeSaio - box-specific decode

func DecodeSaioSR ¶

func DecodeSaioSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeSaioSR - box-specific decode

func DecodeSaiz ¶

func DecodeSaiz(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeSaiz - box-specific decode

func DecodeSaizSR ¶

func DecodeSaizSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeSaizSR - box-specific decode

func DecodeSbgp ¶

func DecodeSbgp(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeSbgp - box-specific decode

func DecodeSbgpSR ¶

func DecodeSbgpSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeSbgpSR - box-specific decode

func DecodeSchi ¶

func DecodeSchi(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeSchi - box-specific decode

func DecodeSchiSR ¶

func DecodeSchiSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeSchiSR - box-specific decode

func DecodeSchm ¶

func DecodeSchm(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeSchm - box-specific decode

func DecodeSchmSR ¶

func DecodeSchmSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeSchmSR - box-specific decode

func DecodeSdtp ¶

func DecodeSdtp(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeSdtp - box-specific decode

func DecodeSdtpSR ¶

func DecodeSdtpSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeSdtpSR - box-specific decode

func DecodeSenc ¶

func DecodeSenc(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeSenc - box-specific decode

func DecodeSencSR ¶

func DecodeSencSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeSencSR - box-specific decode

func DecodeSgpd ¶

func DecodeSgpd(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeSgpd - box-specific decode

func DecodeSgpdSR ¶

func DecodeSgpdSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeSgpdSR - box-specific decode

func DecodeSidx ¶

func DecodeSidx(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeSidx - box-specific decode

func DecodeSidxSR ¶

func DecodeSidxSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeSidxSR - box-specific decode

func DecodeSilb ¶ added in v0.46.0

func DecodeSilb(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeSilb - Decode Scheme Identifier Box (silb)

func DecodeSilbSR ¶ added in v0.46.0

func DecodeSilbSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeSilbSR - Decode Scheme Identifier Box (silb)

func DecodeSinf ¶

func DecodeSinf(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeSinf - box-specific decode

func DecodeSinfSR ¶

func DecodeSinfSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeSinfSR - box-specific decode

func DecodeSmDm ¶ added in v0.48.0

func DecodeSmDm(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeSmDm - box-specific decode

func DecodeSmDmSR ¶ added in v0.48.0

func DecodeSmDmSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeSmDmSR - decode box from SliceReader

func DecodeSmhd ¶

func DecodeSmhd(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeSmhd - box-specific decode

func DecodeSmhdSR ¶

func DecodeSmhdSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeSmhdSR - box-specific decode

func DecodeSsix ¶ added in v0.45.0

func DecodeSsix(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeSsix - box-specific decode

func DecodeSsixSR ¶ added in v0.45.0

func DecodeSsixSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeSsixSR - box-specific decode

func DecodeStbl ¶

func DecodeStbl(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeStbl - box-specific decode

func DecodeStblSR ¶

func DecodeStblSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeStblSR - box-specific decode

func DecodeStco ¶

func DecodeStco(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeStco - box-specific decode

func DecodeStcoSR ¶

func DecodeStcoSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeStcoSR - box-specific decode

func DecodeSthd ¶

func DecodeSthd(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeSthd - box-specific decode

func DecodeSthdSR ¶

func DecodeSthdSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeSthdSR - box-specific decode

func DecodeStpp ¶

func DecodeStpp(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeStpp - Decode XMLSubtitleSampleEntry (stpp)

func DecodeStppSR ¶

func DecodeStppSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeStppSR - Decode XMLSubtitleSampleEntry (stpp)

func DecodeStsc ¶

func DecodeStsc(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeStsc - box-specific decode

func DecodeStscSR ¶

func DecodeStscSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeStscSR - box-specific decode

func DecodeStsd ¶

func DecodeStsd(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeStsd - box-specific decode

func DecodeStsdSR ¶

func DecodeStsdSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeStsdSR - box-specific decode

func DecodeStss ¶

func DecodeStss(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeStss - box-specific decode

func DecodeStssSR ¶

func DecodeStssSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeStssSR - box-specific decode

func DecodeStsz ¶

func DecodeStsz(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeStsz - box-specific decode

func DecodeStszSR ¶

func DecodeStszSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeStszSR - box-specific decode

func DecodeSttg ¶

func DecodeSttg(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeSttg - box-specific decode

func DecodeSttgSR ¶

func DecodeSttgSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeSttgSR - box-specific decode

func DecodeStts ¶

func DecodeStts(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeStts - box-specific decode

func DecodeSttsSR ¶

func DecodeSttsSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeSttsSR - box-specific decode

func DecodeStyp ¶

func DecodeStyp(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeStyp - box-specific decode

func DecodeStypSR ¶

func DecodeStypSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeStypSR - box-specific decode

func DecodeSubs ¶

func DecodeSubs(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeSubs - box-specific decode

func DecodeSubsSR ¶

func DecodeSubsSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeSubsSR - box-specific decode

func DecodeTenc ¶

func DecodeTenc(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeTenc - box-specific decode

func DecodeTencSR ¶

func DecodeTencSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeTencSR - box-specific decode

func DecodeTfdt ¶

func DecodeTfdt(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeTfdt - box-specific decode

func DecodeTfdtSR ¶

func DecodeTfdtSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeTfdtSR - box-specific decode

func DecodeTfhd ¶

func DecodeTfhd(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeTfhd - box-specific decode

func DecodeTfhdSR ¶

func DecodeTfhdSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeTfhdSR - box-specific decode

func DecodeTfra ¶

func DecodeTfra(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeTfra - box-specific decode

func DecodeTfraSR ¶

func DecodeTfraSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeTfraSR - box-specific decode

func DecodeTkhd ¶

func DecodeTkhd(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeTkhd - box-specific decode

func DecodeTkhdSR ¶

func DecodeTkhdSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeTkhdSR - box-specific decode

func DecodeTraf ¶

func DecodeTraf(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeTraf - box-specific decode

func DecodeTrafSR ¶

func DecodeTrafSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeTrafSR - box-specific decode

func DecodeTrak ¶

func DecodeTrak(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeTrak - box-specific decode

func DecodeTrakSR ¶

func DecodeTrakSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeTrakSR - box-specific decode

func DecodeTref ¶

func DecodeTref(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeTref - box-specific decode

func DecodeTrefSR ¶

func DecodeTrefSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeTrefSR - box-specific decode

func DecodeTrefType ¶

func DecodeTrefType(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeTrefType - box-specific decode

func DecodeTrefTypeSR ¶

func DecodeTrefTypeSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeTrefTypeSR - box-specific decode

func DecodeTrep ¶

func DecodeTrep(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeTrep - box-specific decode

func DecodeTrepSR ¶

func DecodeTrepSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeTrepSR - box-specific decode

func DecodeTrex ¶

func DecodeTrex(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeTrex - box-specific decode

func DecodeTrexSR ¶

func DecodeTrexSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeTrexSR - box-specific decode

func DecodeTrun ¶

func DecodeTrun(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeTrun - box-specific decode

func DecodeTrunSR ¶

func DecodeTrunSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeTrun - box-specific decode

func DecodeURLBox ¶

func DecodeURLBox(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeURLBox - box-specific decode

func DecodeURLBoxSR ¶

func DecodeURLBoxSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeURLBoxSR - box-specific decode

func DecodeUUIDBox ¶

func DecodeUUIDBox(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeUUIDBox - decode a UUID box including tfxd or tfrf

func DecodeUUIDBoxSR ¶

func DecodeUUIDBoxSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeUUIDBoxSR - decode a UUID box including tfxd or tfrf

func DecodeUdta ¶

func DecodeUdta(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeUdta - box-specific decode

func DecodeUdtaSR ¶

func DecodeUdtaSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeUdtaSR - box-specific decode

func DecodeUnknown ¶

func DecodeUnknown(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeUnknown - decode an unknown box

func DecodeUnknownSR ¶

func DecodeUnknownSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeUnknownSR - decode an unknown box

func DecodeVisualSampleEntry ¶

func DecodeVisualSampleEntry(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeVisualSampleEntry decodes avc1/avc3/hvc1/hev1/vvc1/vvi1 box

func DecodeVisualSampleEntrySR ¶

func DecodeVisualSampleEntrySR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeVisualSampleEntrySR decodes avc1/avc3/hvc1/hev1/vvc1/vvi1 box

func DecodeVlab ¶

func DecodeVlab(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeVlab - box-specific decode

func DecodeVlabSR ¶

func DecodeVlabSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeVlabSR - box-specific decode

func DecodeVmhd ¶

func DecodeVmhd(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeVmhd - box-specific decode

func DecodeVmhdSR ¶

func DecodeVmhdSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeVmhdSR - box-specific decode

func DecodeVppC ¶ added in v0.48.0

func DecodeVppC(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeVppC - box-specific decode

func DecodeVppCSR ¶ added in v0.48.0

func DecodeVppCSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeVppCSR - box-specific decode

func DecodeVsid ¶

func DecodeVsid(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeVsid - box-specific decode

func DecodeVsidSR ¶

func DecodeVsidSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeVsidSR - box-specific decode

func DecodeVttC ¶

func DecodeVttC(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeVttC - box-specific decode

func DecodeVttCSR ¶

func DecodeVttCSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeVttCSR - box-specific decode

func DecodeVtta ¶

func DecodeVtta(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeVtta - box-specific decode

func DecodeVttaSR ¶

func DecodeVttaSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeVttaSR - box-specific decode

func DecodeVttc ¶

func DecodeVttc(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeVttc - box-specific decode

func DecodeVttcSR ¶

func DecodeVttcSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeVttcSR - box-specific decode

func DecodeVtte ¶

func DecodeVtte(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeVtte - box-specific decode

func DecodeVtteSR ¶

func DecodeVtteSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeVtteSR - box-specific decode

func DecodeVvcC ¶ added in v0.50.0

func DecodeVvcC(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeVvcC - box-specific decode

func DecodeVvcCSR ¶ added in v0.50.0

func DecodeVvcCSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeVvcCSR - box-specific decode

func DecodeWvtt ¶

func DecodeWvtt(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

DecodeWvtt - Decoder wvtt Sample Entry (wvtt)

func DecodeWvttSR ¶

func DecodeWvttSR(hdr BoxHeader, startPos uint64, sr bits.SliceReader) (Box, error)

DecodeWvttSR - Decoder wvtt Sample Entry (wvtt)

type BoxDecoder ¶

type BoxDecoder func(hdr BoxHeader, startPos uint64, r io.Reader) (Box, error)

BoxDecoder is function signature of the Box Decode method

type BoxDecoderSR ¶

type BoxDecoderSR func(hdr BoxHeader, startPos uint64, sw bits.SliceReader) (Box, error)

BoxDecoderSR is function signature of the Box DecodeSR method

type BoxHeader ¶

type BoxHeader struct {
	Name   string
	Size   uint64
	Hdrlen int
}

BoxHeader - 8 or 16 bytes depending on size

func DecodeHeader ¶

func DecodeHeader(r io.Reader) (BoxHeader, error)

DecodeHeader decodes a box header (size + box type + possible largeSize)

func DecodeHeaderSR ¶

func DecodeHeaderSR(sr bits.SliceReader) (BoxHeader, error)

DecodeHeaderSR - decode a box header (size + box type + possible largeSize) from sr

type BoxStructure ¶

type BoxStructure interface {
	Encode(w io.Writer) error
}

BoxStructure represent a box or similar entity such as a Segment

type BtrtBox ¶

type BtrtBox struct {
	BufferSizeDB uint32
	MaxBitrate   uint32
	AvgBitrate   uint32
}

BtrtBox - BitRateBox - ISO/IEC 14496-12 Section 8.5.2.2

func (*BtrtBox) Encode ¶

func (b *BtrtBox) Encode(w io.Writer) error

Encode - write box to w

func (*BtrtBox) EncodeSW ¶

func (b *BtrtBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*BtrtBox) Info ¶

func (b *BtrtBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*BtrtBox) Size ¶

func (b *BtrtBox) Size() uint64

Size - return calculated size

func (*BtrtBox) Type ¶

func (b *BtrtBox) Type() string

Type - return box type

type CTooBox ¶

type CTooBox struct {
	Children []Box
}

CTooBox - ©too box defines the ffmpeg encoding tool information

type CdatBox ¶

type CdatBox struct {
	Data []byte
}

CdatBox - Closed Captioning Sample Data according to QuickTime spec: https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFChap3/qtff3.html#//apple_ref/doc/uid/TP40000939-CH205-SW87

func (*CdatBox) Encode ¶

func (b *CdatBox) Encode(w io.Writer) error

Encode - write box to w

func (*CdatBox) EncodeSW ¶

func (b *CdatBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*CdatBox) Info ¶

func (b *CdatBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write specific box information

func (*CdatBox) Size ¶

func (b *CdatBox) Size() uint64

Size - calculated size of box

func (*CdatBox) Type ¶

func (b *CdatBox) Type() string

Type - box type

type Chunk ¶

type Chunk struct {
	ChunkNr       uint32
	StartSampleNr uint32
	NrSamples     uint32
}

Chunk defines a chunk with number, starting sampleNr and nrSamples.

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

func (*ClapBox) Encode ¶

func (b *ClapBox) Encode(w io.Writer) error

Encode - write box to w

func (*ClapBox) EncodeSW ¶

func (b *ClapBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*ClapBox) Info ¶

func (b *ClapBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*ClapBox) Size ¶

func (b *ClapBox) Size() uint64

Size - calculated size of box

func (*ClapBox) Type ¶

func (b *ClapBox) Type() string

Type - box type

type Co64Box ¶

type Co64Box struct {
	Version     byte
	Flags       uint32
	ChunkOffset []uint64
}

Co64Box - Chunk Large Offset Box

Contained in : Sample Table box (stbl)

64-bit version of StcoBox

func (*Co64Box) Encode ¶

func (b *Co64Box) Encode(w io.Writer) error

Encode - write box to w

func (*Co64Box) EncodeSW ¶

func (b *Co64Box) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*Co64Box) GetOffset ¶

func (b *Co64Box) GetOffset(chunkNr int) (uint64, error)

GetOffset - get offset for 1-based chunkNr.

func (*Co64Box) Info ¶

func (b *Co64Box) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*Co64Box) Size ¶

func (b *Co64Box) Size() uint64

Size - box-specific size

func (*Co64Box) Type ¶

func (b *Co64Box) Type() string

Type - box-specific type

type CoLLBox ¶ added in v0.48.0

type CoLLBox struct {
	Version byte
	Flags   uint32
	MaxCLL  uint16 // Maximum Content Light Level
	MaxFALL uint16 // Maximum Frame-Average Light Level
}

CoLLBox - Content Light Level Box (coll) Can be used for VP9 codec in vp09 box (VisualSampleEntryBox). Defined in WebM Project.

func CreateCoLLBox ¶ added in v0.48.0

func CreateCoLLBox(maxCLL, maxFALL uint16) *CoLLBox

CreateCoLLBox - Create a new CoLLBox with specified values

func (*CoLLBox) Encode ¶ added in v0.48.0

func (b *CoLLBox) Encode(w io.Writer) error

Encode - write box to w

func (*CoLLBox) EncodeSW ¶ added in v0.48.0

func (b *CoLLBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*CoLLBox) Info ¶ added in v0.48.0

func (b *CoLLBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*CoLLBox) Size ¶ added in v0.48.0

func (b *CoLLBox) Size() uint64

Size - calculated size of box

func (*CoLLBox) Type ¶ added in v0.48.0

func (b *CoLLBox) Type() string

Type - box type

type ColrBox ¶ added in v0.34.0

type ColrBox struct {
	ColorType               string
	ICCProfile              []byte
	ColorPrimaries          uint16
	TransferCharacteristics uint16
	MatrixCoefficients      uint16
	FullRangeFlag           bool
	UnknownPayload          []byte
}

ColrBox is colr box defined in ISO/IEC 14496-12 2021 Sec. 12.1.5.

func (*ColrBox) Encode ¶ added in v0.34.0

func (c *ColrBox) Encode(w io.Writer) error

Encode writes box to w

func (*ColrBox) EncodeSW ¶ added in v0.34.0

func (c *ColrBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW writes box to sw

func (*ColrBox) Info ¶ added in v0.34.0

func (c *ColrBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) (err error)

Info writes box information

func (*ColrBox) Size ¶ added in v0.34.0

func (c *ColrBox) Size() uint64

Size returns the calculated size of the box

func (*ColrBox) Type ¶ added in v0.34.0

func (c *ColrBox) Type() string

Type returns the box type

type ContainerBox ¶

type ContainerBox interface {
	Type() string
	Size() uint64
	Encode(w io.Writer) error
	EncodeSW(w bits.SliceWriter) error
	GetChildren() []Box
	Info(w io.Writer, specificBoxLevels, indent, indentStep string) error
}

ContainerBox is interface for ContainerBoxes

type CslgBox ¶

type CslgBox struct {
	Version                      byte
	Flags                        uint32
	CompositionToDTSShift        int64
	LeastDecodeToDisplayDelta    int64
	GreatestDecodeToDisplayDelta int64
	CompositionStartTime         int64
	CompositionEndTime           int64
}

CslgBox - CompositionToDecodeBox -ISO/IEC 14496-12 2015 Sec. 8.6.1.4

Contained in: Sample Table Box (stbl) or Track Extension Properties Box (trep)

func (*CslgBox) Encode ¶

func (b *CslgBox) Encode(w io.Writer) error

Encode - write box to w

func (*CslgBox) EncodeSW ¶

func (b *CslgBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*CslgBox) Info ¶

func (b *CslgBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - get details with specificBoxLevels cslg:1 or higher

func (*CslgBox) Size ¶

func (b *CslgBox) Size() uint64

Size - calculated size of box

func (*CslgBox) Type ¶

func (b *CslgBox) Type() string

Type - box type

type CtimBox ¶

type CtimBox struct {
	CueCurrentTime string
}

CtimBox - CueTimeBox (ctim) CueCurrentTime is current time indication (for split cues)

func (*CtimBox) Encode ¶

func (b *CtimBox) Encode(w io.Writer) error

Encode - write box to w

func (*CtimBox) EncodeSW ¶

func (b *CtimBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*CtimBox) Info ¶

func (b *CtimBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*CtimBox) Size ¶

func (b *CtimBox) Size() uint64

Size - calculated size of box

func (*CtimBox) Type ¶

func (b *CtimBox) Type() string

Type - box-specific type

type CttsBox ¶

type CttsBox struct {
	Version byte
	Flags   uint32
	// EndSampleNr - number (1-based) of last sample in chunk. Starts with 0 for index 0
	EndSampleNr []uint32
	// SampleOffeset - offset of first sample in chunk.
	SampleOffset []int32 // int32 to handle version 1
}

CttsBox - Composition Time to Sample Box (ctts - optional)

Contained in: Sample Table Box (stbl)

func (*CttsBox) AddSampleCountsAndOffset ¶

func (b *CttsBox) AddSampleCountsAndOffset(counts []uint32, offsets []int32) error

AddSampleCountsAndOffsets - populate this box with data. Need the same number of entries in both

func (*CttsBox) Encode ¶

func (b *CttsBox) Encode(w io.Writer) error

Encode - write box to w

func (*CttsBox) EncodeSW ¶

func (b *CttsBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*CttsBox) GetCompositionTimeOffset ¶

func (b *CttsBox) GetCompositionTimeOffset(sampleNr uint32) int32

GetCompositionTimeOffset - composition time offset for (one-based) sampleNr in track timescale

func (*CttsBox) Info ¶

func (b *CttsBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - get all info with specificBoxLevels ctts:1 or higher

func (*CttsBox) NrSampleCount ¶

func (b *CttsBox) NrSampleCount() int

NrSampleCount - the number of SampleCount entries in box

func (*CttsBox) SampleCount ¶

func (b *CttsBox) SampleCount(i int) uint32

SampleCount - return sample count i (zero-based)

func (*CttsBox) Size ¶

func (b *CttsBox) Size() uint64

Size - calculated size of box

func (*CttsBox) Type ¶

func (b *CttsBox) Type() string

Type - box type

type Dac3Box ¶

type Dac3Box struct {
	FSCod         byte
	BSID          byte
	BSMod         byte
	ACMod         byte
	LFEOn         byte
	BitRateCode   byte
	Reserved      byte
	InitialZeroes byte // Should be zero
}

Dac3Box - AC3SpecificBox from ETSI TS 102 366 V1.4.1 F.4 (2017) Extra b

func (*Dac3Box) BitrateBps ¶

func (b *Dac3Box) BitrateBps() int

func (*Dac3Box) ChannelInfo ¶

func (b *Dac3Box) ChannelInfo() (nrChannels int, chanmap uint16)

ChannelInfo - number of channels and channelmap according to E.1.3.1.8

func (*Dac3Box) Encode ¶

func (b *Dac3Box) Encode(w io.Writer) error

Encode - write box to w

func (*Dac3Box) EncodeSW ¶

func (b *Dac3Box) EncodeSW(sw bits.SliceWriter) error

Encode - write box to sw

func (*Dac3Box) Info ¶

func (b *Dac3Box) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

func (*Dac3Box) SamplingFrequency ¶

func (b *Dac3Box) SamplingFrequency() int

func (*Dac3Box) Size ¶

func (b *Dac3Box) Size() uint64

Size - calculated size of box

func (*Dac3Box) Type ¶

func (b *Dac3Box) Type() string

Type - box type

type Dac4Box ¶ added in v0.50.0

type Dac4Box struct {
	AC4DSIVersion    uint8             // 3 bits - version of the DSI
	BitstreamVersion uint8             // 7 bits - version of the bitstream
	FSIndex          uint8             // 1 bit - sampling frequency index
	FrameRateIndex   uint8             // 4 bits - frame rate index
	NPresentations   uint16            // 9 bits - number of presentations
	BProgramID       uint8             // 1 bit - program ID flag
	ShortProgramID   uint16            // 16 bits - short program ID (if BProgramID is true)
	BUUID            uint8             // 1 bit - UUID flag (if BProgramID is true)
	ProgramUUID      []byte            // 128 bits - program UUID (if BUUID is true)
	BitRateMode      uint8             // 2 bits - bit rate control algorithm
	BitRate          uint32            // 32 bits - bit rate in bits/second
	BitRatePrecision uint32            // 32 bits - precision of bit rate
	Presentations    []AC4Presentation // Presentation information
	RawData          []byte            // Raw DSI data for complex parsing
}

Dac4Box - AC4SpecificBox according to ETSI TS 103 190-2 V1.2.1 (2018-02) Annex E Contains ac4_dsi_v1 structure as defined in E.6.1

func (*Dac4Box) Encode ¶ added in v0.50.0

func (b *Dac4Box) Encode(w io.Writer) error

Encode - write box to w

func (*Dac4Box) EncodeSW ¶ added in v0.50.0

func (b *Dac4Box) EncodeSW(sw bits.SliceWriter) error

EncodeSW - write box to sw

func (*Dac4Box) GetBitRateModeString ¶ added in v0.50.0

func (b *Dac4Box) GetBitRateModeString() string

GetBitRateModeString returns human-readable bit rate mode

func (*Dac4Box) GetBitstreamVersionString ¶ added in v0.50.0

func (b *Dac4Box) GetBitstreamVersionString() string

GetBitstreamVersionString returns human-readable bitstream version According to ETSI TS 103 190-2 V1.2.1 Annex E

func (*Dac4Box) GetFrameRate ¶ added in v0.50.0

func (b *Dac4Box) GetFrameRate() float64

GetFrameRate returns frame rate based on frameRateIndex According to ETSI TS 103 190-2 Table E.1

func (*Dac4Box) GetFrameRateString ¶ added in v0.50.0

func (b *Dac4Box) GetFrameRateString() string

GetFrameRateString returns human-readable frame rate According to ETSI TS 103 190-2 Table E.1

func (*Dac4Box) GetSamplingFrequency ¶ added in v0.50.0

func (b *Dac4Box) GetSamplingFrequency() int

GetSamplingFrequency returns the sampling frequency based on fsIndex According to ETSI TS 103 190-1 Table 77

func (*Dac4Box) Info ¶ added in v0.50.0

func (b *Dac4Box) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box info to w

func (*Dac4Box) Size ¶ added in v0.50.0

func (b *Dac4Box) Size() uint64

Size - calculated size of box

func (*Dac4Box) Type ¶ added in v0.50.0

func (b *Dac4Box) Type() string

Type - box type

type DataBox ¶

type DataBox struct {
	Data []byte
}

DataBox - data box used by ffmpeg for providing information.

func (*DataBox) Encode ¶

func (b *DataBox) Encode(w io.Writer) error

Encode - write box to w

func (*DataBox) EncodeSW ¶

func (b *DataBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*DataBox) Info ¶

func (b *DataBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - box-specific Info

func (*DataBox) Size ¶

func (b *DataBox) Size() uint64

Size - calculated size of box

func (*DataBox) Type ¶

func (b *DataBox) Type() string

Type - box type

type DataRange ¶

type DataRange struct {
	Offset uint64
	Size   uint64
}

DataRange is a range for sample data in a file relative to file start

type Dec3Box ¶

type Dec3Box struct {
	DataRate  uint16
	NumIndSub uint16
	EC3Subs   []EC3Sub
	Reserved  []byte
}

Dec3Box - AC3SpecificBox from ETSI TS 102 366 V1.4.1 F.4 (2017)

func (*Dec3Box) ChannelInfo ¶

func (b *Dec3Box) ChannelInfo() (nrChannels int, chanmap uint16)

func (*Dec3Box) Encode ¶

func (b *Dec3Box) Encode(w io.Writer) error

Encode - write box to w

func (*Dec3Box) EncodeSW ¶

func (b *Dec3Box) EncodeSW(sw bits.SliceWriter) error

EncodeSW - write box to sw

func (*Dec3Box) Info ¶

func (b *Dec3Box) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

func (*Dec3Box) Size ¶

func (b *Dec3Box) Size() uint64

Size - calculated size of box

func (*Dec3Box) Type ¶

func (b *Dec3Box) Type() string

Type - box type

type DecFileFlags ¶ added in v0.38.0

type DecFileFlags uint32

DecFileFlags can be combined for special decoding options

const (
	DecNoFlags DecFileFlags = 0
	// DecISMFlag tries to read mfra box at end to find segment boundaries (for ISM files)
	DecISMFlag DecFileFlags = (1 << 0)
	// DecStartOnMoof starts a segment at each moof boundary
	// This is provided no styp, or sidx/mfra box gives other information
	DecStartOnMoof = (1 << 1)
)

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 DecSpecificInfoDescriptor ¶

type DecSpecificInfoDescriptor struct {
	DecConfig []byte
	// contains filtered or unexported fields
}

func (*DecSpecificInfoDescriptor) EncodeSW ¶

func (*DecSpecificInfoDescriptor) Info ¶ added in v0.45.0

func (d *DecSpecificInfoDescriptor) Info(w io.Writer, specificLevels, indent, indentStep string) error

func (*DecSpecificInfoDescriptor) Size ¶

func (*DecSpecificInfoDescriptor) SizeSize ¶

func (d *DecSpecificInfoDescriptor) SizeSize() uint64

func (*DecSpecificInfoDescriptor) Tag ¶

func (*DecSpecificInfoDescriptor) Type ¶ added in v0.45.0

type DecoderConfigDescriptor ¶

type DecoderConfigDescriptor struct {
	ObjectType byte
	StreamType byte

	BufferSizeDB     uint32
	MaxBitrate       uint32
	AvgBitrate       uint32
	DecSpecificInfo  *DecSpecificInfoDescriptor
	OtherDescriptors []Descriptor
	UnknownData      []byte // Data, probably erroneous, that we don't understand
	// contains filtered or unexported fields
}

DecoderConfigDescriptor is defined in ISO/IEC 14496-1 Section 7.2.6.6.1

class DecoderConfigDescriptor extends BaseDescriptor : bit(8) tag=DecoderConfigDescrTag {
  bit(8) objectTypeIndication;
  bit(6) streamType;
  bit(1) upStream;
  const bit(1) reserved=1;
  bit(24) bufferSizeDB;
  bit(32) maxBitrate;
  bit(32) avgBitrate;
  DecoderSpecificInfo decSpecificInfo[0 .. 1];
  profileLevelIndicationIndexDescriptor profileLevelIndicationIndexDescr [0..255];
}

func (*DecoderConfigDescriptor) EncodeSW ¶

func (*DecoderConfigDescriptor) Info ¶ added in v0.45.0

func (d *DecoderConfigDescriptor) Info(w io.Writer, specificLevels, indent, indentStep string) error

func (*DecoderConfigDescriptor) Size ¶

func (d *DecoderConfigDescriptor) Size() uint64

func (*DecoderConfigDescriptor) SizeSize ¶

func (d *DecoderConfigDescriptor) SizeSize() uint64

func (*DecoderConfigDescriptor) Tag ¶

func (d *DecoderConfigDescriptor) Tag() byte

func (*DecoderConfigDescriptor) Type ¶ added in v0.45.0

func (d *DecoderConfigDescriptor) Type() string

type DecryptInfo ¶ added in v0.40.0

type DecryptInfo struct {
	Psshs      []*PsshBox
	TrackInfos []DecryptTrackInfo
}

func DecryptInit ¶ added in v0.40.0

func DecryptInit(init *InitSegment) (DecryptInfo, error)

DecryptInit modifies init segment in place and returns decryption info and a clean init segment.

type DecryptTrackInfo ¶ added in v0.40.0

type DecryptTrackInfo struct {
	TrackID uint32
	Sinf    *SinfBox
	Trex    *TrexBox
	Psshs   []*PsshBox
}

type Descriptor ¶

type Descriptor interface {
	// Tag - descriptor tag. Fixed for each descriptor type
	Tag() byte
	// Type is string describing Tag, making descriptor fulfill boxLike interface
	Type() string
	// Size - size of descriptor, excluding tag byte and size field
	Size() uint64
	// SizeSize - size of descriptor including tag byte and size field
	SizeSize() uint64
	// EncodeSW - Write descriptor to slice writer
	EncodeSW(sw bits.SliceWriter) error
	// Info - write information about descriptor
	//   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, specificLevels, indent, indentStep string) error
}

func DecodeDecSpecificInfoDescriptor ¶

func DecodeDecSpecificInfoDescriptor(tag byte, sr bits.SliceReader, maxNrBytes int) (Descriptor, error)

func DecodeDecoderConfigDescriptor ¶

func DecodeDecoderConfigDescriptor(tag byte, sr bits.SliceReader, maxNrBytes int) (Descriptor, error)

func DecodeDescriptor ¶ added in v0.45.0

func DecodeDescriptor(sr bits.SliceReader, maxNrBytes int) (Descriptor, error)

func DecodeRawDescriptor ¶

func DecodeRawDescriptor(tag byte, sr bits.SliceReader, maxNrBytes int) (Descriptor, error)

func DecodeSLConfigDescriptor ¶

func DecodeSLConfigDescriptor(tag byte, sr bits.SliceReader, maxNrBytes int) (Descriptor, error)

type DinfBox ¶

type DinfBox struct {
	Dref     *DrefBox
	Children []Box
}

DinfBox - Data Information Box (dinf - mandatory)

Contained in : Media Information Box (minf) or Meta Box (meta)

func (*DinfBox) AddChild ¶

func (d *DinfBox) AddChild(box Box)

AddChild - Add a child box

func (*DinfBox) Encode ¶

func (d *DinfBox) Encode(w io.Writer) error

Encode - write dinf container to w

func (*DinfBox) EncodeSW ¶

func (d *DinfBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - write container using slice writer

func (*DinfBox) GetChildren ¶

func (d *DinfBox) GetChildren() []Box

GetChildren - list of child boxes

func (*DinfBox) Info ¶

func (d *DinfBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box info to w

func (*DinfBox) Size ¶

func (d *DinfBox) Size() uint64

Size - box-specific size

func (*DinfBox) Type ¶

func (d *DinfBox) Type() string

Type - box-specific type

type DopsBox ¶ added in v0.50.0

type DopsBox struct {
	Version              byte
	OutputChannelCount   byte
	PreSkip              uint16
	InputSampleRate      uint32
	OutputGain           int16
	ChannelMappingFamily byte
	StreamCount          byte
	CoupledCount         byte
	ChannelMapping       []byte
}

DopsBox - Opus Specific Box (dOps) Following https://opus-codec.org/docs/opus_in_isobmff.html

func (*DopsBox) Encode ¶ added in v0.50.0

func (d *DopsBox) Encode(w io.Writer) error

Encode - write box to w

func (*DopsBox) EncodeSW ¶ added in v0.50.0

func (d *DopsBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - write box to sw

func (*DopsBox) Info ¶ added in v0.50.0

func (d *DopsBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box info to w

func (*DopsBox) Size ¶ added in v0.50.0

func (d *DopsBox) Size() uint64

Size - return calculated size

func (*DopsBox) Type ¶ added in v0.50.0

func (d *DopsBox) Type() string

Type - return box type

type DrefBox ¶

type DrefBox struct {
	Version    byte
	Flags      uint32
	EntryCount uint32
	Children   []Box
}

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

func (*DrefBox) AddChild ¶

func (d *DrefBox) AddChild(box Box)

AddChild - Add a child box and update EntryCount

func (*DrefBox) Encode ¶

func (d *DrefBox) Encode(w io.Writer) error

Encode - write dref box to w including children

func (*DrefBox) EncodeSW ¶

func (d *DrefBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - write dref box to w including children

func (*DrefBox) Info ¶

func (d *DrefBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*DrefBox) Size ¶

func (d *DrefBox) Size() uint64

Size - calculated size of box

func (*DrefBox) Type ¶

func (d *DrefBox) Type() string

Type - box type

type EC3Sub ¶

type EC3Sub struct {
	FSCod     byte
	BSID      byte
	ASVC      byte
	BSMod     byte
	ACMod     byte
	LFEOn     byte
	NumDepSub byte
	ChanLoc   uint16
}

EC3Sub - Enhanced AC-3 substream information

type ESDescriptor ¶

type ESDescriptor struct {
	EsID             uint16
	DependsOnEsID    uint16
	OCResID          uint16
	FlagsAndPriority byte

	URLString           string
	DecConfigDescriptor *DecoderConfigDescriptor
	SLConfigDescriptor  *SLConfigDescriptor
	OtherDescriptors    []Descriptor
	UnknownData         []byte // Data, probably erroneous, that we don't understand
	// contains filtered or unexported fields
}

ESDescriptor is defined in ISO/IEC 14496-1 7.2.6.5

class ES_Descriptor extends BaseDescriptor : bit(8) tag=ES_DescrTag {
  bit(16) ES_ID;
  bit(1) streamDependenceFlag;
  bit(1) URL_Flag;
  bit(1) OCRstreamFlag;
  bit(5) streamPriority;
  if (streamDependenceFlag)
    bit(16) dependsOn_ES_ID;
  if (URL_Flag) {
    bit(8) URLlength;
    bit(8) URLstring[URLlength];
  }
  if (OCRstreamFlag)
    bit(16) OCR_ES_Id;
  DecoderConfigDescriptor decConfigDescr;
  if (ODProfileLevelIndication==0x01) //no SL extension.
  {
    SLConfigDescriptor slConfigDescr;
  } else  { // SL extension is possible.
    SLConfigDescriptor slConfigDescr;
  }
  IPI_DescrPointer ipiPtr[0 .. 1];
  IP_IdentificationDataSet ipIDS[0 .. 255];
  IPMP_DescriptorPointer ipmpDescrPtr[0 .. 255];
  LanguageDescriptor langDescr[0 .. 255];
  QoS_Descriptor qosDescr[0 .. 1];
  RegistrationDescriptor regDescr[0 .. 1];
  ExtensionDescriptor extDescr[0 .. 255];
}

func CreateESDescriptor ¶

func CreateESDescriptor(decConfig []byte) ESDescriptor

CreateESDescriptor creates an ESDescriptor with a DecoderConfigDescriptor for audio.

func DecodeESDescriptor ¶

func DecodeESDescriptor(sr bits.SliceReader, descSize uint32) (ESDescriptor, error)

func (*ESDescriptor) EncodeSW ¶

func (e *ESDescriptor) EncodeSW(sw bits.SliceWriter) error

func (*ESDescriptor) Info ¶ added in v0.45.0

func (e *ESDescriptor) Info(w io.Writer, specificLevels, indent, indentStep string) error

func (*ESDescriptor) Size ¶

func (e *ESDescriptor) Size() uint64

Size is size of payload after tag and size field

func (*ESDescriptor) SizeSize ¶

func (e *ESDescriptor) SizeSize() uint64

SizeSize is size of size field.

func (*ESDescriptor) Tag ¶

func (e *ESDescriptor) Tag() byte

func (*ESDescriptor) Type ¶ added in v0.45.0

func (e *ESDescriptor) Type() string

type EdtsBox ¶

type EdtsBox struct {
	Elst     []*ElstBox
	Children []Box
}

EdtsBox - Edit Box (edts - optional)

Contained in: Track Box ("trak")

The edit box maps the presentation timeline to the media-time line

func (*EdtsBox) AddChild ¶

func (e *EdtsBox) AddChild(child Box)

AddChild - Add a child box and update EntryCount

func (*EdtsBox) Encode ¶

func (b *EdtsBox) Encode(w io.Writer) error

Encode - write edts container to w

func (*EdtsBox) EncodeSW ¶

func (b *EdtsBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - write edts container to sw

func (*EdtsBox) GetChildren ¶

func (b *EdtsBox) GetChildren() []Box

GetChildren - list of child boxes

func (*EdtsBox) Info ¶

func (b *EdtsBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*EdtsBox) Size ¶

func (b *EdtsBox) Size() uint64

Size - calculated size of box

func (*EdtsBox) Type ¶

func (b *EdtsBox) Type() string

Type - box type

type ElngBox ¶

type ElngBox struct {
	Version  byte
	Flags    uint32
	Language string
	// contains filtered or unexported fields
}

ElngBox - Extended Language Box Defined in ISO/IEC 14496-12 Section 8.4.6 It should be a full box, but was erroneously implemented as a normal box. For backwards compatibility, the erroneous box without full header can still be decoded. The method MissingFullBoxBytes() returns true if that is the case.

func CreateElng ¶

func CreateElng(language string) *ElngBox

CreateElng - Create an Extended Language Box

func (*ElngBox) Encode ¶

func (b *ElngBox) Encode(w io.Writer) error

Encode - write box to w

func (*ElngBox) EncodeSW ¶

func (b *ElngBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*ElngBox) FixMissingFullBoxBytes ¶ added in v0.45.1

func (b *ElngBox) FixMissingFullBoxBytes()

FixMissingFullBoxBytes adds missing bytes version and flags bytes.

func (*ElngBox) Info ¶

func (b *ElngBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*ElngBox) MissingFullBoxBytes ¶ added in v0.45.1

func (b *ElngBox) MissingFullBoxBytes() bool

MissingFullBoxBytes indicates that the box is erroneously not including the 4 full box header bytes

func (*ElngBox) Size ¶

func (b *ElngBox) Size() uint64

Size - calculated size of box

func (*ElngBox) Type ¶

func (b *ElngBox) Type() string

Type - box type

type ElstBox ¶

type ElstBox struct {
	Version byte
	Flags   uint32
	Entries []ElstEntry
}

ElstBox - Edit List Box (elst - optional)

Contained in : Edit Box (edts)

func (*ElstBox) Encode ¶

func (b *ElstBox) Encode(w io.Writer) error

Encode - write box to w

func (*ElstBox) EncodeSW ¶

func (b *ElstBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*ElstBox) Info ¶

func (b *ElstBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*ElstBox) Size ¶

func (b *ElstBox) Size() uint64

Size - calculated size of box

func (*ElstBox) Type ¶

func (b *ElstBox) Type() string

Type - box type

type ElstEntry ¶

type ElstEntry struct {
	SegmentDuration   uint64
	MediaTime         int64
	MediaRateInteger  int16
	MediaRateFraction int16
}

type EmebBox ¶ added in v0.46.0

type EmebBox struct {
}

EmebBox - EventMessageBox as defined in ISO/IEC 23001-18 Section 6.2

func (*EmebBox) Encode ¶ added in v0.46.0

func (b *EmebBox) Encode(w io.Writer) error

Encode - write box to w

func (*EmebBox) EncodeSW ¶ added in v0.46.0

func (b *EmebBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*EmebBox) Info ¶ added in v0.46.0

func (b *EmebBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*EmebBox) Size ¶ added in v0.46.0

func (b *EmebBox) Size() uint64

Size - calculated size of box

func (*EmebBox) Type ¶ added in v0.46.0

func (b *EmebBox) Type() string

Type - box-specific type

type EmibBox ¶ added in v0.46.0

type EmibBox struct {
	Version               uint8
	Flags                 uint32
	PresentationTimeDelta int64
	EventDuration         uint32
	Id                    uint32
	SchemeIdURI           string
	Value                 string
	MessageData           []byte
}

EmibBox - EventMessageInstanceBox as defined in ISO/IEC 23001-18 Section 6.1

func (*EmibBox) Encode ¶ added in v0.46.0

func (b *EmibBox) Encode(w io.Writer) error

func (*EmibBox) EncodeSW ¶ added in v0.46.0

func (b *EmibBox) EncodeSW(sw bits.SliceWriter) error

func (*EmibBox) Info ¶ added in v0.46.0

func (b *EmibBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

func (*EmibBox) Size ¶ added in v0.46.0

func (b *EmibBox) Size() uint64

func (*EmibBox) Type ¶ added in v0.46.0

func (b *EmibBox) Type() string

type EmsgBox ¶

type EmsgBox struct {
	Version               byte
	Flags                 uint32
	TimeScale             uint32
	PresentationTimeDelta uint32
	PresentationTime      uint64
	EventDuration         uint32
	ID                    uint32
	SchemeIDURI           string
	Value                 string
	MessageData           []byte
}

EmsgBox - DASHEventMessageBox as defined in ISO/IEC 23009-1

func (*EmsgBox) Encode ¶

func (b *EmsgBox) Encode(w io.Writer) error

Encode - write box to w

func (*EmsgBox) EncodeSW ¶

func (b *EmsgBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*EmsgBox) Info ¶

func (b *EmsgBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*EmsgBox) Size ¶

func (b *EmsgBox) Size() uint64

Size - calculated size of box

func (*EmsgBox) Type ¶

func (b *EmsgBox) Type() string

Type - box type

type EncFragFileMode ¶

type EncFragFileMode byte

EncFragFileMode - mode for writing file

type EncOptimize ¶

type EncOptimize uint32

EncOptimize - encoder optimization mode

func (EncOptimize) String ¶

func (eo EncOptimize) String() string

type EsdsBox ¶

type EsdsBox struct {
	Version byte
	Flags   uint32
	ESDescriptor
}

EsdsBox as used for MPEG-audio, see ISO 14496-1 Section 7.2.6.6 for DecoderConfigDescriptor

func CreateEsdsBox ¶

func CreateEsdsBox(decConfig []byte) *EsdsBox

CreateEsdsBox - Create an EsdsBox geiven decConfig

func (*EsdsBox) Encode ¶

func (e *EsdsBox) Encode(w io.Writer) error

Encode - write box to w

func (*EsdsBox) EncodeSW ¶

func (e *EsdsBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*EsdsBox) Info ¶

func (e *EsdsBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*EsdsBox) Size ¶

func (e *EsdsBox) Size() uint64

Size - calculated size of box

func (*EsdsBox) Type ¶

func (e *EsdsBox) Type() string

Type - box type

type EvteBox ¶ added in v0.46.0

type EvteBox struct {
	Btrt               *BtrtBox
	Silb               *SilbBox
	Children           []Box
	DataReferenceIndex uint16
}

EvteBox - EventMessageSampleEntry box as defined in ISO/IEC 23001-18 Section 7.2

func (*EvteBox) AddChild ¶ added in v0.46.0

func (b *EvteBox) AddChild(child Box)

AddChild - add a child box (should only be btrt and silb)

func (*EvteBox) Encode ¶ added in v0.46.0

func (b *EvteBox) Encode(w io.Writer) error

Encode - write box to w via a SliceWriter

func (*EvteBox) EncodeSW ¶ added in v0.46.0

func (b *EvteBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - write box to sw

func (*EvteBox) Info ¶ added in v0.46.0

func (b *EvteBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write specific box info to w

func (*EvteBox) Size ¶ added in v0.46.0

func (b *EvteBox) Size() uint64

func (*EvteBox) Type ¶ added in v0.46.0

func (b *EvteBox) Type() string

type File ¶

type File struct {
	Ftyp  *FtypBox
	Moov  *MoovBox
	Mdat  *MdatBox     // mdat box for non-fragmented files. Extra empty boxes allowed.
	Init  *InitSegment // Init data (ftyp + moov for fragmented file)
	Sidx  *SidxBox     // The first sidx box for a DASH OnDemand file
	Sidxs []*SidxBox   // All sidx boxes for a DASH OnDemand file

	Mfra        *MfraBox        // MfraBox for ISM files
	Segments    []*MediaSegment // Media segments
	Children    []Box           // All top-level boxes in order
	FragEncMode EncFragFileMode // Determine how fragmented files are encoded
	EncOptimize EncOptimize     // Bit field with optimizations being done at encoding
	// contains filtered or unexported fields
}

File - an MPEG-4 file asset

A progressive MPEG-4 file contains three main boxes:

ftyp : the file type box
moov : the movie box (meta-data)
mdat : the media data (chunks and samples). Only used for pror

where mdat may come before moov. If fragmented, there are many more boxes and they are collected in the InitSegment, Segment and Segments structures. The sample metadata in the fragments in the Segments will be optimized unless EncModeBoxTree is set. To Encode the same data as Decoded, this flag must therefore be set. In all cases, Children contain all top-level boxes

func DecodeFile ¶

func DecodeFile(r io.Reader, options ...Option) (*File, error)

DecodeFile - parse and decode a file from reader r with optional file options. For example, the file options overwrite the default decode or encode mode. On decode problems, the returned File may contain some top-level boxes, but not all.

func DecodeFileSR ¶

func DecodeFileSR(sr bits.SliceReader, options ...Option) (*File, error)

DecodeFile - parse and decode a file from reader r with optional file options. For example, the file options overwrite the default decode or encode mode.

func NewFile ¶

func NewFile() *File

NewFile - create MP4 file

func ReadMP4File ¶

func ReadMP4File(path string) (*File, error)

ReadMP4File - read an mp4 file from path

func (*File) AddChild ¶

func (f *File) AddChild(child Box, boxStartPos uint64)

AddChild - add child with start position

func (*File) AddMediaSegment ¶

func (f *File) AddMediaSegment(m *MediaSegment)

AddMediaSegment - add a mediasegment to file f

func (*File) AddSidx ¶

func (f *File) AddSidx(sidx *SidxBox)

AddSidx adds a sidx box to the File and not a MediaSegment.

func (*File) ApplyOptions ¶

func (f *File) ApplyOptions(opts ...Option)

ApplyOptions - applies options for decoding or encoding a file

func (*File) CopySampleData ¶

func (f *File) CopySampleData(w io.Writer, rs io.ReadSeeker, trak *TrakBox,
	startSampleNr, endSampleNr uint32, workSpace []byte) error

CopySampleData copies sample data from a track in a progressive mp4 file to w. Use rs for lazy read and workSpace as an intermediate storage to avoid memory allocations.

func (*File) Encode ¶

func (f *File) Encode(w io.Writer) error

Encode - encode a file to a Writer Fragmented files are encoded based on InitSegment and MediaSegments, unless EncModeBoxTree is set.

func (*File) EncodeSW ¶

func (f *File) EncodeSW(sw bits.SliceWriter) error

EncodeSW - encode a file to a SliceWriter Fragmented files are encoded based on InitSegment and MediaSegments, unless EncModeBoxTree is set.

func (*File) Info ¶

func (f *File) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box tree with indent for each level

func (*File) IsFragmented ¶

func (f *File) IsFragmented() bool

IsFragmented - is file made of multiple segments (Mp4 fragments)

func (*File) LastSegment ¶

func (f *File) LastSegment() *MediaSegment

LastSegment - Currently last segment

func (*File) Size ¶

func (f *File) Size() uint64

Size - total size of all boxes

func (*File) UpdateSidx ¶ added in v0.44.0

func (f *File) UpdateSidx(addIfNotExists, nonZeroEPT bool) error

type Fixed16 ¶

type Fixed16 uint16

Fixed16 - An 8.8 fixed point number

func (Fixed16) String ¶

func (f Fixed16) String() string

type Fixed32 ¶

type Fixed32 uint32

Fixed32 - A 16.16 fixed point number

func (Fixed32) String ¶

func (f Fixed32) String() string

type Fragment ¶

type Fragment struct {
	Emsgs    []*EmsgBox
	Prft     *PrftBox
	Moof     *MoofBox
	Mdat     *MdatBox
	Children []Box // All top-level boxes in order

	EncOptimize EncOptimize // Bit field with optimizations being done at encoding
	StartPos    uint64      // Start position in file added by parser
	// contains filtered or unexported fields
}

Fragment - MP4 Fragment ([prft] + moof + mdat)

func CreateFragment ¶

func CreateFragment(seqNumber uint32, trackID uint32) (*Fragment, error)

CreateFragment creates a single track fragment

func CreateMultiTrackFragment ¶

func CreateMultiTrackFragment(seqNumber uint32, trackIDs []uint32) (*Fragment, error)

CreateMultiTrackFragment creates a multi-track fragment without trun boxes.

func NewFragment ¶

func NewFragment() *Fragment

NewFragment creates an empty MP4 Fragment.

func (*Fragment) AddChild ¶

func (f *Fragment) AddChild(b Box)

AddChild adds a top-level box to Fragment. Add in proper order.

func (*Fragment) AddEmsg ¶ added in v0.34.0

func (f *Fragment) AddEmsg(emsg *EmsgBox)

AddEmsg inserts an emsg box at the end of a sequence of emsg boxes at the start of the fragment.

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) AddFullSampleToTrack ¶

func (f *Fragment) AddFullSampleToTrack(s FullSample, trackID uint32) error

AddFullSampleToTrack - allows for adding samples to any track New trun boxes will be created if latest trun of fragment is not in this track

func (*Fragment) AddSample ¶

func (f *Fragment) AddSample(s Sample, baseMediaDecodeTime uint64)

AddSample - add a sample to the first (and only) trun of a track AddSampleToTrack is the more general function

func (*Fragment) AddSampleInterval ¶

func (f *Fragment) AddSampleInterval(sItvl SampleInterval) error

AddSampleInterval - add SampleInterval for a fragment with only one track

func (*Fragment) AddSampleToTrack ¶

func (f *Fragment) AddSampleToTrack(s Sample, trackID uint32, baseMediaDecodeTime uint64) error

AddSampleToTrack - allows for adding samples to any track New trun boxes will be created if latest trun of fragment is not in this track baseMediaDecodeTime will be used only for first sample in a trun

func (*Fragment) AddSamples ¶

func (f *Fragment) AddSamples(ss []Sample, baseMediaDecodeTime uint64)

AddSamples - add a slice of Sample to the first (and only) trun of a track

func (*Fragment) CommonSampleDuration ¶ added in v0.39.0

func (f *Fragment) CommonSampleDuration(trex *TrexBox) (uint32, error)

CommonSampleDuration returns a common non-zero sample duration for a track defined by trex if available.

func (*Fragment) Encode ¶

func (f *Fragment) Encode(w io.Writer) error

Encode - write fragment via writer

func (*Fragment) EncodeSW ¶

func (f *Fragment) EncodeSW(sw bits.SliceWriter) error

EncodeSW - write fragment via SliceWriter

func (*Fragment) GetChildren ¶

func (f *Fragment) GetChildren() []Box

GetChildren - return children boxes

func (*Fragment) GetFullSamples ¶

func (f *Fragment) GetFullSamples(trex *TrexBox) ([]FullSample, error)

GetFullSamples - Get full samples including media and accumulated time

func (*Fragment) GetSampleInterval ¶

func (f *Fragment) GetSampleInterval(trex *TrexBox, startSampleNr, endSampleNr uint32) (SampleInterval, error)

GetSampleInterval - get SampleInterval for a fragment with only one track

func (*Fragment) GetSampleNrFromTime ¶

func (f *Fragment) GetSampleNrFromTime(trex *TrexBox, sampleTime uint64) (uint32, error)

GetSampleNrFromTime - look up sample number from a specified time. Return error if no matching time

func (*Fragment) Info ¶

func (f *Fragment) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*Fragment) SetTrunDataOffsets ¶

func (f *Fragment) SetTrunDataOffsets()

SetTrunDataOffsets - if writeOrder available, sort and set dataOffset in truns

func (*Fragment) Size ¶

func (f *Fragment) Size() uint64

Size - return size of fragment including all boxes. Be aware that TrafBox.OptimizeTfhdTrun() can change size

type FreeBox ¶

type FreeBox struct {
	Name string
	// contains filtered or unexported fields
}

FreeBox - Free Space Box (free or skip)

func NewFreeBox ¶ added in v0.48.0

func NewFreeBox(data []byte) *FreeBox

NewFreeBox creates a new FreeBox with arbitrary data payload.

func NewSkipBox ¶ added in v0.48.0

func NewSkipBox(data []byte) *FreeBox

NewSkipBox creates a new SkipBox with arbitrary data payload.

func (*FreeBox) Encode ¶

func (b *FreeBox) Encode(w io.Writer) error

Encode - write box to w

func (*FreeBox) EncodeSW ¶

func (b *FreeBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*FreeBox) Info ¶

func (b *FreeBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*FreeBox) Payload ¶ added in v0.48.0

func (b *FreeBox) Payload() []byte

Payload returns the payload of the box (everything after the box header)

func (*FreeBox) Size ¶

func (b *FreeBox) Size() uint64

Size - calculated size of box

func (*FreeBox) Type ¶

func (b *FreeBox) Type() string

Type - box type

type FrmaBox ¶

type FrmaBox struct {
	DataFormat string // uint32 - original box type
}

FrmaBox - Original Format Box

func (*FrmaBox) Encode ¶

func (b *FrmaBox) Encode(w io.Writer) error

Encode - write box to w

func (*FrmaBox) EncodeSW ¶

func (b *FrmaBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*FrmaBox) Info ¶

func (b *FrmaBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) (err error)

Info - write box info to w

func (*FrmaBox) Size ¶

func (b *FrmaBox) Size() uint64

Size - return calculated size

func (*FrmaBox) Type ¶

func (b *FrmaBox) Type() string

Type - return box type

type FtypBox ¶

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

FtypBox - File Type Box (ftyp - mandatory in full file/init segment)

func CreateFtyp ¶

func CreateFtyp() *FtypBox

CreateFtyp - Create an Ftyp box suitable for DASH/CMAF

func NewFtyp ¶

func NewFtyp(majorBrand string, minorVersion uint32, compatibleBrands []string) *FtypBox

NewFtyp - new ftyp box with parameters

func (*FtypBox) AddCompatibleBrands ¶

func (b *FtypBox) AddCompatibleBrands(compatibleBrands []string)

AddCompatibleBrands adds new compatible brands to Ftyp box.

func (*FtypBox) CompatibleBrands ¶

func (b *FtypBox) CompatibleBrands() []string

CompatibleBrands - slice of compatible brands (4 chars each)

func (*FtypBox) Encode ¶

func (b *FtypBox) Encode(w io.Writer) error

Encode - write box to w

func (*FtypBox) EncodeSW ¶

func (b *FtypBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*FtypBox) Info ¶

func (b *FtypBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write specific box info to w

func (*FtypBox) MajorBrand ¶

func (b *FtypBox) MajorBrand() string

MajorBrand - major brand (4 chars)

func (*FtypBox) MinorVersion ¶

func (b *FtypBox) MinorVersion() uint32

MinorVersion - minor version

func (*FtypBox) Size ¶

func (b *FtypBox) Size() uint64

Size - return calculated size

func (*FtypBox) Type ¶

func (b *FtypBox) Type() string

Type - return box type

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() int64

PresentationTime - DecodeTime displaced by composition time offset (possibly negative)

type GenericContainerBox ¶ added in v0.38.0

type GenericContainerBox struct {
	Children []Box
	// contains filtered or unexported fields
}

GenericContainerBox is a generic container box with no special child pointers

func NewGenericContainerBox ¶ added in v0.38.0

func NewGenericContainerBox(name string) *GenericContainerBox

func (*GenericContainerBox) AddChild ¶ added in v0.38.0

func (b *GenericContainerBox) AddChild(child Box)

AddChild - Add a child box

func (*GenericContainerBox) Encode ¶ added in v0.38.0

func (b *GenericContainerBox) Encode(w io.Writer) error

Encode - write GenericContainerBox to w

func (*GenericContainerBox) EncodeSW ¶ added in v0.38.0

func (b *GenericContainerBox) EncodeSW(sw bits.SliceWriter) error

Encode - write minf container to sw

func (*GenericContainerBox) GetChildren ¶ added in v0.38.0

func (b *GenericContainerBox) GetChildren() []Box

GetChildren - list of child boxes

func (*GenericContainerBox) Info ¶ added in v0.38.0

func (b *GenericContainerBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*GenericContainerBox) Size ¶ added in v0.38.0

func (b *GenericContainerBox) Size() uint64

func (*GenericContainerBox) Type ¶ added in v0.38.0

func (b *GenericContainerBox) Type() string

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 false, but we allow true 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. Most common hnadler types are: "vide" (video track), "soun" (audio track), "subt" (subtitle track), "text" (text track). "meta" (timed Metadata track), clcp (Closed Captions (QuickTime))

func CreateHdlr ¶

func CreateHdlr(mediaOrHdlrType string) (*HdlrBox, error)

CreateHdlr - create mediaType-specific hdlr box

func (*HdlrBox) Encode ¶

func (b *HdlrBox) Encode(w io.Writer) error

Encode - write box to w

func (*HdlrBox) EncodeSW ¶

func (b *HdlrBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*HdlrBox) Info ¶

func (b *HdlrBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*HdlrBox) Size ¶

func (b *HdlrBox) Size() uint64

Size - calculated size of box

func (*HdlrBox) Type ¶

func (b *HdlrBox) Type() string

Type - box type

type HvcCBox ¶

type HvcCBox struct {
	hevc.DecConfRec
}

HvcCBox - HEVCConfigurationBox (ISO/IEC 14496-15 8.4.1.1.2) Contains one HEVCDecoderConfigurationRecord

func CreateHvcC ¶

func CreateHvcC(vpsNalus, spsNalus, ppsNalus [][]byte, vpsComplete, spsComplete, ppsComplete, includePS bool) (*HvcCBox, error)

CreateHvcC - create an hvcC box based on VPS, SPS and PPS and signal completeness If includePS is false, the nalus are not included, but information from sps is extracted.

func (*HvcCBox) Encode ¶

func (b *HvcCBox) Encode(w io.Writer) error

Encode - write box to w

func (*HvcCBox) EncodeSW ¶

func (b *HvcCBox) EncodeSW(sw bits.SliceWriter) error

Encode - write box to w

func (*HvcCBox) Info ¶

func (b *HvcCBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - box-specific Info

func (*HvcCBox) Size ¶

func (b *HvcCBox) Size() uint64

Size - return calculated size

func (*HvcCBox) Type ¶

func (b *HvcCBox) Type() string

Type - return box type

type IdenBox ¶

type IdenBox struct {
	CueID string
}

IdenBox - CueIDBox (iden)

func (*IdenBox) Encode ¶

func (b *IdenBox) Encode(w io.Writer) error

Encode - write box to w

func (*IdenBox) EncodeSW ¶

func (b *IdenBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*IdenBox) Info ¶

func (b *IdenBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*IdenBox) Size ¶

func (b *IdenBox) Size() uint64

Size - calculated size of box

func (*IdenBox) Type ¶

func (b *IdenBox) Type() string

Type - box-specific type

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

func (*IlstBox) AddChild ¶

func (b *IlstBox) AddChild(child Box)

AddChild - Add a child box and update SampleCount

func (*IlstBox) Encode ¶

func (b *IlstBox) Encode(w io.Writer) error

Encode - write ilst container to w

func (*IlstBox) EncodeSW ¶

func (b *IlstBox) EncodeSW(sw bits.SliceWriter) error

Encode - write ilst container to sw

func (*IlstBox) GetChildren ¶

func (b *IlstBox) GetChildren() []Box

GetChildren - list of child boxes

func (*IlstBox) Info ¶

func (b *IlstBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*IlstBox) Size ¶

func (b *IlstBox) Size() uint64

Size - box-specific type

func (*IlstBox) Type ¶

func (b *IlstBox) Type() string

Type - box-specific type

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 InitProtectData ¶ added in v0.40.0

type InitProtectData struct {
	Tenc     *TencBox
	ProtFunc ProtectionRangeFunc
	Trex     *TrexBox
	Scheme   string
}

func ExtractInitProtectData ¶ added in v0.40.0

func ExtractInitProtectData(inSeg *InitSegment) (*InitProtectData, error)

ExtractInitProtectData extracts protection data from init segment

func InitProtect ¶ added in v0.40.0

func InitProtect(init *InitSegment, key, iv []byte, scheme string, kid UUID, psshBoxes []*PsshBox) (*InitProtectData, error)

InitProtect modifies the init segment to add protection information and return what is needed to encrypt fragments.

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 CreateEmptyInit ¶

func CreateEmptyInit() *InitSegment

CreateEmptyInit - create an init segment for fragmented files

func NewMP4Init ¶

func NewMP4Init() *InitSegment

NewMP4Init - Create MP4Init

func (*InitSegment) AddChild ¶

func (s *InitSegment) AddChild(b Box)

AddChild - Add a top-level box to InitSegment

func (*InitSegment) AddEmptyTrack ¶

func (s *InitSegment) AddEmptyTrack(timeScale uint32, mediaType, language string)

AddEmptyTrack - add trak + trex box with appropriate trackID value

func (*InitSegment) Encode ¶

func (s *InitSegment) Encode(w io.Writer) error

Encode - encode an initsegment to a Writer

func (*InitSegment) EncodeSW ¶

func (s *InitSegment) EncodeSW(sw bits.SliceWriter) error

EncodeSW - encode an initsegment to a SliceWriter

func (*InitSegment) GetMediaType ¶

func (s *InitSegment) GetMediaType() string

GetMediaType - should return video or audio (at present)

func (*InitSegment) Info ¶

func (s *InitSegment) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box tree with indent for each level

func (*InitSegment) Size ¶

func (s *InitSegment) Size() uint64

Size - size of init segment

func (*InitSegment) TweakSingleTrakLive ¶ added in v0.43.0

func (s *InitSegment) TweakSingleTrakLive() error

TweakSingleTrakLive assures that there is only one track and removes any mehd box.

type InitializationVector ¶

type InitializationVector []byte

InitializationVector (8 or 16 bytes)

type KindBox ¶

type KindBox struct {
	Version   byte
	Flags     uint32
	SchemeURI string
	Value     string
}

KindBox - Track Kind Box

func (*KindBox) Encode ¶

func (b *KindBox) Encode(w io.Writer) error

Encode - write box to w

func (*KindBox) EncodeSW ¶

func (b *KindBox) EncodeSW(sw bits.SliceWriter) error

Encode - write box to w

func (*KindBox) Info ¶

func (b *KindBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*KindBox) Size ¶

func (b *KindBox) Size() uint64

Size - calculated size of box

func (*KindBox) Type ¶

func (b *KindBox) Type() string

Type - box type

type LevaBox ¶ added in v0.45.0

type LevaBox struct {
	Version byte
	Flags   uint32
	Levels  []LevaLevel
}

LevaBox - Subsegment Index Box according to ISO/IEC 14496-12 Section 8.8.13.2.

func (*LevaBox) Encode ¶ added in v0.45.0

func (b *LevaBox) Encode(w io.Writer) error

Encode - write box to w

func (*LevaBox) EncodeSW ¶ added in v0.45.0

func (b *LevaBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*LevaBox) Info ¶ added in v0.45.0

func (b *LevaBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - more info for level 1

func (*LevaBox) Size ¶ added in v0.45.0

func (b *LevaBox) Size() uint64

Size - return calculated size

func (*LevaBox) Type ¶ added in v0.45.0

func (b *LevaBox) Type() string

Type - return box type

type LevaLevel ¶ added in v0.45.0

type LevaLevel struct {
	TrackID               uint32
	GroupingType          uint32
	GroupingTypeParameter uint32
	SubTrackID            uint32
	// contains filtered or unexported fields
}

LevaLevel - level data for LevaBox

func NewLevaLevel ¶ added in v0.45.0

func NewLevaLevel(trackID uint32, paddingFlag bool, assignmentType byte,
	groupingType, groupingTypeParameter, subTrackID uint32) (LevaLevel, error)

NewLevaLevel - create new level for LevaBox.

func (LevaLevel) AssignmentType ¶ added in v0.45.0

func (l LevaLevel) AssignmentType() byte

AssignmentType - return assignment type.

func (LevaLevel) PaddingFlag ¶ added in v0.45.0

func (l LevaLevel) PaddingFlag() bool

PaddingFlag - return padding flag.

func (LevaLevel) Size ¶ added in v0.45.0

func (l LevaLevel) Size() uint64

Size - return calculated size.

type LoudnessBase ¶ added in v0.38.0

type LoudnessBase struct {
	EQSetID                uint8
	DownmixID              uint8
	DRCSetID               uint8
	BsSamplePeakLevel      int16
	BsTruePeakLevel        int16
	MeasurementSystemForTP uint8
	ReliabilityForTP       uint8
	Measurements           []LoudnessMeasurement
}

LoudnessBase provides a loudness entry in a LoudnessBaseBox

type LoudnessBaseBox ¶ added in v0.48.0

type LoudnessBaseBox struct {
	Name          string
	Version       byte
	Flags         uint32
	LoudnessBases []*LoudnessBase
}

LoudnessBaseBox according to ISO/IEC 14496-12 Section 12.2.7.2 TrackLoudnessInfo (tlou) and AudioLoudnessInfo (alou) boxes are extensions of the LoudnessBaseBox.

func (*LoudnessBaseBox) Encode ¶ added in v0.48.0

func (b *LoudnessBaseBox) Encode(w io.Writer) error

func (*LoudnessBaseBox) EncodeSW ¶ added in v0.48.0

func (b *LoudnessBaseBox) EncodeSW(sw bits.SliceWriter) error

func (*LoudnessBaseBox) Info ¶ added in v0.48.0

func (b *LoudnessBaseBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

func (*LoudnessBaseBox) Size ¶ added in v0.48.0

func (b *LoudnessBaseBox) Size() uint64

Size of LoudnessBaseBox.

func (*LoudnessBaseBox) Type ¶ added in v0.48.0

func (b *LoudnessBaseBox) Type() string

Type of LoundessBaseBox, should be tlou or alou

type LoudnessMeasurement ¶ added in v0.48.0

type LoudnessMeasurement struct {
	MethodDefinition  uint8
	MethodValue       uint8
	MeasurementSystem uint8
	Reliability       uint8
}

LoudnessMeasurement provides a loudness measurement in a LoudnessBase.

type LudtBox ¶ added in v0.38.0

type LudtBox struct {
	Loudness      []*LoudnessBaseBox
	AlbumLoudness []*LoudnessBaseBox
	Children      []Box
}

LudtBox - Track loudness container

Contained in : Udta Box (udta)

func (*LudtBox) AddChild ¶ added in v0.38.0

func (b *LudtBox) AddChild(child Box)

AddChild - add child box

func (*LudtBox) Encode ¶ added in v0.38.0

func (b *LudtBox) Encode(w io.Writer) error

Encode - write ludt container to w

func (*LudtBox) EncodeSW ¶ added in v0.38.0

func (b *LudtBox) EncodeSW(sw bits.SliceWriter) error

Encode - write ludt container to sw

func (*LudtBox) GetChildren ¶ added in v0.38.0

func (b *LudtBox) GetChildren() []Box

GetChildren - list of child boxes

func (*LudtBox) Info ¶ added in v0.38.0

func (b *LudtBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*LudtBox) Size ¶ added in v0.38.0

func (b *LudtBox) Size() uint64

Size - calculated size of box

func (*LudtBox) Type ¶ added in v0.38.0

func (b *LudtBox) Type() string

Type - return box type

type MHADecoderConfigurationRecord ¶ added in v0.50.0

type MHADecoderConfigurationRecord struct {
	ConfigVersion                  uint8
	MpegH3DAProfileLevelIndication uint8
	ReferenceChannelLayout         uint8
	MpegH3DAConfigLength           uint16
	MpegH3DAConfig                 []byte
}

MHADecoderConfigurationRecord - MPEG-H MHADecoderConfigurationRecord According to ISO/IEC 23008-3: 2018, Section 20.4.2

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 ¶

func (m *MdatBox) AddSampleData(s []byte)

AddSampleData - a sample data to an mdat box

func (*MdatBox) AddSampleDataPart ¶

func (m *MdatBox) AddSampleDataPart(s []byte)

AddSampleDataPart - add a data part (for output)

func (*MdatBox) CopyData ¶

func (m *MdatBox) CopyData(start, size int64, rs io.ReadSeeker, w io.Writer) (nrWritten int64, err error)

CopyData - copy data range from mdat to w. The ReadSeeker is used for lazily loaded mdat case.

func (*MdatBox) DataLength ¶

func (m *MdatBox) DataLength() uint64

DataLength - length of data stored in box either as one or multiple parts

func (*MdatBox) Encode ¶

func (m *MdatBox) Encode(w io.Writer) error

Encode - write box to w. If m.lazyDataSize > 0, the mdat data needs to be written separately

func (*MdatBox) EncodeSW ¶

func (m *MdatBox) EncodeSW(sw bits.SliceWriter) error

Encode - write box to sw. If m.lazyDataSize > 0, the mdat data needs to be written separately

func (*MdatBox) GetLazyDataSize ¶

func (m *MdatBox) GetLazyDataSize() uint64

GetLazyDataSize - size of the box if filled with data

func (*MdatBox) HeaderSize ¶

func (m *MdatBox) HeaderSize() uint64

HeaderSize - 8 or 16 (bytes) depending o whether largeSize is used

func (*MdatBox) Info ¶

func (m *MdatBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*MdatBox) IsLazy ¶

func (m *MdatBox) IsLazy() bool

IsLazy - is the mdat data handled lazily (with separate writer/reader).

func (*MdatBox) PayloadAbsoluteOffset ¶

func (m *MdatBox) PayloadAbsoluteOffset() uint64

PayloadAbsoluteOffset - position of mdat payload start (works after header)

func (*MdatBox) ReadData ¶

func (m *MdatBox) ReadData(start, size int64, rs io.ReadSeeker) ([]byte, error)

ReadData reads Mdat data specified by the start and size. Input argument start is the position relative to the start of a file. The ReadSeeker is used for lazily loaded mdat case.

func (*MdatBox) SetData ¶

func (m *MdatBox) SetData(data []byte)

SetData - set the mdat data to given slice. No copying is done

func (*MdatBox) SetLazyDataSize ¶

func (m *MdatBox) SetLazyDataSize(newSize uint64)

SetLazyDataSize - set size of mdat lazy data so that the data can be written separately Don't put any data in m.Data in this mode.

func (*MdatBox) Size ¶

func (m *MdatBox) Size() uint64

Size - return calculated size, depending on largeSize set or not

func (*MdatBox) Type ¶

func (m *MdatBox) Type() string

Type - return box type

type MdhdBox ¶

type MdhdBox struct {
	Version          byte // Only version 0
	Flags            uint32
	CreationTime     uint64 // Seconds since 1904-01-01
	ModificationTime uint64 // Seconds since 1904-01-01
	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) CreationTimeS ¶ added in v0.46.0

func (b *MdhdBox) CreationTimeS() int64

CreationTimeS returns the creation time in seconds since Jan 1, 1970

func (*MdhdBox) Encode ¶

func (m *MdhdBox) Encode(w io.Writer) error

Encode - write box to w

func (*MdhdBox) EncodeSW ¶

func (m *MdhdBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*MdhdBox) GetLanguage ¶

func (m *MdhdBox) GetLanguage() string

GetLanguage - Get three-byte language string

func (*MdhdBox) Info ¶

func (m *MdhdBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*MdhdBox) ModificationTimeS ¶ added in v0.46.0

func (b *MdhdBox) ModificationTimeS() int64

ModificationTimeS returns the modification time in seconds since Jan 1, 1970

func (*MdhdBox) SetCreationTimeS ¶ added in v0.46.0

func (b *MdhdBox) SetCreationTimeS(unixTimeS int64)

SetCreationTimeS sets the creation time from seconds since Jan 1, 1970

func (*MdhdBox) SetLanguage ¶

func (m *MdhdBox) SetLanguage(lang string)

SetLanguage - Set three-byte language string

func (*MdhdBox) SetModificationTimeS ¶ added in v0.46.0

func (b *MdhdBox) SetModificationTimeS(unixTimeS int64)

SetModificationTimeS sets the modification time from seconds since Jan 1, 1970

func (*MdhdBox) Size ¶

func (m *MdhdBox) Size() uint64

Size - calculated size of box

func (*MdhdBox) Type ¶

func (m *MdhdBox) Type() string

Type - box type

type MdiaBox ¶

type MdiaBox struct {
	Mdhd     *MdhdBox
	Hdlr     *HdlrBox
	Elng     *ElngBox
	Minf     *MinfBox
	Children []Box
}

MdiaBox - Media Box (mdia)

Contained in : Track Box (trak) Contains all information about the media data.

func NewMdiaBox ¶

func NewMdiaBox() *MdiaBox

NewMdiaBox - Generate a new empty mdia box

func (*MdiaBox) AddChild ¶

func (m *MdiaBox) AddChild(box Box)

AddChild - Add a child box

func (*MdiaBox) Encode ¶

func (m *MdiaBox) Encode(w io.Writer) error

EncodeSW - write mdia container to w

func (*MdiaBox) EncodeSW ¶

func (m *MdiaBox) EncodeSW(sw bits.SliceWriter) error

Encode - write mdia container via sw

func (*MdiaBox) GetChildren ¶

func (m *MdiaBox) GetChildren() []Box

GetChildren - list of child boxes

func (*MdiaBox) Info ¶

func (m *MdiaBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*MdiaBox) Size ¶

func (m *MdiaBox) Size() uint64

Size - return calculated size

func (*MdiaBox) Type ¶

func (m *MdiaBox) Type() string

Type - return box type

type MediaSegment ¶

type MediaSegment struct {
	Styp        *StypBox
	Sidx        *SidxBox   // The first sidx box in a segment
	Sidxs       []*SidxBox // All sidx boxes in a segment
	Fragments   []*Fragment
	EncOptimize EncOptimize
	StartPos    uint64 // Start position in file
}

MediaSegment is an MP4 Media Segment with one or more Fragments.

func NewMediaSegment ¶

func NewMediaSegment() *MediaSegment

NewMediaSegment - create empty MediaSegment with CMAF styp box

func NewMediaSegmentWithStyp ¶ added in v0.34.0

func NewMediaSegmentWithStyp(styp *StypBox) *MediaSegment

NewMediaSegmentWithStyp - create empty MediaSegment with styp box

func NewMediaSegmentWithoutStyp ¶

func NewMediaSegmentWithoutStyp() *MediaSegment

NewMediaSegmentWithoutStyp - create empty media segment with no styp box

func (*MediaSegment) AddFragment ¶

func (s *MediaSegment) AddFragment(f *Fragment)

AddFragment - Add a fragment to a MediaSegment

func (*MediaSegment) AddSidx ¶

func (s *MediaSegment) AddSidx(sidx *SidxBox)

AddSidx adds a sidx box to the MediaSegment.

func (*MediaSegment) CommonSampleDuration ¶ added in v0.39.0

func (s *MediaSegment) CommonSampleDuration(trex *TrexBox) (uint32, error)

CommonSampleDuration returns a common non-zero sample duration for a track defined by trex if available.

func (*MediaSegment) Encode ¶

func (s *MediaSegment) Encode(w io.Writer) error

Encode - Write MediaSegment via writer

func (*MediaSegment) EncodeSW ¶

func (s *MediaSegment) EncodeSW(sw bits.SliceWriter) error

EncodeSW - Write MediaSegment via SliceWriter

func (*MediaSegment) FirstBox ¶ added in v0.44.0

func (s *MediaSegment) FirstBox() (Box, error)

FirstBox returns the first box in the segment, or an error if no boxes are found.

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) Info ¶

func (s *MediaSegment) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box tree with indent for each level

func (*MediaSegment) LastFragment ¶

func (s *MediaSegment) LastFragment() *Fragment

LastFragment returns the currently last fragment, or nil if no fragments.

func (*MediaSegment) Size ¶

func (s *MediaSegment) Size() uint64

Size - return size of media segment

type MehdBox ¶

type MehdBox struct {
	Version          byte
	Flags            uint32
	FragmentDuration int64
}

MehdBox - Movie Extends Header Box Optional, provides overall duration of a fragmented movie

func (*MehdBox) Encode ¶

func (b *MehdBox) Encode(w io.Writer) error

Encode - write box to w

func (*MehdBox) EncodeSW ¶

func (b *MehdBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*MehdBox) Info ¶

func (b *MehdBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) (err error)

Info - write box-specific information

func (*MehdBox) Size ¶

func (b *MehdBox) Size() uint64

Size - return calculated size

func (*MehdBox) Type ¶

func (b *MehdBox) Type() string

Type - return box type

type MetaBox ¶

type MetaBox struct {
	Version  byte
	Flags    uint32
	Hdlr     *HdlrBox
	Children []Box
	// contains filtered or unexported fields
}

MPEG box defined in ISO/IEC 14496-12 Ed. 6 2020 Section 8.11

Note. QuickTime meta atom has no version and flags field. https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/Metadata/Metadata.html#//apple_ref/doc/uid/TP40000939-CH1-SW10

func CreateMetaBox ¶

func CreateMetaBox(version byte, hdlr *HdlrBox) *MetaBox

CreateMetaBox creates a new MetaBox

func (*MetaBox) AddChild ¶

func (b *MetaBox) AddChild(child Box)

AddChild adds a child box

func (*MetaBox) Encode ¶

func (b *MetaBox) Encode(w io.Writer) error

Encode writes minf container to w

func (*MetaBox) EncodeSW ¶

func (b *MetaBox) EncodeSW(sw bits.SliceWriter) error

Encode writes minf container to sw

func (*MetaBox) GetChildren ¶

func (b *MetaBox) GetChildren() []Box

GetChildren lists child boxes

func (*MetaBox) Info ¶

func (b *MetaBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info writes box-specific info

func (*MetaBox) IsQuickTime ¶ added in v0.33.0

func (m *MetaBox) IsQuickTime() bool

IsQuickTime returns true if box is QuickTime compatible (has no version and flags)

func (*MetaBox) Size ¶

func (b *MetaBox) Size() uint64

Size calculates size of box

func (*MetaBox) Type ¶

func (b *MetaBox) Type() string

Type returns box type

type MfhdBox ¶

type MfhdBox struct {
	Version        byte
	Flags          uint32
	SequenceNumber uint32
}

MfhdBox - Media Fragment Header Box (mfhd)

Contained in : Movie Fragment box (moof))

func CreateMfhd ¶

func CreateMfhd(sequenceNumber uint32) *MfhdBox

CreateMfhd - create an MfhdBox

func (*MfhdBox) Encode ¶

func (m *MfhdBox) Encode(w io.Writer) error

Encode - write box to w

func (*MfhdBox) EncodeSW ¶

func (m *MfhdBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*MfhdBox) Info ¶

func (m *MfhdBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*MfhdBox) Size ¶

func (m *MfhdBox) Size() uint64

Size - calculated size of box

func (*MfhdBox) Type ¶

func (m *MfhdBox) Type() string

Type - box type

type MfraBox ¶

type MfraBox struct {
	Tfra     *TfraBox
	Tfras    []*TfraBox
	Mfro     *MfroBox
	Children []Box
	StartPos uint64
}

MfraBox - Movie Fragment Random Access Box (mfra) Container for TfraBox(es) that can be used to find sync samples

func (*MfraBox) AddChild ¶

func (m *MfraBox) AddChild(child Box) error

AddChild - add child box

func (*MfraBox) Encode ¶

func (m *MfraBox) Encode(w io.Writer) error

Encode - write mfra container to w

func (*MfraBox) EncodeSW ¶

func (m *MfraBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW- write mfra container via sw

func (*MfraBox) FindEntry ¶ added in v0.39.0

func (m *MfraBox) FindEntry(moofStart uint64, trackID uint32) *TfraEntry

FindEntry - find tfra entry for given moof start offset and trackID. Return nil if not found.

func (*MfraBox) GetChildren ¶

func (m *MfraBox) GetChildren() []Box

GetChildren - list of child boxes

func (*MfraBox) Info ¶

func (m *MfraBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*MfraBox) Size ¶

func (m *MfraBox) Size() uint64

Size - returns calculated size

func (*MfraBox) Type ¶

func (m *MfraBox) Type() string

Type - returns box type

type MfroBox ¶

type MfroBox struct {
	Version    byte
	Flags      uint32
	ParentSize uint32
}

MfroBox - Movie Fragment Random Access Offset Box (mfro) Contained in : MfraBox (mfra)

func TryDecodeMfro ¶ added in v0.44.0

func TryDecodeMfro(startPos uint64, r io.Reader) (*MfroBox, error)

TryDecodeMfro only decode an MfroBox and return it. If it is not an MfroBox, it returns nil and an error.

func (*MfroBox) Encode ¶

func (b *MfroBox) Encode(w io.Writer) error

Encode - write box to w

func (*MfroBox) EncodeSW ¶

func (b *MfroBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*MfroBox) Info ¶

func (b *MfroBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*MfroBox) Size ¶

func (b *MfroBox) Size() uint64

Size - return calculated size

func (*MfroBox) Type ¶

func (b *MfroBox) Type() string

Type - return box type

type MhaCBox ¶ added in v0.50.0

type MhaCBox struct {
	MHADecoderConfigRecord MHADecoderConfigurationRecord
}

MhaCBox - MPEG-H MHACConfigurationBox According to ISO/IEC 23008-3: 2018, Section 20.5.2

func (*MhaCBox) Encode ¶ added in v0.50.0

func (b *MhaCBox) Encode(w io.Writer) error

Encode - write box to w

func (*MhaCBox) EncodeSW ¶ added in v0.50.0

func (b *MhaCBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - write box to sw

func (*MhaCBox) Info ¶ added in v0.50.0

func (b *MhaCBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*MhaCBox) Size ¶ added in v0.50.0

func (b *MhaCBox) Size() uint64

Size - calculated size of box

func (*MhaCBox) Type ¶ added in v0.50.0

func (b *MhaCBox) Type() string

Type - box type

type MimeBox ¶

type MimeBox struct {
	Version              byte
	Flags                uint32
	ContentType          string
	LacksZeroTermination bool // Handle non-compliant case as well
}

MimeBox - MIME Box as defined in ISO/IEC 14496-12 2020 Section 12.3.3.2

func (*MimeBox) Encode ¶

func (b *MimeBox) Encode(w io.Writer) error

Encode - write box to w

func (*MimeBox) EncodeSW ¶

func (b *MimeBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*MimeBox) Info ¶

func (b *MimeBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write specific box information

func (*MimeBox) Size ¶

func (b *MimeBox) Size() uint64

Size - calculated size of box

func (*MimeBox) Type ¶

func (b *MimeBox) Type() string

Type - box type

type MinfBox ¶

type MinfBox struct {
	Vmhd     *VmhdBox
	Smhd     *SmhdBox
	Sthd     *SthdBox
	Dinf     *DinfBox
	Stbl     *StblBox
	Children []Box
}

MinfBox - Media Information Box (minf - mandatory)

Contained in : Media Box (mdia)

func NewMinfBox ¶

func NewMinfBox() *MinfBox

NewMinfBox - Generate a new empty minf box

func (*MinfBox) AddChild ¶

func (m *MinfBox) AddChild(child Box)

AddChild - Add a child box

func (*MinfBox) Encode ¶

func (m *MinfBox) Encode(w io.Writer) error

Encode - write minf container to w

func (*MinfBox) EncodeSW ¶

func (m *MinfBox) EncodeSW(sw bits.SliceWriter) error

Encode - write minf container to sw

func (*MinfBox) GetChildren ¶

func (m *MinfBox) GetChildren() []Box

GetChildren - list of child boxes

func (*MinfBox) Info ¶

func (m *MinfBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*MinfBox) Size ¶

func (m *MinfBox) Size() uint64

Size - calculated size of box

func (*MinfBox) Type ¶

func (m *MinfBox) Type() string

Type - box type

type MoofBox ¶

type MoofBox struct {
	Mfhd     *MfhdBox
	Traf     *TrafBox // The first traf child box
	Trafs    []*TrafBox
	Pssh     *PsshBox
	Psshs    []*PsshBox
	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) AddChild ¶

func (m *MoofBox) AddChild(child Box) error

AddChild - add child box

func (*MoofBox) Encode ¶

func (m *MoofBox) Encode(w io.Writer) error

Encode - write moof after updating trun dataoffset

func (*MoofBox) EncodeSW ¶

func (m *MoofBox) EncodeSW(sw bits.SliceWriter) error

Encode - write moof after updating trun dataoffset

func (*MoofBox) GetChildren ¶

func (m *MoofBox) GetChildren() []Box

GetChildren - list of child boxes

func (*MoofBox) Info ¶

func (m *MoofBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*MoofBox) RemovePsshs ¶

func (m *MoofBox) RemovePsshs() (psshs []*PsshBox, totalSize uint64)

RemovePsshs - remove and return all psshs children boxes

func (*MoofBox) Size ¶

func (m *MoofBox) Size() uint64

Size - returns calculated size

func (*MoofBox) Type ¶

func (m *MoofBox) Type() string

Type - returns box type

type MoovBox ¶

type MoovBox struct {
	Mvhd     *MvhdBox
	Trak     *TrakBox // The first trak box
	Traks    []*TrakBox
	Mvex     *MvexBox
	Pssh     *PsshBox
	Psshs    []*PsshBox
	Children []Box
	StartPos uint64
}

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 NewMoovBox ¶

func NewMoovBox() *MoovBox

NewMoovBox - Generate a new empty moov box

func (*MoovBox) AddChild ¶

func (m *MoovBox) AddChild(child Box)

AddChild - Add a child box

func (*MoovBox) Encode ¶

func (m *MoovBox) Encode(w io.Writer) error

Encode - write moov container to w

func (*MoovBox) EncodeSW ¶

func (m *MoovBox) EncodeSW(sw bits.SliceWriter) error

Encode - write moov container to sw

func (*MoovBox) GetChildren ¶

func (m *MoovBox) GetChildren() []Box

GetChildren - list of child boxes

func (*MoovBox) GetSinf ¶

func (m *MoovBox) GetSinf(trackID uint32) *SinfBox

func (*MoovBox) Info ¶

func (m *MoovBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*MoovBox) IsEncrypted ¶ added in v0.44.0

func (m *MoovBox) IsEncrypted(trackID uint32) bool

IsEncrypted returns true if SampleEntryBox is "encv" or "enca"

func (*MoovBox) RemovePsshs ¶

func (m *MoovBox) RemovePsshs() []*PsshBox

RemovePsshs - remove and return all psshs children boxes

func (*MoovBox) Size ¶

func (m *MoovBox) Size() uint64

Size - calculated size of box

func (*MoovBox) Type ¶

func (m *MoovBox) Type() string

Type - box type

type MvexBox ¶

type MvexBox struct {
	Mehd     *MehdBox
	Trex     *TrexBox
	Trexs    []*TrexBox
	Children []Box
}

MvexBox - MovieExtendsBox (mevx)

Contained in : Movie Box (moov)

Its presence signals a fragmented asset

func NewMvexBox ¶

func NewMvexBox() *MvexBox

NewMvexBox - Generate a new empty mvex box

func (*MvexBox) AddChild ¶

func (m *MvexBox) AddChild(child Box)

AddChild - Add a child box

func (*MvexBox) Encode ¶

func (m *MvexBox) Encode(w io.Writer) error

Encode - write mvex container to w

func (*MvexBox) EncodeSW ¶

func (m *MvexBox) EncodeSW(sw bits.SliceWriter) error

Encode - write mvex container to sw

func (*MvexBox) GetChildren ¶

func (m *MvexBox) GetChildren() []Box

GetChildren - list of child boxes

func (*MvexBox) GetTrex ¶

func (m *MvexBox) GetTrex(trackID uint32) (trex *TrexBox, ok bool)

GetTrex - get trex box for trackID

func (*MvexBox) Info ¶

func (m *MvexBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*MvexBox) Size ¶

func (m *MvexBox) Size() uint64

Size - return calculated size

func (*MvexBox) Type ¶

func (m *MvexBox) Type() string

Type - return box type

type MvhdBox ¶

type MvhdBox struct {
	Version          byte
	Flags            uint32
	CreationTime     uint64 // Seconds since 1904-01-01
	ModificationTime uint64 // Seconds since 1904-01-01
	Timescale        uint32
	Duration         uint64
	NextTrackID      uint32
	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.

func CreateMvhd ¶

func CreateMvhd() *MvhdBox

CreateMvhd - create mvhd box with reasonable values

func (*MvhdBox) CreationTimeS ¶ added in v0.46.0

func (b *MvhdBox) CreationTimeS() int64

CreationTimeS returns the creation time in seconds since Jan 1, 1970

func (*MvhdBox) Encode ¶

func (b *MvhdBox) Encode(w io.Writer) error

Encode - write box to w

func (*MvhdBox) EncodeSW ¶

func (b *MvhdBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*MvhdBox) Info ¶

func (b *MvhdBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*MvhdBox) ModificationTimeS ¶ added in v0.46.0

func (b *MvhdBox) ModificationTimeS() int64

ModificationTimeS returns the modification time in seconds since Jan 1, 1970

func (*MvhdBox) SetCreationTimeS ¶ added in v0.46.0

func (b *MvhdBox) SetCreationTimeS(unixTimeS int64)

SetCreationTimeS sets the creation time from seconds since Jan 1, 1970

func (*MvhdBox) SetModificationTimeS ¶ added in v0.46.0

func (b *MvhdBox) SetModificationTimeS(unixTimeS int64)

SetModificationTimeS sets the modification time from seconds since Jan 1, 1970

func (*MvhdBox) Size ¶

func (b *MvhdBox) Size() uint64

Size - return calculated size

func (*MvhdBox) Type ¶

func (b *MvhdBox) Type() string

Type - return box type

type NTP64 ¶ added in v0.47.0

type NTP64 uint64

NTP64 is NTP timestamp in RFC 5905 64-bit format: uint32 seconds since 1900-01-01, and uint32 fraction.

func NewNTP64 ¶ added in v0.47.0

func NewNTP64(utcTime float64) NTP64

NewNTP64 creates NTP64 from UTC time in seconds.

func (NTP64) Fraction ¶ added in v0.47.0

func (n NTP64) Fraction() uint32

Fraction returns 32-bit fractional part of NTP64.

func (NTP64) Seconds ¶ added in v0.47.0

func (n NTP64) Seconds() uint32

Seconds returns integral seconds part of NTP64

func (NTP64) String ¶ added in v0.47.0

func (n NTP64) String() string

String returns NTP64 as UTC time in string format.

func (NTP64) Time ¶ added in v0.47.0

func (n NTP64) Time() time.Time

Time returns NTP64 as time.Time in UTC.

func (NTP64) UTC ¶ added in v0.47.0

func (n NTP64) UTC() float64

UTC returns NTP64 as UTC time in seconds.

func (NTP64) UTCSeconds ¶ added in v0.47.0

func (n NTP64) UTCSeconds() uint64

UTCSeconds returns seconds of NTP64 shifted to UNIX epoch.

type NmhdBox ¶

type NmhdBox struct {
	Version byte
	Flags   uint32
}

NmhdBox - Null Media Header Box (nmhd - often used instead of sthd for subtitle tracks)

func (*NmhdBox) Encode ¶

func (b *NmhdBox) Encode(w io.Writer) error

Encode - write box to w

func (*NmhdBox) EncodeSW ¶

func (b *NmhdBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*NmhdBox) Info ¶

func (b *NmhdBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*NmhdBox) Size ¶

func (b *NmhdBox) Size() uint64

Size - calculated size of box

func (*NmhdBox) Type ¶

func (b *NmhdBox) Type() string

Type - box-specific type

type Option ¶

type Option func(f *File)

Option is function signature of file options. The design follows functional options pattern.

func WithDecodeFlags ¶ added in v0.38.0

func WithDecodeFlags(flags DecFileFlags) Option

WithDecodeFlags sets up DecodeFlags

func WithDecodeMode ¶

func WithDecodeMode(mode DecFileMode) Option

WithDecodeMode sets up DecFileMode

func WithEncodeMode ¶

func WithEncodeMode(mode EncFragFileMode) Option

WithEncodeMode sets up EncFragFileMode

type PaspBox ¶

type PaspBox struct {
	HSpacing uint32
	VSpacing uint32
}

PaspBox - Pixel Aspect Ratio Box, ISO/IEC 14496-12 2020 Sec. 12.1.4

func (*PaspBox) Encode ¶

func (b *PaspBox) Encode(w io.Writer) error

Encode - write box to w

func (*PaspBox) EncodeSW ¶

func (b *PaspBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*PaspBox) Info ¶

func (b *PaspBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*PaspBox) Size ¶

func (b *PaspBox) Size() uint64

Size - calculated size of box

func (*PaspBox) Type ¶

func (b *PaspBox) Type() string

Type - box type

type PaylBox ¶

type PaylBox struct {
	CueText string
}

PaylBox - CuePayloadBox (payl)

func (*PaylBox) Encode ¶

func (b *PaylBox) Encode(w io.Writer) error

Encode - write box to w

func (*PaylBox) EncodeSW ¶

func (b *PaylBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*PaylBox) Info ¶

func (b *PaylBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*PaylBox) Size ¶

func (b *PaylBox) Size() uint64

Size - calculated size of box

func (*PaylBox) Type ¶

func (b *PaylBox) Type() string

Type - box-specific type

type PrftBox ¶

type PrftBox struct {
	Version          byte
	Flags            uint32
	ReferenceTrackID uint32
	NTPTimestamp     NTP64
	MediaTime        uint64
}

PrftBox - Producer Reference Box (prft)

Contained in File before moof box

func CreatePrftBox ¶

func CreatePrftBox(version byte, flags, refTrackID uint32, ntp NTP64, mediatime uint64) *PrftBox

CreatePrftBox creates a new PrftBox.

func (*PrftBox) Encode ¶

func (b *PrftBox) Encode(w io.Writer) error

Encode - write box to w

func (*PrftBox) EncodeSW ¶

func (b *PrftBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*PrftBox) Info ¶

func (b *PrftBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*PrftBox) InterpretFlags ¶ added in v0.47.0

func (b *PrftBox) InterpretFlags() string

InterpretFlags - return string representation of flags.

func (*PrftBox) Size ¶

func (b *PrftBox) Size() uint64

Size - return calculated size

func (*PrftBox) Type ¶

func (b *PrftBox) Type() string

Type - return box type

type ProtectionRangeFunc ¶ added in v0.40.0

type ProtectionRangeFunc func(sample []byte, scheme string) ([]SubSamplePattern, error)

type PsshBox ¶

type PsshBox struct {
	Version  byte
	Flags    uint32
	SystemID UUID
	KIDs     []UUID
	Data     []byte
}

PsshBox - Protection System Specific Header Box Defined in ISO/IEC 23001-7 Section 8.1

func NewPsshBox ¶ added in v0.49.0

func NewPsshBox(systemID string, KIDs []string, data []byte) (*PsshBox, error)

NewPsshBox makes a PsshBox with the given systemID, KIDs and data. If there are KIDs, the version is set to 1, otherwise it is set to 0. The systemID and KIDs are expected to be in the form of UUIDs (e.g., "9a04f079-9840-4286-ab92-e65be0885f95"), hex without hyphens, or base-64 encoded strings.

func PsshBoxesFromBase64 ¶ added in v0.40.0

func PsshBoxesFromBase64(psshBase64 string) ([]*PsshBox, error)

PsshBoxesFromBase64 extracts pssh boxes from base64-encoded string

func PsshBoxesFromBytes ¶ added in v0.40.0

func PsshBoxesFromBytes(psshData []byte) ([]*PsshBox, error)

PsshBoxesFromDBytesextracts pssh boxes from slice of bytes

func (*PsshBox) Encode ¶

func (b *PsshBox) Encode(w io.Writer) error

Encode - write box to w

func (*PsshBox) EncodeSW ¶

func (b *PsshBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*PsshBox) Info ¶

func (b *PsshBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) (err error)

Info - write box info to w

func (*PsshBox) Size ¶

func (b *PsshBox) Size() uint64

Size - return calculated size

func (*PsshBox) Type ¶

func (b *PsshBox) Type() string

Type - return box type

type RapSampleGroupEntry ¶

type RapSampleGroupEntry struct {
	NumLeadingSamplesKnown uint8
	NumLeadingSamples      uint8
}

RapSampleGroupEntry - Random Access Point "rap "

ISO/IEC 14496-12 Ed. 6 2020 Section 10.4 - VisualRandomAccessEntry

func (*RapSampleGroupEntry) Encode ¶

func (s *RapSampleGroupEntry) Encode(sw bits.SliceWriter)

Encode SampleGroupEntry to SliceWriter

func (*RapSampleGroupEntry) Info ¶

func (s *RapSampleGroupEntry) Info(w io.Writer, specificBoxLevels, indent, indentStep string) (err error)

Info - write box info to w

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 RawDescriptor ¶

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

RawDescriptor - raw representation of any descriptor

func CreateRawDescriptor ¶

func CreateRawDescriptor(tag, sizeFieldSizeMinus1 byte, data []byte) (RawDescriptor, error)

func (*RawDescriptor) EncodeSW ¶

func (d *RawDescriptor) EncodeSW(sw bits.SliceWriter) error

func (*RawDescriptor) Info ¶ added in v0.45.0

func (d *RawDescriptor) Info(w io.Writer, specificLevels, indent, indentStep string) error

func (*RawDescriptor) Size ¶

func (d *RawDescriptor) Size() uint64

func (*RawDescriptor) SizeSize ¶

func (d *RawDescriptor) SizeSize() uint64

func (*RawDescriptor) Tag ¶

func (s *RawDescriptor) Tag() byte

func (*RawDescriptor) Type ¶ added in v0.45.0

func (d *RawDescriptor) Type() string

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 bits.SliceWriter)

Encode SampleGroupEntry to SliceWriter

func (*RollSampleGroupEntry) Info ¶

func (s *RollSampleGroupEntry) Info(w io.Writer, specificBoxLevels, indent, indentStep string) (err error)

Info - write box info to w

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 SLConfigDescriptor ¶

type SLConfigDescriptor struct {
	ConfigValue byte
	MoreData    []byte
	// contains filtered or unexported fields
}

func (*SLConfigDescriptor) EncodeSW ¶

func (d *SLConfigDescriptor) EncodeSW(sw bits.SliceWriter) error

func (*SLConfigDescriptor) Info ¶ added in v0.45.0

func (d *SLConfigDescriptor) Info(w io.Writer, specificLevels, indent, indentStep string) error

func (*SLConfigDescriptor) Size ¶

func (d *SLConfigDescriptor) Size() uint64

func (*SLConfigDescriptor) SizeSize ¶

func (d *SLConfigDescriptor) SizeSize() uint64

func (*SLConfigDescriptor) Tag ¶

func (d *SLConfigDescriptor) Tag() byte

func (*SLConfigDescriptor) Type ¶ added in v0.45.0

func (d *SLConfigDescriptor) Type() string

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)

func NewSaioBox ¶ added in v0.40.0

func NewSaioBox() *SaioBox

Return a new SaioBox with one offset to be updated later

func (*SaioBox) Encode ¶

func (b *SaioBox) Encode(w io.Writer) error

Encode - write box to w

func (*SaioBox) EncodeSW ¶

func (b *SaioBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*SaioBox) Info ¶

func (b *SaioBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) (err error)

Info - write SaioBox details. Get offset list with level >= 1

func (*SaioBox) SetOffset ¶ added in v0.40.0

func (b *SaioBox) SetOffset(offset int64)

SetOffset sets offset for first (and only) entry

func (*SaioBox) Size ¶

func (b *SaioBox) Size() uint64

Size - return calculated size

func (*SaioBox) Type ¶

func (b *SaioBox) Type() string

Type - return box type

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)

func NewSaizBox ¶ added in v0.40.0

func NewSaizBox(capacity int) *SaizBox

NewSaizBox creates a SaizBox with appropriate size allocated.

func (*SaizBox) AddSampleInfo ¶ added in v0.40.0

func (b *SaizBox) AddSampleInfo(iv []byte, subsamplePatterns []SubSamplePattern)

AddSampleInfo adds a sampleinfo info based on parameters provided. If no length field, don't update the sample field (typically audio cbcs)

func (*SaizBox) Encode ¶

func (b *SaizBox) Encode(w io.Writer) error

Encode - write box to w

func (*SaizBox) EncodeSW ¶

func (b *SaizBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*SaizBox) Info ¶

func (b *SaizBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) (err error)

Info - write SaizBox details. Get sampleInfo list with level >= 1

func (*SaizBox) Size ¶

func (b *SaizBox) Size() uint64

Size - return calculated size

func (*SaizBox) Type ¶

func (b *SaizBox) Type() string

Type - return box type

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)

func NewSample ¶

func NewSample(flags uint32, dur uint32, size uint32, compositionTimeOffset int32) Sample

NewSample - create Sample with trun data

func (*Sample) IsSync ¶

func (s *Sample) IsSync() bool

IsSync - check sync by masking flags including dependsOn

type SampleFlags ¶

type SampleFlags struct {
	IsLeading                 byte
	SampleDependsOn           byte
	SampleIsDependedOn        byte
	SampleHasRedundancy       byte
	SamplePaddingValue        byte
	SampleIsNonSync           bool
	SampleDegradationPriority uint16
}

SampleFlags according to 14496-12 Sec. 8.8.3.1

func DecodeSampleFlags ¶

func DecodeSampleFlags(u uint32) SampleFlags

DecodeSampleFlags - decode a uint32 flags field

func (SampleFlags) Encode ¶

func (sf SampleFlags) Encode() uint32

Encode - convert sampleflags to uint32 bit pattern

func (SampleFlags) String ¶

func (sf SampleFlags) String() string

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 bits.SliceWriter)
	// Info - description of content.
	Info(w io.Writer, specificBoxLevels, indent, indentStep string) (err error)
}

SampleGroupEntry - like a box, but size and type are not in a header

func DecodeAlstSampleGroupEntry ¶

func DecodeAlstSampleGroupEntry(name string, length uint32, sr bits.SliceReader) (SampleGroupEntry, error)

DecodeAlstSampleGroupEntry - decode ALST Sample Group Entry

func DecodeRapSampleGroupEntry ¶

func DecodeRapSampleGroupEntry(name string, length uint32, sr bits.SliceReader) (SampleGroupEntry, error)

DecodeRapSampleGroupEntry - decode Rap Sample Sample Group Entry

func DecodeRollSampleGroupEntry ¶

func DecodeRollSampleGroupEntry(name string, length uint32, sr bits.SliceReader) (SampleGroupEntry, error)

DecodeRollSampleGroupEntry - decode Roll Sample Group Entry

func DecodeSeigSampleGroupEntry ¶

func DecodeSeigSampleGroupEntry(name string, length uint32, sr bits.SliceReader) (SampleGroupEntry, error)

DecodeSeigSampleGroupEntry - decode Common Encryption Sample Group Entry

func DecodeUnknownSampleGroupEntry ¶

func DecodeUnknownSampleGroupEntry(name string, length uint32, sr bits.SliceReader) (SampleGroupEntry, error)

DecodeUnknownSampleGroupEntry - decode an unknown sample group entry

type SampleGroupEntryDecoder ¶

type SampleGroupEntryDecoder func(name string, length uint32, sr bits.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

func (*SampleInterval) Reset ¶

func (s *SampleInterval) Reset()

Reset resets sample interval while retaining allocated slice-backing arrays

type SbgpBox ¶

type SbgpBox struct {
	Version                 byte
	Flags                   uint32
	GroupingType            string // uint32, but takes values such as seig
	GroupingTypeParameter   uint32
	SampleCounts            []uint32
	GroupDescriptionIndices []uint32 // Starts at 65537 inside fragment, see Section 8.9.4
}

SbgpBox - Sample To Group Box, ISO/IEC 14496-12 6'th edition 2020 Section 8.9.2

func (*SbgpBox) Encode ¶

func (b *SbgpBox) Encode(w io.Writer) error

Encode - write box to w

func (*SbgpBox) EncodeSW ¶

func (b *SbgpBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*SbgpBox) Info ¶

func (b *SbgpBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) (err error)

Info - write box info to w

func (*SbgpBox) Size ¶

func (b *SbgpBox) Size() uint64

Size - return calculated size

func (*SbgpBox) Type ¶

func (b *SbgpBox) Type() string

Type - return box type

type SchiBox ¶

type SchiBox struct {
	Tenc     *TencBox
	Children []Box
}

SchiBox - Schema Information Box

func (*SchiBox) AddChild ¶

func (b *SchiBox) AddChild(child Box)

AddChild - Add a child box

func (*SchiBox) Encode ¶

func (b *SchiBox) Encode(w io.Writer) error

Encode - write minf container to w

func (*SchiBox) EncodeSW ¶

func (b *SchiBox) EncodeSW(sw bits.SliceWriter) error

Encode - write minf container to sw

func (*SchiBox) GetChildren ¶

func (b *SchiBox) GetChildren() []Box

GetChildren - list of child boxes

func (*SchiBox) Info ¶

func (b *SchiBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*SchiBox) Size ¶

func (b *SchiBox) Size() uint64

Size - calculated size of box

func (*SchiBox) Type ¶

func (b *SchiBox) Type() string

Type - box type

type SchmBox ¶

type SchmBox struct {
	Version       byte
	Flags         uint32
	SchemeType    string // 4CC represented as uint32
	SchemeVersion uint32
	SchemeURI     string // Absolute null-terminated URL
}

SchmBox - Scheme Type Box

func (*SchmBox) Encode ¶

func (b *SchmBox) Encode(w io.Writer) error

Encode - write box to w

func (*SchmBox) EncodeSW ¶

func (b *SchmBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*SchmBox) Info ¶

func (b *SchmBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) (err error)

Info - write box info to w

func (*SchmBox) Size ¶

func (b *SchmBox) Size() uint64

Size - return calculated size

func (*SchmBox) Type ¶

func (b *SchmBox) Type() string

Type - return box type

type SdtpBox ¶

type SdtpBox struct {
	Version byte
	Flags   uint32
	Entries []SdtpEntry
}

SdtpBox - Sample Dependency Box (sdtp - optional)

ISO/IEC 14496-12 Ed. 6 2020 Section 8.6.4 Contained in Sample Table Box (stbl)

Table to determine whether a sample depends or is depended on by other samples

func CreateSdtpBox ¶

func CreateSdtpBox(entries []SdtpEntry) *SdtpBox

CreateSdtpBox - create a new SdtpBox

func (*SdtpBox) Encode ¶

func (b *SdtpBox) Encode(w io.Writer) error

Encode - write box to w

func (*SdtpBox) EncodeSW ¶

func (b *SdtpBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*SdtpBox) Info ¶

func (b *SdtpBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*SdtpBox) Size ¶

func (b *SdtpBox) Size() uint64

Size - return calculated size

func (*SdtpBox) Type ¶

func (b *SdtpBox) Type() string

Type - return box type

type SdtpEntry ¶

type SdtpEntry uint8

SdtpEntry (uint8)

ISO/IEC 14496-12 Ed. 6 2020 Section 8.6.4.2

func NewSdtpEntry ¶

func NewSdtpEntry(isLeading, sampleDependsOn, sampleDependedOn, hasRedundancy uint8) SdtpEntry

NewSdtpEntry - make new SdtpEntry from 2-bit parameters

func (SdtpEntry) IsLeading ¶

func (entry SdtpEntry) IsLeading() uint8

IsLeading (bits 0-1) 0: Leading unknown 1: Has dependency before referenced I-picture (not decodable) 2: Not a leading sample 3: Has no dependency before referenced I-picture (decodable)

func (SdtpEntry) SampleDependsOn ¶

func (entry SdtpEntry) SampleDependsOn() uint8

SampleDependsOn (bits 2-3) 0: Dependency is unknown 1: Depends on others (not an I-picture) 2: Does not depend on others (I-picture) 3: Reservced

func (SdtpEntry) SampleHasRedundancy ¶

func (entry SdtpEntry) SampleHasRedundancy() uint8

SampleHasRedundancy (bits 6-7) 0: Redundant coding unknown 1: Redundant coding in this sample 2: No redundant coding in this sample 3: Reserved

func (SdtpEntry) SampleIsDependedOn ¶

func (entry SdtpEntry) SampleIsDependedOn() uint8

SampleIsDependedOn (bits 4-5) 0: Dependency unknown 1: Other samples may depend on this (not disposable) 2: No other samples depend on this (disposable) 3: Reserved

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 bits.SliceWriter)

Encode SampleGroupEntry to SliceWriter

func (*SeigSampleGroupEntry) Info ¶

func (s *SeigSampleGroupEntry) Info(w io.Writer, specificBoxLevels, indent, indentStep string) (err error)

Info - write box info to w

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 CreateSencBox ¶

func CreateSencBox() *SencBox

CreateSencBox - create an empty SencBox

func NewSencBox ¶ added in v0.40.0

func NewSencBox(ivCapacity, subSampleCapacity int) *SencBox

NewSencBox returns a SencBox with capacity for IVs and SubSamples.

func (*SencBox) AddSample ¶

func (s *SencBox) AddSample(sample SencSample) error

AddSample - add a senc sample with possible IV and subsamples

func (*SencBox) Encode ¶

func (s *SencBox) Encode(w io.Writer) error

Encode - write box to w

func (*SencBox) EncodeSW ¶

func (s *SencBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*SencBox) EncodeSWNoHdr ¶ added in v0.44.0

func (s *SencBox) EncodeSWNoHdr(sw bits.SliceWriter) error

EncodeSWNoHdr encodes without header (useful for PIFF box)

func (*SencBox) GetPerSampleIVSize ¶

func (s *SencBox) GetPerSampleIVSize() int

GetPerSampleIVSize - return perSampleIVSize

func (*SencBox) Info ¶

func (s *SencBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*SencBox) ParseReadBox ¶

func (s *SencBox) ParseReadBox(perSampleIVSize byte, saiz *SaizBox) error

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

func (*SencBox) PerSampleIVSize ¶ added in v0.48.0

func (s *SencBox) PerSampleIVSize() byte

PerSampleIVSize returns the per-sample IV size, 0 if not known yet. This will be automatically determined when parsing the box, or when adding samples. It can also be set explicitly.

func (*SencBox) ReadButNotParsed ¶ added in v0.48.0

func (s *SencBox) ReadButNotParsed() bool

ReadButNotParsed returns true if box has been read but not parsed. The parsing happens as a second step after perSampleIVSize is known. ParseReadBox should be called to parse the box.

func (*SencBox) SetPerSampleIVSize ¶ added in v0.48.0

func (s *SencBox) SetPerSampleIVSize(size byte)

SetPerSampleIVSize sets the per-sample IV size. Should be 0, 8 or 16.

func (*SencBox) Size ¶

func (s *SencBox) Size() uint64

Size - box-specific type

func (*SencBox) Type ¶

func (s *SencBox) Type() string

Type - box-specific type

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

func (*SgpdBox) Encode ¶

func (b *SgpdBox) Encode(w io.Writer) error

Encode - write box to w

func (*SgpdBox) EncodeSW ¶

func (b *SgpdBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*SgpdBox) Info ¶

func (b *SgpdBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) (err error)

Info - write box info to w

func (*SgpdBox) Size ¶

func (b *SgpdBox) Size() uint64

Size - return calculated size

func (*SgpdBox) Type ¶

func (b *SgpdBox) Type() string

Type - return box type

type SidxBox ¶

type SidxBox struct {
	Version                  byte
	Flags                    uint32
	ReferenceID              uint32
	Timescale                uint32
	EarliestPresentationTime uint64
	// FirstOffset is offset of first media segment relative to AnchorPoint
	FirstOffset uint64
	// AnchorPoint is first byte offset after SidxBox
	AnchorPoint uint64
	SidxRefs    []SidxRef
}

SidxBox - SegmentIndexBox

func CreateSidx ¶

func CreateSidx(baseMediaDecodeTime uint64) *SidxBox

CreateSidx - Create a new TfdtBox with baseMediaDecodeTime

func (*SidxBox) Encode ¶

func (b *SidxBox) Encode(w io.Writer) error

Encode - write box to w

func (*SidxBox) EncodeSW ¶

func (b *SidxBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*SidxBox) Info ¶

func (b *SidxBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - more info for level 1

func (*SidxBox) Size ¶

func (b *SidxBox) Size() uint64

Size - return calculated size

func (*SidxBox) Type ¶

func (b *SidxBox) Type() string

Type - return box type

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 SilbBox ¶ added in v0.46.0

type SilbBox struct {
	Version          uint8
	Flags            uint32
	Schemes          []SilbEntry
	OtherSchemesFlag bool
}

SilbBox - Scheme Identifier Box as defined in ISO/IEC 23001-18 Section 7.3

func (*SilbBox) Encode ¶ added in v0.46.0

func (b *SilbBox) Encode(w io.Writer) error

Encode - write box to w via a SliceWriter

func (*SilbBox) EncodeSW ¶ added in v0.46.0

func (b *SilbBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - write box to sw

func (*SilbBox) Info ¶ added in v0.46.0

func (b *SilbBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write specific box info to w

func (*SilbBox) Size ¶ added in v0.46.0

func (b *SilbBox) Size() uint64

func (*SilbBox) Type ¶ added in v0.46.0

func (b *SilbBox) Type() string

type SilbEntry ¶ added in v0.46.0

type SilbEntry struct {
	SchemeIdURI    string
	Value          string
	AtLeastOneFlag bool
}

SilbEntry - Scheme Identifier Box entry

type SinfBox ¶

type SinfBox struct {
	Frma     *FrmaBox // Mandatory
	Schm     *SchmBox // Optional
	Schi     *SchiBox // Optional
	Children []Box
}

SinfBox - Protection Scheme Information Box according to ISO/IEC 23001-7

func (*SinfBox) AddChild ¶

func (b *SinfBox) AddChild(child Box)

AddChild - Add a child box

func (*SinfBox) Encode ¶

func (b *SinfBox) Encode(w io.Writer) error

Encode - write sinf container to w

func (*SinfBox) EncodeSW ¶

func (b *SinfBox) EncodeSW(sw bits.SliceWriter) error

Encode - write sinf container to sw

func (*SinfBox) GetChildren ¶

func (b *SinfBox) GetChildren() []Box

GetChildren - list of child boxes

func (*SinfBox) Info ¶

func (b *SinfBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*SinfBox) Size ¶

func (b *SinfBox) Size() uint64

Size - calculated size of box

func (*SinfBox) Type ¶

func (b *SinfBox) Type() string

Type - box type

type SmDmBox ¶ added in v0.48.0

type SmDmBox struct {
	Version                 byte
	Flags                   uint32
	PrimaryRChromaticityX   uint16
	PrimaryRChromaticityY   uint16
	PrimaryGChromaticityX   uint16
	PrimaryGChromaticityY   uint16
	PrimaryBChromaticityX   uint16
	PrimaryBChromaticityY   uint16
	WhitePointChromaticityX uint16
	WhitePointChromaticityY uint16
	LuminanceMax            uint32
	LuminanceMin            uint32
}

SmDmBox - Sample Mastering Display Metadata Box (smdm) Can be used for VP9 codec in vp09 box (VisualSampleEntryBox). Defined in WebM Project.

func CreateSmDmBox ¶ added in v0.48.0

func CreateSmDmBox(primaryRX, primaryRY, primaryGX, primaryGY, primaryBX, primaryBY, whitePointX, whitePointY uint16,
	luminanceMax, luminanceMin uint32) *SmDmBox

CreateSmDmBox - Create a new SmDmBox with specified values

func (*SmDmBox) Encode ¶ added in v0.48.0

func (b *SmDmBox) Encode(w io.Writer) error

Encode - write box to w

func (*SmDmBox) EncodeSW ¶ added in v0.48.0

func (b *SmDmBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*SmDmBox) Info ¶ added in v0.48.0

func (b *SmDmBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*SmDmBox) Size ¶ added in v0.48.0

func (b *SmDmBox) Size() uint64

Size - calculated size of box

func (*SmDmBox) Type ¶ added in v0.48.0

func (b *SmDmBox) Type() string

Type - box type

type SmhdBox ¶

type SmhdBox struct {
	Version byte
	Flags   uint32
	Balance uint16 // should be int16
}

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)

func (*SmhdBox) Encode ¶

func (b *SmhdBox) Encode(w io.Writer) error

Encode - write box to w

func (*SmhdBox) EncodeSW ¶

func (b *SmhdBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*SmhdBox) Info ¶

func (b *SmhdBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*SmhdBox) Size ¶

func (b *SmhdBox) Size() uint64

Size - calculated size of box

func (*SmhdBox) Type ¶

func (b *SmhdBox) Type() string

Type - box type

type SsixBox ¶ added in v0.45.0

type SsixBox struct {
	Version     byte
	Flags       uint32
	SubSegments []SubSegment
}

SsixBox - Subsegment Index Box according to ISO/IEC 14496-12 Section 8.16.4.2

func (*SsixBox) Encode ¶ added in v0.45.0

func (b *SsixBox) Encode(w io.Writer) error

Encode - write box to w

func (*SsixBox) EncodeSW ¶ added in v0.45.0

func (b *SsixBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*SsixBox) Info ¶ added in v0.45.0

func (b *SsixBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - more info for level 1

func (*SsixBox) Size ¶ added in v0.45.0

func (b *SsixBox) Size() uint64

Size - return calculated size

func (*SsixBox) Type ¶ added in v0.45.0

func (b *SsixBox) Type() string

Type - return box type

type StblBox ¶

type StblBox struct {
	// Same order as in Table 1 in ISO/IEC 14496-12 Ed.6 2020
	Stsd  *StsdBox
	Stts  *SttsBox
	Ctts  *CttsBox
	Stsc  *StscBox
	Stsz  *StszBox
	Stss  *StssBox
	Stco  *StcoBox
	Co64  *Co64Box
	Sdtp  *SdtpBox
	Sbgp  *SbgpBox   // The first
	Sbgps []*SbgpBox // All
	Sgpd  *SgpdBox   // The first
	Sgpds []*SgpdBox // All
	Subs  *SubsBox
	Saio  *SaioBox
	Saiz  *SaizBox

	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 NewStblBox ¶

func NewStblBox() *StblBox

NewStblBox - Generate a new empty stbl box

func (*StblBox) AddChild ¶

func (s *StblBox) AddChild(child Box)

AddChild - Add a child box

func (*StblBox) Encode ¶

func (s *StblBox) Encode(w io.Writer) error

Encode - write stbl container to w

func (*StblBox) EncodeSW ¶

func (b *StblBox) EncodeSW(sw bits.SliceWriter) error

Encode - write stbl container to sw

func (*StblBox) GetChildren ¶

func (s *StblBox) GetChildren() []Box

GetChildren - list of child boxes

func (*StblBox) Info ¶

func (s *StblBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*StblBox) Size ¶

func (s *StblBox) Size() uint64

Size - box-specific size

func (*StblBox) Type ¶

func (s *StblBox) Type() string

Type - box-specific type

type StcoBox ¶

type StcoBox struct {
	Version     byte
	Flags       uint32
	ChunkOffset []uint32
}

StcoBox - Chunk Offset Box (stco - mandatory)

Contained in : Sample Table box (stbl)

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.

func (*StcoBox) Encode ¶

func (b *StcoBox) Encode(w io.Writer) error

Encode - write box to w

func (*StcoBox) EncodeSW ¶

func (b *StcoBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*StcoBox) GetOffset ¶

func (b *StcoBox) GetOffset(chunkNr int) (uint64, error)

GetOffset - get offset for 1-based chunkNr.

func (*StcoBox) Info ¶

func (b *StcoBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*StcoBox) Size ¶

func (b *StcoBox) Size() uint64

Size - box-specific size

func (*StcoBox) Type ¶

func (b *StcoBox) Type() string

Type - box-specific type

type SthdBox ¶

type SthdBox struct {
	Version byte
	Flags   uint32
}

SthdBox - Subtitle Media Header Box (sthd - for subtitle tracks)

func (*SthdBox) Encode ¶

func (b *SthdBox) Encode(w io.Writer) error

Encode - write box to w

func (*SthdBox) EncodeSW ¶

func (b *SthdBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*SthdBox) Info ¶

func (b *SthdBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*SthdBox) Size ¶

func (b *SthdBox) Size() uint64

Size - calculated size of box

func (*SthdBox) Type ¶

func (b *SthdBox) Type() string

Type - box-specific type

type StppBox ¶

type StppBox struct {
	Namespace          string   // Mandatory
	SchemaLocation     string   // Optional
	AuxiliaryMimeTypes string   // Optional, but required if auxiliary types present
	Btrt               *BtrtBox // Optional
	Children           []Box
	DataReferenceIndex uint16
	// contains filtered or unexported fields
}

StppBox - XMLSubtitleSampleEntry Box (stpp) Defined in ISO/IEC 14496-12 Sec. 12.6.3.2 and ISO/IEC 14496-30.

Contained in : Media Information Box (minf)

func NewStppBox ¶

func NewStppBox(namespace, schemaLocation, auxiliaryMimeTypes string) *StppBox

NewStppBox - Create new stpp box namespace, schemaLocation and auxiliaryMimeType are space-separated utf8-lists with zero-termination schemaLocation and auxiliaryMimeTypes are optional but must at least have a zero byte.

func (*StppBox) AddChild ¶

func (b *StppBox) AddChild(child Box)

AddChild - add a child box (avcC normally, but clap and pasp could be part of visual entry)

func (*StppBox) Encode ¶

func (b *StppBox) Encode(w io.Writer) error

Encode - write box to w via a SliceWriter

func (*StppBox) EncodeSW ¶

func (b *StppBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - write box to sw

func (*StppBox) Info ¶

func (b *StppBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write specific box info to w

func (*StppBox) Size ¶

func (b *StppBox) Size() uint64

Size - return calculated size

func (*StppBox) Type ¶

func (b *StppBox) Type() string

Type - return box type

type StscBox ¶

type StscBox struct {
	Version byte
	Flags   uint32

	Entries             []StscEntry
	SampleDescriptionID []uint32
	// contains filtered or unexported fields
}

StscBox is Sample To Chunk Box in progressive file.

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
  • sample description id : description (see the sample description box - stsd) this value is most often the same for all samples, so it is stored as a single value if possible.

FirstSampleNr is a helper value for fast lookup. Something that is often a bottleneck.

func (*StscBox) AddEntry ¶

func (b *StscBox) AddEntry(firstChunk, samplesPerChunk, sampleDescriptionID uint32) error

AddEntry adds a new entry and calculates helper values.

func (*StscBox) ChunkNrFromSampleNr ¶

func (b *StscBox) ChunkNrFromSampleNr(sampleNr int) (chunkNr, firstSampleInChunk int, err error)

ChunkNrFromSampleNr - get chunk number from sampleNr (one-based)

func (*StscBox) Encode ¶

func (b *StscBox) Encode(w io.Writer) error

Encode - write box to w

func (*StscBox) EncodeSW ¶

func (b *StscBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*StscBox) FindEntryNrForSampleNr ¶

func (b *StscBox) FindEntryNrForSampleNr(sampleNr, lowEntryIdx uint32) uint32

FindEntryNrForSampleNr returns the entry where sampleNr belongs. lowEntryIdx is entry index (zero-based). The resulting entryNr is 0-based index.

func (*StscBox) GetChunk ¶

func (b *StscBox) GetChunk(chunkNr uint32) Chunk

GetChunk returns chunk for chunkNr (one-based).

func (*StscBox) GetContainingChunks ¶

func (b *StscBox) GetContainingChunks(startSampleNr, endSampleNr uint32) ([]Chunk, error)

GetContainingChunks returns chunks containing the sample interval including endSampleNr. startSampleNr and endSampleNr are 1-based.

func (*StscBox) GetSampleDescriptionID ¶

func (b *StscBox) GetSampleDescriptionID(chunkNr int) uint32

GetSampleDescriptionID returns the sample description ID from common or individual values for chunk. chunkNr is 1-based.

func (*StscBox) Info ¶

func (b *StscBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write specific box info to w

func (*StscBox) SetSingleSampleDescriptionID ¶

func (b *StscBox) SetSingleSampleDescriptionID(sampleDescriptionID uint32)

SetSingleSampleDescriptionID - use this for efficiency if all samples have same sample description

func (*StscBox) Size ¶

func (b *StscBox) Size() uint64

Size - box-specific size

func (*StscBox) Type ¶

func (b *StscBox) Type() string

Type box-specific type

type StscEntry ¶

type StscEntry struct {
	FirstChunk      uint32
	SamplesPerChunk uint32
	FirstSampleNr   uint32
}

type StsdBox ¶

type StsdBox struct {
	Version     byte
	Flags       uint32
	SampleCount uint32
	// AvcX is a pointer to box with name avc1 or avc3
	AvcX *VisualSampleEntryBox
	// HvcX is a pointer to a box with name hvc1 or hev1
	HvcX *VisualSampleEntryBox
	// VvcX is apointer to a box with name vvc1 or vvi1
	VvcX *VisualSampleEntryBox
	// Av01 is a pointer to a box with name av01
	Av01 *VisualSampleEntryBox
	// Avs3 is a pointer to a box with name avs3
	Avs3 *VisualSampleEntryBox
	// Encv is a pointer to a box with name encv
	Encv *VisualSampleEntryBox
	// VpXX is a pointer to a box with name vp08 or vp09 (VP8 or VP9 video)
	VpXX *VisualSampleEntryBox
	// Mp4a is a pointer to a box with name mp4a
	Mp4a *AudioSampleEntryBox
	// AC3 is a pointer to a box with name ac-3
	AC3 *AudioSampleEntryBox
	// EC3 is a pointer to a box with name ec-3
	EC3 *AudioSampleEntryBox
	// AC4 is a pointer to a box with name ac-4
	AC4 *AudioSampleEntryBox
	// Opus is a pointer to a box with name Opus
	Opus *AudioSampleEntryBox
	// MhXX is a pointer to an MPEG-H mha1, mha2, mh1, mh2 sample entry box
	MhXX *AudioSampleEntryBox
	// Enca is a pointer to a box with name enca
	Enca *AudioSampleEntryBox
	// Wvtt is a pointer to a WvttBox
	Wvtt *WvttBox
	// Stpp is a pointer to a StppBox
	Stpp *StppBox
	// Evte is a pointer to an EvteBox
	Evte     *EvteBox
	Children []Box
}

StsdBox - Sample Description Box (stsd - manatory) See ISO/IEC 14496-12 Section 8.5.2.2 Full Box + SampleCount All Children are sampleEntries

func NewStsdBox ¶

func NewStsdBox() *StsdBox

NewStsdBox - Generate a new empty stsd box

func (*StsdBox) AddChild ¶

func (s *StsdBox) AddChild(box Box)

AddChild - Add a child box, set relevant pointer, and update SampleCount

func (*StsdBox) Encode ¶

func (s *StsdBox) Encode(w io.Writer) error

Encode - box-specific encode of stsd - not a usual container

func (*StsdBox) EncodeSW ¶

func (s *StsdBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode of stsd - not a usual container

func (*StsdBox) GetBtrt ¶ added in v0.46.0

func (s *StsdBox) GetBtrt() *BtrtBox

GetBtrt returns the first BtrtBox found in StsdBox children.

func (*StsdBox) GetSampleDescription ¶

func (s *StsdBox) GetSampleDescription(index int) (Box, error)

GetSampleDescription - get one of multiple descriptions

func (*StsdBox) Info ¶

func (s *StsdBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*StsdBox) Size ¶

func (s *StsdBox) Size() uint64

Size - box-specific type

func (*StsdBox) Type ¶

func (s *StsdBox) Type() string

Type - box-specific type

type StssBox ¶

type StssBox struct {
	Version      byte
	Flags        uint32
	SampleNumber []uint32
}

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) Encode ¶

func (b *StssBox) Encode(w io.Writer) error

Encode - write box to w

func (*StssBox) EncodeSW ¶

func (b *StssBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*StssBox) EntryCount ¶

func (b *StssBox) EntryCount() uint32

EntryCount - number of sync samples

func (*StssBox) Info ¶

func (b *StssBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*StssBox) IsSyncSample ¶

func (b *StssBox) IsSyncSample(sampleNr uint32) (isSync bool)

IsSyncSample - check if sample (one-based) sampleNr is a sync sample

func (*StssBox) Size ¶

func (b *StssBox) Size() uint64

Size - box-specific size

func (*StssBox) Type ¶

func (b *StssBox) Type() string

Type - box-specific type

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) Encode ¶

func (b *StszBox) Encode(w io.Writer) error

Encode - write box to w

func (*StszBox) EncodeSW ¶

func (b *StszBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*StszBox) GetNrSamples ¶

func (b *StszBox) GetNrSamples() uint32

GetNrSamples - get number of sampples

func (*StszBox) GetSampleSize ¶

func (b *StszBox) GetSampleSize(i int) uint32

GetSampleSize returns the size (in bytes) of a sample

func (*StszBox) GetTotalSampleSize ¶

func (b *StszBox) GetTotalSampleSize(startNr, endNr uint32) (uint64, error)

GetTotalSampleSize - get total size of a range [startNr, endNr] of samples

func (*StszBox) Info ¶

func (b *StszBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*StszBox) Size ¶

func (b *StszBox) Size() uint64

Size - box-specific size

func (*StszBox) Type ¶

func (b *StszBox) Type() string

Type - box-specific type

type SttgBox ¶

type SttgBox struct {
	Settings string
}

SttgBox - CueSettingsBox (sttg)

func (*SttgBox) Encode ¶

func (b *SttgBox) Encode(w io.Writer) error

Encode - write box to w

func (*SttgBox) EncodeSW ¶

func (b *SttgBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*SttgBox) Info ¶

func (b *SttgBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*SttgBox) Size ¶

func (b *SttgBox) Size() uint64

Size - calculated size of box

func (*SttgBox) Type ¶

func (b *SttgBox) Type() string

Type - box-specific type

type SttsBox ¶

type SttsBox struct {
	Version         byte
	Flags           uint32
	SampleCount     []uint32
	SampleTimeDelta []uint32
}

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) Encode ¶

func (b *SttsBox) Encode(w io.Writer) error

Encode - write box to w

func (*SttsBox) EncodeSW ¶

func (b *SttsBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*SttsBox) GetDecodeTime ¶

func (b *SttsBox) GetDecodeTime(sampleNr uint32) (decTime uint64, dur uint32)

GetDecodeTime - decode time and duration for (one-based) sampleNr in track timescale

func (*SttsBox) GetDur ¶

func (b *SttsBox) GetDur(sampleNr uint32) (dur uint32)

GetDur - get dur for a specific sample

func (*SttsBox) GetSampleNrAtTime ¶

func (b *SttsBox) GetSampleNrAtTime(sampleStartTime uint64) (sampleNr uint32, err error)

GetSampleNrAtTime returns the 1-based sample number at or as soon as possible after time. Match a final single zero duration if present. If time is too big to reach, an error is returned. Time is calculated by summing up durations of previous samples

func (*SttsBox) GetTimeCode ¶

func (b *SttsBox) GetTimeCode(sample, timescale uint32) time.Duration

GetTimeCode - return the timecode (duration since the beginning of the media) of the beginning of a sample

func (*SttsBox) Info ¶

func (b *SttsBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*SttsBox) Size ¶

func (b *SttsBox) Size() uint64

Size - return calculated size

func (*SttsBox) Type ¶

func (b *SttsBox) Type() string

Type - return box type

type StypBox ¶

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

StypBox - Segment Type Box (styp)

func CreateStyp ¶

func CreateStyp() *StypBox

CreateStyp - Create an Styp box suitable for DASH/CMAF

func NewStyp ¶

func NewStyp(majorBrand string, minorVersion uint32, compatibleBrands []string) *StypBox

NewStyp - new styp box with parameters

func (*StypBox) AddCompatibleBrands ¶

func (b *StypBox) AddCompatibleBrands(compatibleBrands []string)

AddCompatibleBrands adds new compatible brands to Styp box.

func (*StypBox) CompatibleBrands ¶

func (b *StypBox) CompatibleBrands() []string

CompatibleBrands - slice of compatible brands (4 chars each)

func (*StypBox) Encode ¶

func (b *StypBox) Encode(w io.Writer) error

Encode - write box to w

func (*StypBox) EncodeSW ¶

func (b *StypBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*StypBox) Info ¶

func (b *StypBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write specific box info to w

func (*StypBox) MajorBrand ¶

func (b *StypBox) MajorBrand() string

MajorBrand - major brand (4 chars)

func (*StypBox) MinorVersion ¶

func (b *StypBox) MinorVersion() uint32

MinorVersion - minor version

func (*StypBox) Size ¶

func (b *StypBox) Size() uint64

Size - return calculated size

func (*StypBox) Type ¶

func (b *StypBox) Type() string

Type - return box type

type SubSamplePattern ¶

type SubSamplePattern struct {
	BytesOfClearData     uint16
	BytesOfProtectedData uint32
}

SubSamplePattern - pattern of subsample encryption

func AppendProtectRange ¶ added in v0.48.0

func AppendProtectRange(ssps []SubSamplePattern, nrClear, nrProtected uint32) []SubSamplePattern

AppendProtectRange appends a SubSamplePattern to a slice of SubSamplePattern, splitting into multiple if needed.

func GetAVCProtectRanges ¶ added in v0.40.0

func GetAVCProtectRanges(spsMap map[uint32]*avc.SPS, ppsMap map[uint32]*avc.PPS, sample []byte,
	scheme string) ([]SubSamplePattern, error)

GetAVCProtectRanges for common encryption from a sample with 4-byte NALU lengths. THe spsMap and ppsMap are only needed for CBCS mode. For scheme cenc, protection ranges must be a multiple of 16 bytes leaving header and some more in the clear For scheme cbcs, protection range must start after the slice header.

func GetHEVCProtectRanges ¶ added in v0.48.0

func GetHEVCProtectRanges(spsMap map[uint32]*hevc.SPS, ppsMap map[uint32]*hevc.PPS,
	sample []byte, scheme string) ([]SubSamplePattern, error)

type SubSegment ¶ added in v0.45.0

type SubSegment struct {
	Ranges []SubSegmentRange
}

SubSegment - subsegment data for SsixBox

type SubSegmentRange ¶ added in v0.45.0

type SubSegmentRange uint32

SubSegmentRange - range data for SubSegment

func NewSubSegmentRange ¶ added in v0.45.0

func NewSubSegmentRange(level uint8, rangeSize uint32) SubSegmentRange

NewSubSegmentRange - create new SubSegmentRange

func (SubSegmentRange) Level ¶ added in v0.45.0

func (s SubSegmentRange) Level() uint8

Level - return level

func (SubSegmentRange) RangeSize ¶ added in v0.45.0

func (s SubSegmentRange) RangeSize() uint32

RangeSize - return range size

type SubsBox ¶

type SubsBox struct {
	Version byte
	Flags   uint32
	Entries []SubsEntry
}

SubsBox - SubSampleInformationBox

func (*SubsBox) Encode ¶

func (b *SubsBox) Encode(w io.Writer) error

Encode - write box to w

func (*SubsBox) EncodeSW ¶

func (b *SubsBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*SubsBox) Info ¶

func (b *SubsBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - specificBoxLevels dump:1 gives details

func (*SubsBox) Size ¶

func (b *SubsBox) Size() uint64

Size - return calculated size

func (*SubsBox) Type ¶

func (b *SubsBox) Type() string

Type - return box type

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 TencBox ¶

type TencBox struct {
	Version                byte
	Flags                  uint32
	DefaultCryptByteBlock  byte
	DefaultSkipByteBlock   byte
	DefaultIsProtected     byte
	DefaultPerSampleIVSize byte
	DefaultKID             UUID
	// DefaultConstantIVSize  byte given by len(DefaultConstantIV)
	DefaultConstantIV []byte
}

TencBox - Track Encryption Box Defined in ISO/IEC 23001-7 Section 8.2

func (*TencBox) Encode ¶

func (b *TencBox) Encode(w io.Writer) error

Encode - write box to w

func (*TencBox) EncodeSW ¶

func (b *TencBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*TencBox) Info ¶

func (b *TencBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) (err error)

Info - write box info to w

func (*TencBox) Size ¶

func (b *TencBox) Size() uint64

Size - return calculated size

func (*TencBox) Type ¶

func (b *TencBox) Type() string

Type - return box type

type TfdtBox ¶

type TfdtBox struct {
	Version byte
	Flags   uint32
	// contains filtered or unexported fields
}

TfdtBox - Track Fragment Decode Time (tfdt)

Contained in : Track Fragment box (traf)

func CreateTfdt ¶

func CreateTfdt(baseMediaDecodeTime uint64) *TfdtBox

CreateTfdt - Create a new TfdtBox with baseMediaDecodeTime

func (*TfdtBox) BaseMediaDecodeTime ¶

func (t *TfdtBox) BaseMediaDecodeTime() uint64

BaseMediaDecodeTime is the base media decode time.

func (*TfdtBox) Encode ¶

func (t *TfdtBox) Encode(w io.Writer) error

Encode - write box to w

func (*TfdtBox) EncodeSW ¶

func (t *TfdtBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*TfdtBox) Info ¶

func (t *TfdtBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) (err error)

Info - write box info to w

func (*TfdtBox) SetBaseMediaDecodeTime ¶

func (t *TfdtBox) SetBaseMediaDecodeTime(bTime uint64)

SetBaseMediaDecodeTime sets base media decode time of TfdtBox.

func (*TfdtBox) Size ¶

func (t *TfdtBox) Size() uint64

Size - return calculated size

func (*TfdtBox) Type ¶

func (t *TfdtBox) Type() string

Type - return box type

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 ¶

func CreateTfhd(trackID uint32) *TfhdBox

CreateTfhd - Create a new TfdtBox with baseMediaDecodeTime

func (*TfhdBox) DefaultBaseIfMoof ¶

func (t *TfhdBox) DefaultBaseIfMoof() bool

DefaultBaseIfMoof - interpreted flags value

func (*TfhdBox) DurationIsEmpty ¶

func (t *TfhdBox) DurationIsEmpty() bool

DurationIsEmpty - interpreted flags value

func (*TfhdBox) Encode ¶

func (t *TfhdBox) Encode(w io.Writer) error

Encode - write box to w

func (*TfhdBox) EncodeSW ¶

func (t *TfhdBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*TfhdBox) HasBaseDataOffset ¶

func (t *TfhdBox) HasBaseDataOffset() bool

HasBaseDataOffset - interpreted flags value

func (*TfhdBox) HasDefaultSampleDuration ¶

func (t *TfhdBox) HasDefaultSampleDuration() bool

HasDefaultSampleDuration - interpreted flags value

func (*TfhdBox) HasDefaultSampleFlags ¶

func (t *TfhdBox) HasDefaultSampleFlags() bool

HasDefaultSampleFlags - interpreted flags value

func (*TfhdBox) HasDefaultSampleSize ¶

func (t *TfhdBox) HasDefaultSampleSize() bool

HasDefaultSampleSize - interpreted flags value

func (*TfhdBox) HasSampleDescriptionIndex ¶

func (t *TfhdBox) HasSampleDescriptionIndex() bool

HasSampleDescriptionIndex - interpreted flags value

func (*TfhdBox) Info ¶

func (t *TfhdBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write specific box information

func (*TfhdBox) Size ¶

func (t *TfhdBox) Size() uint64

Size - returns calculated size

func (*TfhdBox) Type ¶

func (t *TfhdBox) Type() string

Type - returns box type

type TfraBox ¶

type TfraBox struct {
	Version               byte
	Flags                 uint32
	TrackID               uint32
	LengthSizeOfTrafNum   byte
	LengthSizeOfTrunNum   byte
	LengthSizeOfSampleNum byte
	Entries               []TfraEntry
}

TfraBox - Track Fragment Random Access Box (tfra) Contained it MfraBox (mfra)

func (*TfraBox) Encode ¶

func (b *TfraBox) Encode(w io.Writer) error

Encode - write box to w

func (*TfraBox) EncodeSW ¶

func (b *TfraBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*TfraBox) FindEntry ¶ added in v0.39.0

func (b *TfraBox) FindEntry(moofStart uint64) *TfraEntry

FindEntry - find entry for moofStart. Return nil if not found

func (*TfraBox) Info ¶

func (b *TfraBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - box-specific info. More for level 1

func (*TfraBox) Size ¶

func (b *TfraBox) Size() uint64

Size - return calculated size

func (*TfraBox) Type ¶

func (b *TfraBox) Type() string

Type - return box type

type TfraEntry ¶

type TfraEntry struct {
	Time         uint64
	MoofOffset   uint64
	TrafNumber   uint32
	TrunNumber   uint32
	SampleNumber uint32
}

TfraEntry - reference as used inside TfraBox

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.

func CreateTkhd ¶

func CreateTkhd() *TkhdBox

CreateTkhd - create tkhd box with common settings

func (*TkhdBox) CreationTimeS ¶ added in v0.46.0

func (b *TkhdBox) CreationTimeS() int64

CraetionTimeS returns the creation time in seconds since Jan 1, 1970

func (*TkhdBox) Encode ¶

func (b *TkhdBox) Encode(w io.Writer) error

Encode - write box to w

func (*TkhdBox) EncodeSW ¶

func (b *TkhdBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*TkhdBox) Info ¶

func (b *TkhdBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*TkhdBox) ModificationTimeS ¶ added in v0.46.0

func (b *TkhdBox) ModificationTimeS() int64

ModificationTimeS returns the modification time in seconds since Jan 1, 1970

func (*TkhdBox) SetCreationTimeS ¶ added in v0.46.0

func (b *TkhdBox) SetCreationTimeS(unixTimeS int64)

SetCreationTimeS sets the creation time from seconds since Jan 1, 1970

func (*TkhdBox) SetModificationTimeS ¶ added in v0.46.0

func (b *TkhdBox) SetModificationTimeS(unixTimeS int64)

SetModificationTimeS sets the modification time from seconds since Jan 1, 1970

func (*TkhdBox) Size ¶

func (b *TkhdBox) Size() uint64

Size - calculated size of box

func (*TkhdBox) Type ¶

func (b *TkhdBox) Type() string

Type - box type

type TopBoxInfo ¶

type TopBoxInfo struct {
	// Type - box type
	Type string
	// Size - box size
	Size uint64
	// StartPos - where in file does box start
	StartPos uint64
}

TopBoxInfo - information about a top-level box

func GetTopBoxInfoList ¶

func GetTopBoxInfoList(rs io.ReadSeeker, stopBoxType string) ([]TopBoxInfo, error)

GetTopBoxInfoList - get top boxes until stopBoxType or end of file

type TrafBox ¶

type TrafBox struct {
	Tfhd     *TfhdBox
	Tfdt     *TfdtBox
	Saiz     *SaizBox
	Saio     *SaioBox
	Sbgp     *SbgpBox
	Sgpd     *SgpdBox
	Senc     *SencBox
	UUIDSenc *UUIDBox // A PIFF box of subtype senc
	Trun     *TrunBox // The first TrunBox
	Truns    []*TrunBox
	Children []Box
}

TrafBox - Track Fragment Box (traf)

Contained in : Movie Fragment Box (moof)

func (*TrafBox) AddChild ¶

func (t *TrafBox) AddChild(child Box) error

AddChild - add child box

func (*TrafBox) ContainsSencBox ¶

func (t *TrafBox) ContainsSencBox() (ok, parsed bool)

ContainsSencBox - is there a senc box in traf and is it parsed If not parsed, call ParseReadSenc to parse it

func (*TrafBox) Encode ¶

func (t *TrafBox) Encode(w io.Writer) error

Encode - write box to w

func (*TrafBox) EncodeSW ¶

func (b *TrafBox) EncodeSW(sw bits.SliceWriter) error

Encode - write minf container to sw

func (*TrafBox) GetChildren ¶

func (t *TrafBox) GetChildren() []Box

GetChildren - list of child boxes

func (*TrafBox) Info ¶

func (t *TrafBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*TrafBox) OptimizeTfhdTrun ¶

func (t *TrafBox) OptimizeTfhdTrun() error

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 (t *TrafBox) ParseReadSenc(defaultIVSize byte, moofStartPos uint64) error

ParseReadSenc makes a second round to parse a senc box previously read

func (*TrafBox) RemoveEncryptionBoxes ¶

func (t *TrafBox) RemoveEncryptionBoxes() uint64

RemoveEncryptionBoxes - remove encryption boxes and return number of bytes removed

func (*TrafBox) Size ¶

func (t *TrafBox) Size() uint64

Size - return calculated size

func (*TrafBox) Type ¶

func (t *TrafBox) Type() string

Type - return box type

type TrakBox ¶

type TrakBox struct {
	Tkhd     *TkhdBox
	Edts     *EdtsBox
	Mdia     *MdiaBox
	Children []Box
}

TrakBox - Track Box (tkhd - mandatory)

Contained in : Movie Box (moov)

A media file can contain one or more tracks.

func CreateEmptyTrak ¶

func CreateEmptyTrak(trackID, timeScale uint32, mediaType, language string) *TrakBox

CreateEmptyTrak - create a full trak-tree for an empty (fragmented) track with no samples or stsd content

func NewTrakBox ¶

func NewTrakBox() *TrakBox

NewTrakBox - Make a new empty TrakBox

func (*TrakBox) AddChild ¶

func (t *TrakBox) AddChild(child Box)

AddChild - Add a child box

func (*TrakBox) Encode ¶

func (t *TrakBox) Encode(w io.Writer) error

Encode - write trak container to w

func (*TrakBox) EncodeSW ¶

func (b *TrakBox) EncodeSW(sw bits.SliceWriter) error

Encode - write trak container to sw

func (*TrakBox) GetChildren ¶

func (t *TrakBox) GetChildren() []Box

GetChildren - list of child boxes

func (*TrakBox) GetNrSamples ¶

func (t *TrakBox) GetNrSamples() uint32

GetNrSamples - get number of samples for this track defined in the parent moov box.

func (*TrakBox) GetRangesForSampleInterval ¶

func (t *TrakBox) GetRangesForSampleInterval(startSampleNr, endSampleNr uint32) ([]DataRange, error)

GetRangesForSampleInterval - get ranges inside file for sample range [startSampleNr, endSampleNr]

func (*TrakBox) GetSampleData ¶

func (t *TrakBox) GetSampleData(startSampleNr, endSampleNr uint32) ([]Sample, error)

GetSampleData - get sample metadata for a specific interval of samples defined in moov. If going outside the range of available samples, an error is returned.

func (*TrakBox) Info ¶

func (t *TrakBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box info to w

func (*TrakBox) SetAACDescriptor ¶

func (t *TrakBox) SetAACDescriptor(objType byte, samplingFrequency int) error

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) SetAC3Descriptor ¶

func (t *TrakBox) SetAC3Descriptor(dac3 *Dac3Box) error

SetAC3Descriptor - Modify a TrakBox by adding AC-3 SampleDescriptor

func (*TrakBox) SetAVCDescriptor ¶

func (t *TrakBox) SetAVCDescriptor(sampleDescriptorType string, spsNALUs, ppsNALUs [][]byte, includePS bool) error

SetAVCDescriptor - Set AVC SampleDescriptor based on SPS and PPS

func (*TrakBox) SetEC3Descriptor ¶

func (t *TrakBox) SetEC3Descriptor(dec3 *Dec3Box) error

SetEC3Descriptor - Modify a TrakBox by adding EC-3 SampleDescriptor

func (*TrakBox) SetHEVCDescriptor ¶

func (t *TrakBox) SetHEVCDescriptor(sampleDescriptorType string, vpsNALUs, spsNALUs, ppsNALUs, seiNALUs [][]byte, includePS bool) error

SetHEVCDescriptor sets HEVC SampleDescriptor based on descriptorType, VPS, SPS, PPS and SEI.

func (*TrakBox) SetStppDescriptor ¶

func (t *TrakBox) SetStppDescriptor(namespace, schemaLocation, auxiliaryMimeTypes string) error

SetStppDescriptor - add stpp box with utf8-lists namespace, schemaLocation and auxiliaryMimeType The utf8-lists have space-separated items, but no zero-termination

func (*TrakBox) SetWvttDescriptor ¶

func (t *TrakBox) SetWvttDescriptor(config string) error

SetWvttDescriptor - Set wvtt descriptor with a vttC box. config should start with WEBVTT or be empty.

func (*TrakBox) Size ¶

func (t *TrakBox) Size() uint64

Size - calculated size of box

func (*TrakBox) Type ¶

func (t *TrakBox) Type() string

Type - box type

type TrefBox ¶

type TrefBox struct {
	Children []Box
}

TrefBox - // TrackReferenceBox - ISO/IEC 14496-12 Ed. 9 Sec. 8.3

func (*TrefBox) AddChild ¶

func (b *TrefBox) AddChild(box Box)

AddChild - Add a child box

func (*TrefBox) Encode ¶

func (b *TrefBox) Encode(w io.Writer) error

Encode - write minf container to w

func (*TrefBox) EncodeSW ¶

func (b *TrefBox) EncodeSW(sw bits.SliceWriter) error

Encode - write minf container to sw

func (*TrefBox) GetChildren ¶

func (b *TrefBox) GetChildren() []Box

GetChildren - list of child boxes

func (*TrefBox) Info ¶

func (b *TrefBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*TrefBox) Size ¶

func (b *TrefBox) Size() uint64

Size - calculated size of box

func (*TrefBox) Type ¶

func (b *TrefBox) Type() string

Type - box type

type TrefTypeBox ¶

type TrefTypeBox struct {
	Name     string
	TrackIDs []uint32
}

TrefTypeBox - TrackReferenceTypeBox - ISO/IEC 14496-12 Ed. 9 Sec. 8.3 Name can be one of hint, cdsc, font, hind, vdep, vplx, subt (ISO/IEC 14496-12) dpnd, ipir, mpod, sync (ISO/IEC 14496-14)

func (*TrefTypeBox) Encode ¶

func (t *TrefTypeBox) Encode(w io.Writer) error

Encode - write box to w

func (*TrefTypeBox) EncodeSW ¶

func (b *TrefTypeBox) EncodeSW(sw bits.SliceWriter) error

Encode - write box to sw

func (*TrefTypeBox) Info ¶

func (b *TrefTypeBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*TrefTypeBox) Size ¶

func (b *TrefTypeBox) Size() uint64

Size - calculated size of box

func (*TrefTypeBox) Type ¶

func (b *TrefTypeBox) Type() string

Type - box type

type TrepBox ¶

type TrepBox struct {
	Version  byte
	Flags    uint32
	TrackID  uint32
	Children []Box
}

TrepBox - Track Extension Properties Box (trep) Contained in mvex

func (*TrepBox) AddChild ¶

func (b *TrepBox) AddChild(child Box)

AddChild - Add a child box and update SampleCount

func (*TrepBox) Encode ¶

func (b *TrepBox) Encode(w io.Writer) error

Encode - box-specific encode of stsd - not a usual container

func (*TrepBox) EncodeSW ¶

func (b *TrepBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW- box-specific encode of stsd - not a usual container

func (*TrepBox) Info ¶

func (b *TrepBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*TrepBox) Size ¶

func (b *TrepBox) Size() uint64

Size - box-specific type

func (*TrepBox) Type ¶

func (b *TrepBox) Type() string

Type - box-specific type

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(trackID uint32) *TrexBox

CreateTrex - create trex box with trackID

func (*TrexBox) Encode ¶

func (b *TrexBox) Encode(w io.Writer) error

Encode - write box to w

func (*TrexBox) EncodeSW ¶

func (b *TrexBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*TrexBox) Info ¶

func (b *TrexBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*TrexBox) Size ¶

func (b *TrexBox) Size() uint64

Size - return calculated size

func (*TrexBox) Type ¶

func (b *TrexBox) Type() string

Type - return box type

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 Fragment Box (traf)

func CreateTrun ¶

func CreateTrun(writeOrderNr uint32) *TrunBox

CreateTrun - create a TrunBox for filling up with samples. writeOrderNr is only used for multi-trun offsets.

func (*TrunBox) AddFullSample ¶

func (t *TrunBox) AddFullSample(s *FullSample)

AddFullSample - add Sample part of FullSample

func (*TrunBox) AddSample ¶

func (t *TrunBox) AddSample(s Sample)

AddSample - add a Sample

func (*TrunBox) AddSampleDefaultValues ¶

func (t *TrunBox) AddSampleDefaultValues(tfhd *TfhdBox, trex *TrexBox) (totalDur uint64)

AddSampleDefaultValues - add values from tfhd and trex boxes if needed Return total duration

func (*TrunBox) AddSamples ¶

func (t *TrunBox) AddSamples(s []Sample)

AddSamples - add a a slice of Sample

func (*TrunBox) CommonSampleDuration ¶ added in v0.39.0

func (t *TrunBox) CommonSampleDuration(defaultSampleDuration uint32) uint32

CommonSampleDuration returns the common duration if all samples have the same duration, otherwise 0.

func (*TrunBox) Duration ¶

func (t *TrunBox) Duration(defaultSampleDuration uint32) uint64

Duration returns the total duration of all samples given defaultSampleDuration

func (*TrunBox) Encode ¶

func (t *TrunBox) Encode(w io.Writer) error

Encode - write box to w

func (*TrunBox) EncodeSW ¶

func (t *TrunBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*TrunBox) FirstSampleFlags ¶

func (t *TrunBox) FirstSampleFlags() (flags uint32, present bool)

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) GetSampleNrForRelativeTime ¶

func (t *TrunBox) GetSampleNrForRelativeTime(deltaTime uint64, defaultSampleDuration uint32) (uint32, error)

GetSampleNrForRelativeTime - get sample number for exact relative time (calculated from summing durations)

func (*TrunBox) GetSampleRange ¶

func (t *TrunBox) GetSampleRange(startSampleNr, endSampleNr uint32) []Sample

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 ¶

func (t *TrunBox) GetSamples() []Sample

GetSamples - get all trun sample data To fill missing individual values from tfhd and trex defaults, call AddSampleDefaultValues() before this call

func (*TrunBox) HasDataOffset ¶

func (t *TrunBox) HasDataOffset() bool

HasDataOffset - interpreted dataOffsetPresent flag

func (*TrunBox) HasFirstSampleFlags ¶

func (t *TrunBox) HasFirstSampleFlags() bool

HasFirstSampleFlags - interpreted firstSampleFlagsPresent flag

func (*TrunBox) HasSampleCompositionTimeOffset ¶

func (t *TrunBox) HasSampleCompositionTimeOffset() bool

HasSampleCompositionTimeOffset - interpreted sampleCompositionTimeOffset flag

func (*TrunBox) HasSampleDuration ¶

func (t *TrunBox) HasSampleDuration() bool

HasSampleDuration - interpreted sampleDurationPresent flag

func (*TrunBox) HasSampleFlags ¶

func (t *TrunBox) HasSampleFlags() bool

HasSampleFlags - interpreted sampleFlagsPresent flag

func (*TrunBox) HasSampleSize ¶

func (t *TrunBox) HasSampleSize() bool

HasSampleSize - interpreted sampleSizePresent flag

func (*TrunBox) Info ¶

func (t *TrunBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - specificBoxLevels trun:1 gives details

func (*TrunBox) RemoveFirstSampleFlags ¶

func (t *TrunBox) RemoveFirstSampleFlags()

RemoveFirstSampleFlags - remove firstSampleFlags and its indicator

func (*TrunBox) SampleCount ¶

func (t *TrunBox) SampleCount() uint32

SampleCount - return how many samples are defined

func (*TrunBox) SetFirstSampleFlags ¶

func (t *TrunBox) SetFirstSampleFlags(flags uint32)

SetFirstSampleFlags - set firstSampleFlags and bit indicating its presence

func (*TrunBox) Size ¶

func (t *TrunBox) Size() uint64

Size - return calculated size

func (*TrunBox) SizeOfData ¶

func (t *TrunBox) SizeOfData() (totalSize uint64)

SizeOfData - size of mediasamples in bytes

func (*TrunBox) Type ¶

func (t *TrunBox) Type() string

Type - return box type

type URLBox ¶

type URLBox struct {
	Version           byte
	Flags             uint32
	Location          string // Zero-terminated string
	NoLocation        bool
	NoZeroTermination bool
}

URLBox - DataEntryUrlBox ('url ')

Contained in : DrefBox (dref

func CreateURLBox ¶

func CreateURLBox() *URLBox

CreateURLBox - Create a self-referencing URL box

func (*URLBox) Encode ¶

func (b *URLBox) Encode(w io.Writer) error

Encode - write box to w

func (*URLBox) EncodeSW ¶

func (b *URLBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*URLBox) Info ¶

func (b *URLBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write specific box information

func (*URLBox) Size ¶

func (b *URLBox) Size() uint64

Size - return calculated size

func (*URLBox) Type ¶

func (b *URLBox) Type() string

Type - return box type

type UUID ¶

type UUID []byte

UUID - 16-byte KeyID or SystemID

func NewUUIDFromString ¶ added in v0.48.0

func NewUUIDFromString(h string) (UUID, error)

NewUUIDFromString creates a UUID from a hexadecimal, uuid-string or base64 string

func (UUID) Equal ¶ added in v0.48.0

func (u UUID) Equal(a UUID) bool

Equal compares with other UUID

func (UUID) String ¶

func (u UUID) String() string

type UUIDBox ¶

type UUIDBox struct {
	Tfxd           *TfxdData
	Tfrf           *TfrfData
	Senc           *SencBox
	StartPos       uint64
	UnknownPayload []byte
	// contains filtered or unexported fields
}

UUIDBox - Used as container for MSS boxes tfxd and tfrf For unknown UUID, the data after the UUID is stored as UnknownPayload

func NewTfrfBox ¶ added in v0.48.0

func NewTfrfBox(fragmentCount byte, fragmentAbsoluteTimes, fragmentAbsoluteDurations []uint64) *UUIDBox

NewTrfrfBox creates a new TfrfBox with values. fragmentCount is the number of fragments, andb both fragmentAbsoluteTimes and fragmentAbsoluteDurations must be slices of that length.

func NewTfxdBox ¶ added in v0.48.0

func NewTfxdBox(fragmentAbsoluteTime, fragmentAbsoluteDuration uint64) *UUIDBox

NewTfxdBox creates a new TfxdBox with values.

func (*UUIDBox) Encode ¶

func (b *UUIDBox) Encode(w io.Writer) error

Encode - write box to w

func (*UUIDBox) EncodeSW ¶

func (b *UUIDBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*UUIDBox) Info ¶

func (b *UUIDBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - box-specific info

func (*UUIDBox) SetUUID ¶

func (u *UUIDBox) SetUUID(uuid string) (err error)

UUID - Set UUID from string corresponding to 16 bytes. The input should be a UUID-formatted hex string, plain hex or baset64 encoded.

func (*UUIDBox) Size ¶

func (b *UUIDBox) Size() uint64

Size - return calculated size including tfxd/tfrf

func (*UUIDBox) SubType ¶

func (b *UUIDBox) SubType() string

SubType - interpret the UUID as a known sub type or unknown

func (*UUIDBox) Type ¶

func (b *UUIDBox) Type() string

Type - return box type

func (*UUIDBox) UUID ¶

func (u *UUIDBox) UUID() string

UUID - Return UUID as formatted string

type UdtaBox ¶

type UdtaBox struct {
	Children []Box
}

UdtaBox - User Data Box is a container for User Data

Contained in : moov, trak, moof, or traf

func (*UdtaBox) AddChild ¶

func (b *UdtaBox) AddChild(box Box)

AddChild - Add a child box

func (*UdtaBox) Encode ¶

func (b *UdtaBox) Encode(w io.Writer) error

Encode - write udta container to w

func (*UdtaBox) EncodeSW ¶

func (b *UdtaBox) EncodeSW(sw bits.SliceWriter) error

Encode - write udta container to sw

func (*UdtaBox) GetChildren ¶

func (b *UdtaBox) GetChildren() []Box

GetChildren - list of child boxes

func (*UdtaBox) Info ¶

func (b *UdtaBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*UdtaBox) Size ¶

func (b *UdtaBox) Size() uint64

Size - calculated size of box

func (*UdtaBox) Type ¶

func (b *UdtaBox) Type() string

Type - box type

type UnknownBox ¶

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

UnknownBox - box that we don't know how to parse

func CreateUnknownBox ¶ added in v0.48.0

func CreateUnknownBox(name string, size uint64, payload []byte) *UnknownBox

CreateUnknownBox creates an unknown box. Set the size to match the payload size + header size to get a well-formed box.

func (*UnknownBox) Encode ¶

func (b *UnknownBox) Encode(w io.Writer) error

Encode - write box to w

func (*UnknownBox) EncodeSW ¶

func (b *UnknownBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*UnknownBox) Info ¶

func (b *UnknownBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*UnknownBox) Payload ¶ added in v0.48.0

func (b *UnknownBox) Payload() []byte

Payload returns the (non-decoded) payload.

func (*UnknownBox) Size ¶

func (b *UnknownBox) Size() uint64

Size - return calculated size

func (*UnknownBox) Type ¶

func (b *UnknownBox) Type() string

Type - return box type

type UnknownSampleGroupEntry ¶

type UnknownSampleGroupEntry struct {
	Name   string
	Length uint32
	Data   []byte
}

UnknownSampleGroupEntry - unknown or not implemented SampleGroupEntry

func (*UnknownSampleGroupEntry) Encode ¶

Encode SampleGroupEntry to SliceWriter

func (*UnknownSampleGroupEntry) Info ¶

func (s *UnknownSampleGroupEntry) Info(w io.Writer, specificBoxLevels, indent, indentStep string) (err error)

Info - write box info to w

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)

type VisualSampleEntryBox ¶

type VisualSampleEntryBox struct {
	DataReferenceIndex uint16
	Width              uint16
	Height             uint16
	Horizresolution    uint32
	Vertresolution     uint32
	FrameCount         uint16
	CompressorName     string
	AvcC               *AvcCBox
	HvcC               *HvcCBox
	Av1C               *Av1CBox
	Av3c               *Av3cBox
	VvcC               *VvcCBox
	VppC               *VppCBox
	Btrt               *BtrtBox
	Clap               *ClapBox
	Pasp               *PaspBox
	Sinf               *SinfBox
	SmDm               *SmDmBox
	CoLL               *CoLLBox
	Children           []Box
	TrailingBytes      []byte
	// contains filtered or unexported fields
}

VisualSampleEntryBox Video Sample Description box (avc1/avc3/hvc1/hev1...)

func CreateVisualSampleEntryBox ¶

func CreateVisualSampleEntryBox(name string, width, height uint16, sampleEntry Box) *VisualSampleEntryBox

CreateVisualSampleEntryBox creates a new VisualSampleEntry such as avc1, avc3, hev1, hvc1, vvc1, vvi1

func NewVisualSampleEntryBox ¶

func NewVisualSampleEntryBox(name string) *VisualSampleEntryBox

NewVisualSampleEntryBox creates new empty box with an appropriate name such as avc1

func (*VisualSampleEntryBox) AddChild ¶

func (b *VisualSampleEntryBox) AddChild(child Box)

AddChild adds a child box and sets pointer to common types

func (*VisualSampleEntryBox) ConvertAvc3ToAvc1 ¶

func (b *VisualSampleEntryBox) ConvertAvc3ToAvc1(spss [][]byte, ppss [][]byte) error

ConvertAvc3ToAvc1 converts visual sample entry box type and insert SPS and PPS parameter sets

func (*VisualSampleEntryBox) ConvertHev1ToHvc1 ¶

func (b *VisualSampleEntryBox) ConvertHev1ToHvc1(vpss [][]byte, spss [][]byte, ppss [][]byte) error

ConvertHev1ToHvc1 converts visual sample entry box type and insert VPS, SPS, and PPS parameter sets

func (*VisualSampleEntryBox) Encode ¶

func (b *VisualSampleEntryBox) Encode(w io.Writer) error

Encode writes box to w

func (*VisualSampleEntryBox) EncodeSW ¶

func (b *VisualSampleEntryBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW writes box to sw

func (*VisualSampleEntryBox) Info ¶

func (b *VisualSampleEntryBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info writes box-specific information

func (*VisualSampleEntryBox) RemoveEncryption ¶

func (b *VisualSampleEntryBox) RemoveEncryption() (*SinfBox, error)

RemoveEncryption removes sinf box and set type to unencrypted type

func (*VisualSampleEntryBox) SetType ¶

func (b *VisualSampleEntryBox) SetType(name string)

SetType sets the type (name) of the box

func (*VisualSampleEntryBox) Size ¶

func (b *VisualSampleEntryBox) Size() uint64

Size - return calculated size

func (*VisualSampleEntryBox) Type ¶

func (b *VisualSampleEntryBox) Type() string

Type returns box type

type VlabBox ¶

type VlabBox struct {
	SourceLabel string
}

VlabBox - WebVTTSourceLabelBox (vlab)

func (*VlabBox) Encode ¶

func (b *VlabBox) Encode(w io.Writer) error

Encode - write box to w

func (*VlabBox) EncodeSW ¶

func (b *VlabBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*VlabBox) Info ¶

func (b *VlabBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*VlabBox) Size ¶

func (b *VlabBox) Size() uint64

Size - calculated size of box

func (*VlabBox) Type ¶

func (b *VlabBox) Type() string

Type - box-specific type

type VmhdBox ¶

type VmhdBox struct {
	Version      byte
	Flags        uint32
	GraphicsMode uint16
	OpColor      [3]uint16
}

VmhdBox - Video Media Header Box (vhmd - mandatory for video tracks)

Contained in : Media Information Box (minf)

func CreateVmhd ¶

func CreateVmhd() *VmhdBox

CreateVmhd - Create Video Media Header Box

func (*VmhdBox) Encode ¶

func (b *VmhdBox) Encode(w io.Writer) error

Encode - write box to w

func (*VmhdBox) EncodeSW ¶

func (b *VmhdBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*VmhdBox) Info ¶

func (b *VmhdBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*VmhdBox) Size ¶

func (b *VmhdBox) Size() uint64

Size - calculated size of box

func (*VmhdBox) Type ¶

func (b *VmhdBox) Type() string

Type - box-specific type

type VppCBox ¶ added in v0.48.0

type VppCBox struct {
	Version                 byte
	Flags                   uint32
	Profile                 byte
	Level                   byte
	BitDepth                byte
	ChromaSubsampling       byte
	VideoFullRangeFlag      byte
	ColourPrimaries         byte
	TransferCharacteristics byte
	MatrixCoefficients      byte
	CodecInitData           []byte
}

VppCBox - VP Codec Configuration Box (vpcC) The VPCodecConfigurationBox contains decoder configuration information formatted according to the VP codec configuration syntax.

func (*VppCBox) Encode ¶ added in v0.48.0

func (b *VppCBox) Encode(w io.Writer) error

Encode - write box to w

func (*VppCBox) EncodeSW ¶ added in v0.48.0

func (b *VppCBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*VppCBox) Info ¶ added in v0.48.0

func (b *VppCBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box info to w

func (*VppCBox) Size ¶ added in v0.48.0

func (b *VppCBox) Size() uint64

Size - calculated size of box

func (*VppCBox) Type ¶ added in v0.48.0

func (b *VppCBox) Type() string

Type - box type

type VsidBox ¶

type VsidBox struct {
	SourceID uint32
}

VsidBox - CueSourceIDBox (vsid)

func (*VsidBox) Encode ¶

func (b *VsidBox) Encode(w io.Writer) error

Encode - write box to w

func (*VsidBox) EncodeSW ¶

func (b *VsidBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*VsidBox) Info ¶

func (b *VsidBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*VsidBox) Size ¶

func (b *VsidBox) Size() uint64

Size - calculated size of box

func (*VsidBox) Type ¶

func (b *VsidBox) Type() string

Type - box-specific type

type VttCBox ¶

type VttCBox struct {
	Config string
}

VttCBox - WebVTTConfigurationBox (vttC)

func (*VttCBox) Encode ¶

func (b *VttCBox) Encode(w io.Writer) error

Encode - write box to w

func (*VttCBox) EncodeSW ¶

func (b *VttCBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*VttCBox) Info ¶

func (b *VttCBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*VttCBox) Size ¶

func (b *VttCBox) Size() uint64

Size - calculated size of box

func (*VttCBox) Type ¶

func (b *VttCBox) Type() string

Type - box-specific type

type VttaBox ¶

type VttaBox struct {
	CueAdditionalText string
}

VttaBox - VTTAdditionalTextBox (vtta) (corresponds to NOTE in WebVTT)

func (*VttaBox) Encode ¶

func (b *VttaBox) Encode(w io.Writer) error

Encode - write box to w

func (*VttaBox) EncodeSW ¶

func (b *VttaBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*VttaBox) Info ¶

func (b *VttaBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*VttaBox) Size ¶

func (b *VttaBox) Size() uint64

Size - calculated size of box

func (*VttaBox) Type ¶

func (b *VttaBox) Type() string

Type - box-specific type

type VttcBox ¶

type VttcBox struct {
	Vsid     *VsidBox
	Iden     *IdenBox
	Ctim     *CtimBox
	Sttg     *SttgBox
	Payl     *PaylBox
	Children []Box
}

VttcBox - VTTCueBox (vttc)

func (*VttcBox) AddChild ¶

func (b *VttcBox) AddChild(child Box)

AddChild - Add a child box

func (*VttcBox) Encode ¶

func (b *VttcBox) Encode(w io.Writer) error

Encode - write mvex container to w

func (*VttcBox) EncodeSW ¶

func (b *VttcBox) EncodeSW(sw bits.SliceWriter) error

Encode - write vttc container to sw

func (*VttcBox) GetChildren ¶

func (b *VttcBox) GetChildren() []Box

GetChildren - list of child boxes

func (*VttcBox) Info ¶

func (b *VttcBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*VttcBox) Size ¶

func (b *VttcBox) Size() uint64

Size - return calculated size

func (*VttcBox) Type ¶

func (b *VttcBox) Type() string

Type - return box type

type VtteBox ¶

type VtteBox struct {
}

VtteBox - VTTEmptyBox (vtte)

func (*VtteBox) Encode ¶

func (b *VtteBox) Encode(w io.Writer) error

Encode - write box to w

func (*VtteBox) EncodeSW ¶

func (b *VtteBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - box-specific encode to slicewriter

func (*VtteBox) Info ¶

func (b *VtteBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*VtteBox) Size ¶

func (b *VtteBox) Size() uint64

Size - calculated size of box

func (*VtteBox) Type ¶

func (b *VtteBox) Type() string

Type - box-specific type

type VvcCBox ¶ added in v0.50.0

type VvcCBox struct {
	Version byte
	Flags   uint32
	vvc.DecConfRec
}

VvcCBox - VVC Configuration Box (ISO/IEC 14496-15) Contains one VVCDecoderConfigurationRecord

func CreateVvcC ¶ added in v0.50.0

func CreateVvcC(naluArrays []vvc.NaluArray) (*VvcCBox, error)

CreateVvcC creates a VvcC box

Example ¶
package main

import (
	"github.com/Eyevinn/mp4ff/mp4"
	"github.com/Eyevinn/mp4ff/vvc"
)

func main() {
	// Create NALU arrays for VVC parameter sets
	vpsNalu := []byte{0x00, 0x79, 0x00, 0xad} // Example VPS NALU
	spsNalu := []byte{0x00, 0x81, 0x00, 0x00} // Example SPS NALU
	ppsNalu := []byte{0x00, 0x82, 0x00, 0x01} // Example PPS NALU

	naluArrays := []vvc.NaluArray{
		vvc.NewNaluArray(true, vvc.NALU_VPS, [][]byte{vpsNalu}),
		vvc.NewNaluArray(true, vvc.NALU_SPS, [][]byte{spsNalu}),
		vvc.NewNaluArray(true, vvc.NALU_PPS, [][]byte{ppsNalu}),
	}

	// Create VvcC box with the NALU arrays
	vvcCBox, err := mp4.CreateVvcC(naluArrays)
	if err != nil {
		panic(err)
	}

	// Use the VvcC box
	_ = vvcCBox.Type() // "vvcC"
	_ = vvcCBox.Size() // Box size in bytes
}

func (*VvcCBox) Encode ¶ added in v0.50.0

func (b *VvcCBox) Encode(w io.Writer) error

Encode - write box to w

func (*VvcCBox) EncodeSW ¶ added in v0.50.0

func (b *VvcCBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - write box to sw

func (*VvcCBox) Info ¶ added in v0.50.0

func (b *VvcCBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - box-specific Info

func (*VvcCBox) Size ¶ added in v0.50.0

func (b *VvcCBox) Size() uint64

Size - return calculated size

func (*VvcCBox) Type ¶ added in v0.50.0

func (b *VvcCBox) Type() string

Type - return box type

type WvttBox ¶

type WvttBox struct {
	VttC               *VttCBox
	Vlab               *VlabBox
	Btrt               *BtrtBox
	Children           []Box
	DataReferenceIndex uint16
}

WvttBox - WVTTSampleEntry (wvtt) Extends PlainTextSampleEntry which extends SampleEntry

func NewWvttBox ¶

func NewWvttBox() *WvttBox

NewWvttBox - Create new empty wvtt box

func (*WvttBox) AddChild ¶

func (b *WvttBox) AddChild(child Box)

AddChild - add a child box

func (*WvttBox) Encode ¶

func (b *WvttBox) Encode(w io.Writer) error

Encode - write box to w

func (*WvttBox) EncodeSW ¶

func (b *WvttBox) EncodeSW(sw bits.SliceWriter) error

EncodeSW - write box to w

func (*WvttBox) Info ¶

func (b *WvttBox) Info(w io.Writer, specificBoxLevels, indent, indentStep string) error

Info - write box-specific information

func (*WvttBox) Size ¶

func (b *WvttBox) Size() uint64

Size - return calculated size

func (*WvttBox) Type ¶

func (b *WvttBox) Type() string

Type - return box type

Jump to

Keyboard shortcuts

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