Versions in this module Expand all Collapse all v0 v0.2.0 Jul 1, 2026 Changes in this version + const TfhdBaseDataOffsetPresent + const TfhdDefaultBaseIsMoof + const TfhdDefaultSampleDurationPresent + const TfhdDefaultSampleFlagsPresent + const TfhdDefaultSampleSizePresent + const TfhdDurationIsEmpty + const TfhdSampleDescriptionIndexPresent + const TrunDataOffsetPresent + const TrunFirstSampleFlagsPresent + const TrunSampleCompositionTimeOffsetPresent + const TrunSampleDurationPresent + const TrunSampleFlagsPresent + const TrunSampleSizePresent + var ErrBoxTooLarge = errors.New("mp4: box size exceeds 4GB limit") + var TypeAv01 = BoxType + var TypeAv1C = BoxType + var TypeBtrt = BoxType + var TypeEmsg = BoxType + var TypeFree = BoxType + var TypePasp = BoxType + var TypeSidx = BoxType + var TypeSkip = BoxType + var TypeStyp = BoxType + func IsContainerBox(t BoxType) bool + func IsFullBox(t BoxType) bool + func ReadAvcC(data []byte) string + func ReadEsdsCodec(data []byte) string type AudioSampleEntry + ChildOffset int + func ReadAudioSampleEntry(data []byte) AudioSampleEntry + type Co64Iter struct + func NewCo64Iter(data []byte) Co64Iter + func (it *Co64Iter) Count() uint32 + func (it *Co64Iter) Next() (uint64, bool) + type CttsEntry struct + Count uint32 + Offset int32 + type CttsIter struct + func NewCttsIter(data []byte, version uint8) CttsIter + func (it *CttsIter) Count() uint32 + func (it *CttsIter) Next() (CttsEntry, bool) type ElstEntry + MediaRateFrac int16 + MediaRateInt int16 + SegmentDuration uint64 + type ElstIter struct + func NewElstIter(data []byte, version uint8) ElstIter + func (it *ElstIter) Count() uint32 + func (it *ElstIter) Next() (ElstEntry, bool) + type FtypInfo struct + Compatible [][4]byte + MajorBrand [4]byte + MinorVersion uint32 + func ReadFtyp(data []byte) FtypInfo + type Reader struct + func NewReader(buf []byte) Reader + func (r *Reader) Data() []byte + func (r *Reader) DataOffset() int + func (r *Reader) Depth() int + func (r *Reader) Enter() + func (r *Reader) EntryCount() uint32 + func (r *Reader) Exit() + func (r *Reader) Flags() uint32 + func (r *Reader) HeaderSize() int + func (r *Reader) Next() bool + func (r *Reader) Offset() int + func (r *Reader) RawBox() []byte + func (r *Reader) ReadElst() (mediaTime int64, ok bool) + func (r *Reader) ReadHdlr() [4]byte + func (r *Reader) ReadHdlrName() string + func (r *Reader) ReadMdhd() (timescale uint32, duration uint64, language uint16) + func (r *Reader) ReadMehd() (fragmentDuration uint64) + func (r *Reader) ReadMfhd() (sequenceNumber uint32) + func (r *Reader) ReadMvhd() (timescale uint32, duration uint64, nextTrackId uint32) + func (r *Reader) ReadTfdt() (baseMediaDecodeTime uint64) + func (r *Reader) ReadTfhd() (trackId uint32) + func (r *Reader) ReadTkhd() (trackId uint32, duration uint64, width, height uint32) + func (r *Reader) ReadTrex() (...) + func (r *Reader) Size() uint64 + func (r *Reader) Skip(n int) + func (r *Reader) Type() BoxType + func (r *Reader) Version() uint8 + type ScanEntry struct + HeaderSize int + Offset int64 + Size int64 + Type BoxType + func (e ScanEntry) DataOffset() int64 + func (e ScanEntry) DataSize() int64 + type Scanner struct + func NewScanner(rs io.ReadSeeker) Scanner + func (s *Scanner) Entry() ScanEntry + func (s *Scanner) Err() error + func (s *Scanner) Next() bool + func (s *Scanner) ReadBody(buf []byte) error + func (s *Scanner) ReadBox(buf []byte) error + func (s *Scanner) Reset(rs io.ReadSeeker) + type SidxEntry struct + ReferenceType bool + ReferencedSize uint32 + SAPType uint8 + StartsWithSAP bool + SubsegDuration uint32 + type StscEntry struct + FirstChunk uint32 + SampleDescriptionId uint32 + SamplesPerChunk uint32 + type StscIter struct + func NewStscIter(data []byte) StscIter + func (it *StscIter) Count() uint32 + func (it *StscIter) Next() (StscEntry, bool) + type StszIter struct + func NewStszIter(data []byte) StszIter + func (it *StszIter) Count() uint32 + func (it *StszIter) Next() (uint32, bool) + type SttsEntry struct + Count uint32 + Duration uint32 + type SttsIter struct + func NewSttsIter(data []byte) SttsIter + func (it *SttsIter) Count() uint32 + func (it *SttsIter) Next() (SttsEntry, bool) type TrunEntry + CompositionTimeOffset int32 + Duration uint32 + Flags uint32 + Size uint32 + type TrunIter struct + func NewTrunIter(data []byte, flags uint32) TrunIter + func (it *TrunIter) Count() uint32 + func (it *TrunIter) DataOffset() int32 + func (it *TrunIter) FirstSampleFlags() uint32 + func (it *TrunIter) Next() (TrunEntry, bool) + type Uint32Iter struct + func NewUint32Iter(data []byte) Uint32Iter + func (it *Uint32Iter) Count() uint32 + func (it *Uint32Iter) Next() (uint32, bool) type VisualSampleEntry + ChildOffset int + func ReadVisualSampleEntry(data []byte) VisualSampleEntry + type Writer struct + func NewWriter(buf []byte) Writer + func (w *Writer) Bytes() []byte + func (w *Writer) EndBox() + func (w *Writer) Err() error + func (w *Writer) Len() int + func (w *Writer) Reset() + func (w *Writer) StartBox(t BoxType) + func (w *Writer) StartFullBox(t BoxType, version uint8, flags uint32) + func (w *Writer) Write(p []byte) (int, error) + func (w *Writer) WriteAudioSampleEntry(dataRefIdx, channelCount, sampleSize uint16, sampleRate uint32) + func (w *Writer) WriteCo64(entries []uint64) + func (w *Writer) WriteCtts(entries []CttsEntry) + func (w *Writer) WriteDref() + func (w *Writer) WriteElst(entries []ElstEntry) + func (w *Writer) WriteFtyp(brand [4]byte, brandVersion uint32, compat [][4]byte) + func (w *Writer) WriteHdlr(handlerType [4]byte, name string) + func (w *Writer) WriteMdhd(timescale uint32, duration uint64, language uint16) + func (w *Writer) WriteMehd(fragmentDuration uint64) + func (w *Writer) WriteMfhd(sequenceNumber uint32) + func (w *Writer) WriteMvhd(timescale uint32, duration uint64, nextTrackId uint32) + func (w *Writer) WriteSidx(trackID uint32, timescale uint32, earliestPTS uint64, firstOffset uint64, ...) + func (w *Writer) WriteSmhd() + func (w *Writer) WriteStco(entries []uint32) + func (w *Writer) WriteStsc(entries []StscEntry) + func (w *Writer) WriteStss(entries []uint32) + func (w *Writer) WriteStsz(sampleSize uint32, entries []uint32) + func (w *Writer) WriteStts(entries []SttsEntry) + func (w *Writer) WriteStyp(brand [4]byte, brandVersion uint32, compat [][4]byte) + func (w *Writer) WriteTfdt(baseMediaDecodeTime uint64) + func (w *Writer) WriteTfhd(flags, trackId, defaultDuration, defaultSize, defaultFlags uint32) + func (w *Writer) WriteTkhd(flags uint32, trackId uint32, duration uint64, width, height uint32) + func (w *Writer) WriteTrex(trackId, descIdx, defDuration, defSize, defFlags uint32) + func (w *Writer) WriteTrun(flags uint32, dataOffset int32, firstSampleFlags uint32, entries []TrunEntry) + func (w *Writer) WriteVisualSampleEntry(dataRefIdx, width, height, frameCount, depth uint16, compressor string) + func (w *Writer) WriteVmhd() v0.1.0 Feb 12, 2026 Changes in this version + var TypeAvc1 = newBoxType("avc1") + var TypeAvcC = newBoxType("avcC") + var TypeCo64 = newBoxType("co64") + var TypeCslg = newBoxType("cslg") + var TypeCtts = newBoxType("ctts") + var TypeDinf = newBoxType("dinf") + var TypeDref = newBoxType("dref") + var TypeEdts = newBoxType("edts") + var TypeElng = newBoxType("elng") + var TypeElst = newBoxType("elst") + var TypeEsds = newBoxType("esds") + var TypeFtyp = newBoxType("ftyp") + var TypeHdlr = newBoxType("hdlr") + var TypeHmhd = newBoxType("hmhd") + var TypeLeva = newBoxType("leva") + var TypeMdat = newBoxType("mdat") + var TypeMdhd = newBoxType("mdhd") + var TypeMdia = newBoxType("mdia") + var TypeMehd = newBoxType("mehd") + var TypeMeta = newBoxType("meta") + var TypeMfhd = newBoxType("mfhd") + var TypeMinf = newBoxType("minf") + var TypeMoof = newBoxType("moof") + var TypeMoov = newBoxType("moov") + var TypeMp4a = newBoxType("mp4a") + var TypeMvex = newBoxType("mvex") + var TypeMvhd = newBoxType("mvhd") + var TypeNmhd = newBoxType("nmhd") + var TypePadb = newBoxType("padb") + var TypeSaio = newBoxType("saio") + var TypeSaiz = newBoxType("saiz") + var TypeSbgp = newBoxType("sbgp") + var TypeSdtp = newBoxType("sdtp") + var TypeSgpd = newBoxType("sgpd") + var TypeSmhd = newBoxType("smhd") + var TypeStbl = newBoxType("stbl") + var TypeStco = newBoxType("stco") + var TypeStdp = newBoxType("stdp") + var TypeSthd = newBoxType("sthd") + var TypeStsc = newBoxType("stsc") + var TypeStsd = newBoxType("stsd") + var TypeStsh = newBoxType("stsh") + var TypeStss = newBoxType("stss") + var TypeStsz = newBoxType("stsz") + var TypeStts = newBoxType("stts") + var TypeStz2 = newBoxType("stz2") + var TypeSubs = newBoxType("subs") + var TypeTfdt = newBoxType("tfdt") + var TypeTfhd = newBoxType("tfhd") + var TypeTkhd = newBoxType("tkhd") + var TypeTraf = newBoxType("traf") + var TypeTrak = newBoxType("trak") + var TypeTref = newBoxType("tref") + var TypeTrex = newBoxType("trex") + var TypeTrgr = newBoxType("trgr") + var TypeTrun = newBoxType("trun") + var TypeUdta = newBoxType("udta") + var TypeVmhd = newBoxType("vmhd") + func Encode(box *Box, buf []byte, offset int) (int, error) + func EncodeToBuf(box *Box, buf []byte) ([]byte, error) + func EncodeToBytes(box *Box) ([]byte, error) + func EncodingLength(box *Box) uint64 + type AudioSampleEntry struct + ChannelCount uint16 + Children []*Box + DataReferenceIndex uint16 + SampleRate uint32 + SampleSize uint16 + type AvcC struct + Buffer []byte + MimeCodec string + type Box struct + Audio *AudioSampleEntry + AvcC *AvcC + Buffer []byte + Children map[BoxType][]*Box + Co64 *Co64 + Ctts *Ctts + Dref *DrefBox + Elst *Elst + Esds *Esds + Flags uint32 + Ftyp *Ftyp + HasFullBox bool + Hdlr *Hdlr + Mdat *Mdat + Mdhd *Mdhd + Mehd *Mehd + Mfhd *Mfhd + Mvhd *Mvhd + OtherBoxes []*Box + Size uint64 + Smhd *Smhd + Stco *Stco + Stsc *Stsc + Stsd *Stsd + Stsz *Stsz + Stts *Stts + Tfdt *Tfdt + Tfhd *Tfhd + Tkhd *Tkhd + Trex *Trex + Trun *Trun + Type BoxType + Version uint8 + Visual *VisualSampleEntry + Vmhd *Vmhd + func Decode(buf []byte, start, end int) (*Box, error) + func (b *Box) Child(t BoxType) *Box + func (b *Box) ChildList(t BoxType) []*Box + type BoxType [4]byte + func (t BoxType) String() string + type CTTSEntry struct + CompositionOffset int32 + Count uint32 + type Co64 struct + Entries []uint64 + type Ctts struct + Entries []CTTSEntry + type DrefBox struct + Entries []DrefEntry + type DrefEntry struct + Buf []byte + Type [4]byte + type Elst struct + Entries []ElstEntry + type ElstEntry struct + MediaRate [4]byte + MediaTime int32 + TrackDuration uint32 + type Esds struct + Buffer []byte + MimeCodec string + type Ftyp struct + Brand [4]byte + BrandVersion uint32 + CompatibleBrands [][4]byte + type Hdlr struct + HandlerType [4]byte + Name string + type Headers struct + ContentLen int + Flags uint32 + HeaderSize int + Size uint64 + Type BoxType + Version uint8 + func ReadHeaders(buf []byte, start, end int) (Headers, error) + type Mdat struct + Buffer []byte + ContentLength int + type Mdhd struct + CTime [8]byte + Duration uint64 + Language uint16 + MTime [8]byte + Quality uint16 + TimeScale uint32 + V1 bool + type Mehd struct + FragmentDuration uint32 + type Mfhd struct + SequenceNumber uint32 + type Mvhd struct + CTime [4]byte + CurrentTime uint32 + Duration uint32 + MTime [4]byte + Matrix [36]byte + NextTrackId uint32 + PosterTime uint32 + PreferredRate [4]byte + PreferredVolume [2]byte + PreviewDuration uint32 + PreviewTime uint32 + SelectionDuration uint32 + SelectionTime uint32 + TimeScale uint32 + type STSCEntry struct + FirstChunk uint32 + SampleDescriptionId uint32 + SamplesPerChunk uint32 + type STTSEntry struct + Count uint32 + Duration uint32 + type Smhd struct + Balance uint16 + type Stco struct + Entries []uint32 + type Stsc struct + Entries []STSCEntry + type Stsd struct + Entries []*Box + type Stsz struct + Entries []uint32 + SampleSize uint32 + type Stts struct + Entries []STTSEntry + type Tfdt struct + BaseMediaDecodeTime uint32 + type Tfhd struct + TrackId uint32 + type Tkhd struct + AlternateGroup uint16 + CTime [4]byte + Duration uint32 + Layer uint16 + MTime [4]byte + Matrix [36]byte + TrackHeight uint32 + TrackId uint32 + TrackWidth uint32 + Volume uint16 + type Trex struct + DefaultSampleDescriptionIndex uint32 + DefaultSampleDuration uint32 + DefaultSampleFlags uint32 + DefaultSampleSize uint32 + TrackId uint32 + type Trun struct + DataOffset int32 + Entries []TrunEntry + type TrunEntry struct + SampleCompositionTimeOffset int32 + SampleDuration uint32 + SampleFlags uint32 + SampleSize uint32 + type VisualSampleEntry struct + Children []*Box + CompressorName string + DataReferenceIndex uint16 + Depth uint16 + FrameCount uint16 + HResolution uint32 + Height uint16 + VResolution uint32 + Width uint16 + type Vmhd struct + GraphicsMode uint16 + Opcolor [3]uint16