mp4

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2015 License: MIT Imports: 7 Imported by: 0

README

mp4

wercker status

A encoder/decoder class, io.Reader and io.Writer compatible, usable for HTTP pseudo streaming

For the complete MP4 specifications, see http://standards.iso.org/ittf/PubliclyAvailableStandards/c061988_ISO_IEC_14496-12_2012.zip and http://standards.iso.org/ittf/PubliclyAvailableStandards/c061989_ISO_IEC_15444-12_2012.zip

Doc

See http://godoc.org/github.com/jfbus/mp4 and http://godoc.org/github.com/jfbus/mp4/filter

Warning

Some boxes can have multiple formats (ctts, elst, tkhd, ...). Only the version 0 of those boxes is currently decoded (see https://github.com/jfbus/mp4/issues/7). Version 1 will be supported, and this will break a few things (e.g. some uint32 attributes will switch to uint64).

CLI

A CLI can be found in cli/mp4tool.go

It can :

  • Display info about a media
mp4tool info file.mp4
  • Copy a video (decode it and reencode it to another file, useful for debugging)
mp4tool copy in.mp4 out.mp4
  • Generate a clip
mp4tool clip --start 10 --duration 30 in.mp4 out.mp4

(if you really want to generate a clip, you should use ffmpeg, you will ge better results)

LICENSE

See LICENSE

Documentation

Overview

Package mp4 implements encoding/decoding of MP4 media.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUnknownBoxType is for unknown box types
	ErrUnknownBoxType = errors.New("unknown box type")
	// ErrTruncatedHeader is when a head gets truncated
	ErrTruncatedHeader = errors.New("truncated header")
)

Functions

func AddHeaderSize

func AddHeaderSize(size uint64) uint64

func AppendError

func AppendError(err1 error, err2 error) error

AppendError appends one error to the other and doing the right thing if one or more of them are nil

func EncodeHeader

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

EncodeHeader encodes a box header to a writer

func HeaderSizeFor

func HeaderSizeFor(size uint64) uint64

func RemoveHeaderSize

func RemoveHeaderSize(size uint64) uint64

Types

type BadFormatErr added in v0.1.2

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

BadFormatErr is type of error when an unexpected box appears in unexpected places

func (*BadFormatErr) Error added in v0.1.2

func (b *BadFormatErr) Error() string

type Box

type Box interface {
	Type() string
	Size() uint64
	Encode(w io.Writer) error
}

Box an atom

func DecodeBox

func DecodeBox(h BoxHeader, r io.Reader) (Box, error)

DecodeBox decodes a box

func DecodeChpl

func DecodeChpl(r io.Reader, size uint64) (Box, error)

func DecodeCo64

func DecodeCo64(r io.Reader, size uint64) (Box, error)

DecodeCo64 does what it says on the tin

func DecodeContainer

func DecodeContainer(r io.Reader, size uint64) ([]Box, error)

DecodeContainer decodes a container box

func DecodeCtts

func DecodeCtts(r io.Reader, size uint64) (Box, error)

func DecodeDinf

func DecodeDinf(r io.Reader, size uint64) (Box, error)

func DecodeDref

func DecodeDref(r io.Reader, size uint64) (Box, error)

func DecodeEdts

func DecodeEdts(r io.Reader, size uint64) (Box, error)

func DecodeElst

func DecodeElst(r io.Reader, size uint64) (Box, error)

func DecodeFree

func DecodeFree(r io.Reader, size uint64) (Box, error)

func DecodeFtyp

func DecodeFtyp(r io.Reader, size uint64) (Box, error)

Decode decodes the ftyp box

func DecodeGmhd

func DecodeGmhd(r io.Reader, size uint64) (Box, error)

func DecodeHdlr

func DecodeHdlr(r io.Reader, size uint64) (Box, error)

func DecodeIods

func DecodeIods(r io.Reader, size uint64) (Box, error)

func DecodeMdat

func DecodeMdat(r io.Reader, size uint64) (Box, error)

func DecodeMdhd

func DecodeMdhd(r io.Reader, size uint64) (Box, error)

DecodeMdhd decodes mdhd

func DecodeMdia

func DecodeMdia(r io.Reader, size uint64) (Box, error)

func DecodeMeta

func DecodeMeta(r io.Reader, size uint64) (Box, error)

func DecodeMinf

func DecodeMinf(r io.Reader, size uint64) (Box, error)

func DecodeMoov

func DecodeMoov(r io.Reader, size uint64) (Box, error)

func DecodeMvhd

func DecodeMvhd(r io.Reader, size uint64) (Box, error)

DecodeMvhd - decodes

func DecodeName

func DecodeName(r io.Reader, size uint64) (Box, error)

func DecodeSbgp

func DecodeSbgp(r io.Reader, size uint64) (Box, error)

func DecodeSdtp

func DecodeSdtp(r io.Reader, size uint64) (Box, error)

func DecodeSgpd

func DecodeSgpd(r io.Reader, size uint64) (Box, error)

func DecodeSmhd

func DecodeSmhd(r io.Reader, size uint64) (Box, error)

func DecodeStbl

func DecodeStbl(r io.Reader, size uint64) (Box, error)

DecodeStbl decodes stbl

func DecodeStco

func DecodeStco(r io.Reader, size uint64) (Box, error)

DecodeStco does what it says on the tin

func DecodeStsc

func DecodeStsc(r io.Reader, size uint64) (Box, error)

func DecodeStsd

func DecodeStsd(r io.Reader, size uint64) (Box, error)

func DecodeStss

func DecodeStss(r io.Reader, size uint64) (Box, error)

func DecodeStsz

func DecodeStsz(r io.Reader, size uint64) (Box, error)

DecodeStsz - decodes

func DecodeStts

func DecodeStts(r io.Reader, size uint64) (Box, error)

func DecodeTkhd

func DecodeTkhd(r io.Reader, size uint64) (Box, error)

DecodeTkhd te

func DecodeTrak

func DecodeTrak(r io.Reader, size uint64) (Box, error)

func DecodeTref

func DecodeTref(r io.Reader, size uint64) (Box, error)

func DecodeUdta

func DecodeUdta(r io.Reader, size uint64) (Box, error)

func DecodeVmhd

func DecodeVmhd(r io.Reader, size uint64) (Box, error)

type BoxHeader

type BoxHeader struct {
	Type string
	Size uint64
}

BoxHeader The header of a box

func DecodeHeader

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

DecodeHeader decodes a box header (size + box type)

type ChplBox

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

Chpl Box (apple)

Status: not decoded

func (*ChplBox) Encode

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

func (*ChplBox) Size

func (b *ChplBox) Size() uint64

func (*ChplBox) Type

func (b *ChplBox) Type() string

type Co64Box

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

Co64Box is Chunk Offset Box (co64 - mandatory)

Contained in : Sample Table box (stbl)

Status: decoded

The table contains the offsets (starting at the beginning of the file) for each chunk of data for the current track. A chunk contains samples, the table defining the allocation of samples to each chunk is stsc.

func (*Co64Box) Dump

func (b *Co64Box) Dump()

Dump s the box

func (*Co64Box) Encode

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

Encode encode to the provided writer

func (*Co64Box) Size

func (b *Co64Box) Size() uint64

Size returns the size of the box

func (*Co64Box) Type

func (b *Co64Box) Type() string

Type returns co64

type CttsBox

type CttsBox struct {
	Version      byte
	Flags        [3]byte
	SampleCount  []uint32
	SampleOffset []uint32 // int32 for version 1
}

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

Contained in: Sample Table Box (stbl)

Status: version 0 decoded. version 1 uses int32 for offsets

func (*CttsBox) Encode

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

Encode encodes

func (*CttsBox) Size

func (b *CttsBox) Size() uint64

Size returns the size of ctts

func (*CttsBox) Type

func (b *CttsBox) Type() string

Type returns ctts

type DinfBox

type DinfBox struct {
	Dref *DrefBox
}

Data Information Box (dinf - mandatory)

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

Status : decoded

func (*DinfBox) Encode

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

func (*DinfBox) Size

func (b *DinfBox) Size() uint64

func (*DinfBox) Type

func (b *DinfBox) Type() string

type DrefBox

type DrefBox struct {
	Version byte
	Flags   [3]byte
	// contains filtered or unexported fields
}

Data Reference Box (dref - mandatory)

Contained id: Data Information Box (dinf)

Status: not decoded

Defines the location of the media data. If the data for the track is located in the same file it contains nothing useful.

func (*DrefBox) Encode

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

func (*DrefBox) Size

func (b *DrefBox) Size() uint64

func (*DrefBox) Type

func (b *DrefBox) Type() string

type EdtsBox

type EdtsBox struct {
	Elst *ElstBox
}

Edit Box (edts - optional)

Contained in: Track Box ("trak")

Status: decoded

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

func (*EdtsBox) Dump

func (b *EdtsBox) Dump()

func (*EdtsBox) Encode

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

func (*EdtsBox) Size

func (b *EdtsBox) Size() uint64

func (*EdtsBox) Type

func (b *EdtsBox) Type() string

type ElstBox

type ElstBox struct {
	Version                             byte
	Flags                               [3]byte
	SegmentDuration, MediaTime          []uint32 // should be uint32/int32 for version 0 and uint64/int32 for version 1
	MediaRateInteger, MediaRateFraction []uint16 // should be int16
}

ElstBox - Edit List Box (elst - optional)

Contained in : Edit Box (edts)

Status: version 0 decoded. version 1 not supported

func (*ElstBox) Dump

func (b *ElstBox) Dump()

Dump dumps the elst box

func (*ElstBox) Encode

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

Encode encodes the elst box

func (*ElstBox) Size

func (b *ElstBox) Size() uint64

Size retruns the size of ElstBox

func (*ElstBox) Type

func (b *ElstBox) Type() string

Type returns elst

type Fixed16

type Fixed16 uint16

Fixed16 is 8.8 fixed point number

func (Fixed16) String

func (f Fixed16) String() string

type Fixed32

type Fixed32 uint32

Fixed32 is 16.16 fixed point number

func (Fixed32) String

func (f Fixed32) String() string

type FreeBox

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

File Type Box (ftyp - mandatory)

Status: decoded

func (*FreeBox) Encode

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

func (*FreeBox) Size

func (b *FreeBox) Size() uint64

func (*FreeBox) Type

func (b *FreeBox) Type() string

type FtypBox

type FtypBox struct {
	MajorBrand       string
	MinorVersion     []byte
	CompatibleBrands []string
}

FtypBox - File Type Box (ftyp - mandatory)

Status: decoded

func (*FtypBox) Dump

func (b *FtypBox) Dump()

func (*FtypBox) Encode

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

func (*FtypBox) Size

func (b *FtypBox) Size() uint64

func (*FtypBox) Type

func (b *FtypBox) Type() string

type GmhdBox

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

Gmhd Box (apple)

Status: not decoded

func (*GmhdBox) Encode

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

func (*GmhdBox) Size

func (b *GmhdBox) Size() uint64

func (*GmhdBox) Type

func (b *GmhdBox) Type() string

type HdlrBox

type HdlrBox struct {
	Version     byte
	Flags       [3]byte
	PreDefined  uint32
	HandlerType string
	Name        string
}

Handler Reference Box (hdlr - mandatory)

Contained in: Media Box (mdia) or Meta Box (meta)

Status: decoded

This box describes the type of data contained in the trak.

HandlerType can be : "vide" (video track), "soun" (audio track), "hint" (hint track), "meta" (timed Metadata track), "auxv" (auxiliary video track).

func (*HdlrBox) Encode

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

func (*HdlrBox) Size

func (b *HdlrBox) Size() uint64

func (*HdlrBox) Type

func (b *HdlrBox) Type() string

type IodsBox

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

Object Descriptor Container Box (iods - optional)

Contained in : Movie Box (‘moov’)

Status: not decoded

func (*IodsBox) Encode

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

func (*IodsBox) Size

func (b *IodsBox) Size() uint64

func (*IodsBox) Type

func (b *IodsBox) Type() string

type MP4

type MP4 struct {
	Ftyp *FtypBox
	Moov *MoovBox
	Mdat *MdatBox
	// contains filtered or unexported fields
}

MP4 -A MPEG-4 media

A MPEG-4 media contains three main boxes :

ftyp : the file type box
moov : the movie box (meta-data)
mdat : the media data (chunks and samples)

Other boxes can also be present (pdin, moof, mfra, free, ...), but are not decoded.

func Decode

func Decode(rr RangeReader) (*MP4, error)

Decode decodes a media from a ReadSeeker

func (*MP4) AudioVolume

func (m *MP4) AudioVolume() float64

AudioVolume returns the audio volume of the first audio trak

func (*MP4) Boxes

func (m *MP4) Boxes() []Box

Boxes lists the top-level boxes from a media

func (*MP4) Dump

func (m *MP4) Dump()

Dump displays some information about a media

func (*MP4) Duration

func (m *MP4) Duration() time.Duration

Duration calculates the duration of the media from the mvhd box

func (*MP4) Encode

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

Encode encodes a media to a Writer

func (*MP4) Size

func (m *MP4) Size() (size uint64)

Size returns the size of the MP4

func (*MP4) VideoDimensions

func (m *MP4) VideoDimensions() (int, int)

VideoDimensions returns the dimesnions of the first video trak

type MdatBox

type MdatBox struct {
	ContentSize uint64
	Offset      uint64 // offset of the begging of the file
}

Media Data Box (mdat - optional)

Status: not decoded

The mdat box contains media chunks/samples.

It is not read, only the io.Reader is stored, and will be used to Encode (io.Copy) the box to a io.Writer.

func (*MdatBox) Encode

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

func (*MdatBox) Size

func (b *MdatBox) Size() uint64

func (*MdatBox) Type

func (b *MdatBox) Type() string

type MdhdBox

type MdhdBox struct {
	Version          byte
	Flags            [3]byte
	CreationTime     uint64
	ModificationTime uint64
	Timescale        uint32
	Duration         uint64
	Language         uint16
}

MdhdBox - Media Header Box (mdhd - mandatory)

Contained in : Media Box (mdia)

Status : only version 0 is decoded. version 1 is not supported

Timescale defines the timescale used for tracks. Language is a ISO-639-2/T language code stored as 1bit padding + [3]int5

func (*MdhdBox) Dump

func (b *MdhdBox) Dump()

Dump dumps the mdhd

func (*MdhdBox) Encode

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

Encode encodes

func (*MdhdBox) Size

func (b *MdhdBox) Size() uint64

Size returns the size of the mdhd

func (*MdhdBox) Type

func (b *MdhdBox) Type() string

Type returns mdhd

type MdiaBox

type MdiaBox struct {
	Mdhd *MdhdBox
	Hdlr *HdlrBox
	Minf *MinfBox
}

Media Box (mdia - mandatory)

Contained in : Track Box (trak)

Status: decoded

Contains all information about the media data.

func (*MdiaBox) Dump

func (b *MdiaBox) Dump()

func (*MdiaBox) Encode

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

func (*MdiaBox) Size

func (b *MdiaBox) Size() uint64

func (*MdiaBox) Type

func (b *MdiaBox) Type() string

type MetaBox

type MetaBox struct {
	Version byte
	Flags   [3]byte
	// contains filtered or unexported fields
}

Meta Box (meta - optional)

Status: not decoded

func (*MetaBox) Encode

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

func (*MetaBox) Size

func (b *MetaBox) Size() uint64

func (*MetaBox) Type

func (b *MetaBox) Type() string

type MinfBox

type MinfBox struct {
	Vmhd *VmhdBox
	Smhd *SmhdBox
	Stbl *StblBox
	Dinf *DinfBox
	Hdlr *HdlrBox
	Gmhd *GmhdBox
}

Media Information Box (minf - mandatory)

Contained in : Media Box (mdia)

Status: partially decoded (hmhd - hint tracks - and nmhd - null media - are ignored)

func (*MinfBox) Dump

func (b *MinfBox) Dump()

func (*MinfBox) Encode

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

func (*MinfBox) Size

func (b *MinfBox) Size() uint64

func (*MinfBox) Type

func (b *MinfBox) Type() string

type MoovBox

type MoovBox struct {
	Mvhd *MvhdBox
	Iods *IodsBox
	Trak []*TrakBox
	Udta *UdtaBox
}

Movie Box (moov - mandatory)

Status: partially decoded (anything other than mvhd, iods, trak or udta is ignored)

Contains all meta-data. To be able to stream a file, the moov box should be placed before the mdat box.

func (*MoovBox) Dump

func (b *MoovBox) Dump()

func (*MoovBox) Encode

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

func (*MoovBox) Size

func (b *MoovBox) Size() uint64

func (*MoovBox) Type

func (b *MoovBox) Type() string

type MvhdBox

type MvhdBox struct {
	Version          byte
	Flags            [3]byte
	CreationTime     uint64
	ModificationTime uint64
	Timescale        uint32
	Duration         uint64
	NextTrackID      uint32
	Rate             Fixed32
	Volume           Fixed16
	Matrix           []byte
}

MvhdBox - Movie Header Box (mvhd - mandatory)

Contained in : Movie Box (‘moov’)

Status: version 0 is partially decoded. version 1 is not supported

Contains all media information (duration, ...).

Duration is measured in "time units", and timescale defines the number of time units per second.

Only version 0 is decoded.

func (*MvhdBox) Dump

func (b *MvhdBox) Dump()

Dump dumps

func (*MvhdBox) Encode

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

Encode encodes

func (*MvhdBox) Size

func (b *MvhdBox) Size() uint64

Size returns the size of the mvhd

func (*MvhdBox) Type

func (b *MvhdBox) Type() string

Type return mvhd

type NameBox

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

Name Box

Status: not decoded

func (*NameBox) Encode

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

func (*NameBox) Size

func (b *NameBox) Size() uint64

func (*NameBox) Type

func (b *NameBox) Type() string

type RangeReader

type RangeReader interface {
	RangeRead(start, length uint64) (io.ReadCloser, error)
}

RangeReader can be used to get ReadClose for a given range

type SbgpBox

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

Sbgp Box

Status: not decoded

func (*SbgpBox) Encode

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

func (*SbgpBox) Size

func (b *SbgpBox) Size() uint64

func (*SbgpBox) Type

func (b *SbgpBox) Type() string

type SdtpBox

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

Sdtp Box

Status: not decoded

func (*SdtpBox) Encode

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

func (*SdtpBox) Size

func (b *SdtpBox) Size() uint64

func (*SdtpBox) Type

func (b *SdtpBox) Type() string

type SgpdBox

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

Sgpd Box

Status: not decoded

func (*SgpdBox) Encode

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

func (*SgpdBox) Size

func (b *SgpdBox) Size() uint64

func (*SgpdBox) Type

func (b *SgpdBox) Type() string

type SmhdBox

type SmhdBox struct {
	Version byte
	Flags   [3]byte
	Balance uint16 // should be int16
}

Sound Media Header Box (smhd - mandatory for sound tracks)

Contained in : Media Information Box (minf)

Status: decoded

func (*SmhdBox) Encode

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

func (*SmhdBox) Size

func (b *SmhdBox) Size() uint64

func (*SmhdBox) Type

func (b *SmhdBox) Type() string

type StblBox

type StblBox struct {
	Stsd *StsdBox
	Stts *SttsBox
	Stss *StssBox
	Stsc *StscBox
	Stsz *StszBox
	Stco *StcoBox
	Co64 *Co64Box
	Ctts *CttsBox
}

StblBox - Sample Table Box (stbl - mandatory)

Contained in : Media Information Box (minf)

Status: partially decoded (anything other than stsd, stts, stsc, stss, stsz, stco, ctts is ignored)

The table contains all information relevant to data samples (times, chunks, sizes, ...)

func (*StblBox) Dump

func (b *StblBox) Dump()

Dump dumps

func (*StblBox) Encode

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

Encode encodes

func (*StblBox) Size

func (b *StblBox) Size() uint64

Size returns size

func (*StblBox) Type

func (b *StblBox) Type() string

Type returns stbl

type StcoBox

type StcoBox struct {
	Version     byte
	Flags       [3]byte
	ChunkOffset []uint32
}

StcoBox is Chunk Offset Box (stco - mandatory)

Contained in : Sample Table box (stbl)

Status: decoded

This is the 32bits version of the box, the 64bits version (co64) is not decoded.

The table contains the offsets (starting at the beginning of the file) for each chunk of data for the current track. A chunk contains samples, the table defining the allocation of samples to each chunk is stsc.

func (*StcoBox) Dump

func (b *StcoBox) Dump()

Dump s the box

func (*StcoBox) Encode

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

Encode encode to the provided writer

func (*StcoBox) Size

func (b *StcoBox) Size() uint64

Size returns the size of the box

func (*StcoBox) Type

func (b *StcoBox) Type() string

Type returns stco

type StscBox

type StscBox struct {
	Version             byte
	Flags               [3]byte
	FirstChunk          []uint32
	SamplesPerChunk     []uint32
	SampleDescriptionID []uint32
}

Sample To Chunk Box (stsc - mandatory)

Contained in : Sample Table box (stbl)

Status: decoded

A chunk contains samples. This table defines to which chunk a sample is associated. Each entry is defined by :

  • first chunk : all chunks starting at this index up to the next first chunk have the same sample count/description
  • samples per chunk : number of samples in the chunk
  • description id : description (see the sample description box - stsd)

func (*StscBox) Dump

func (b *StscBox) Dump()

func (*StscBox) Encode

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

func (*StscBox) Size

func (b *StscBox) Size() uint64

func (*StscBox) Type

func (b *StscBox) Type() string

type StsdBox

type StsdBox struct {
	Version byte
	Flags   [3]byte
	// contains filtered or unexported fields
}

Sample Description Box (stsd - manatory)

Contained in : Sample Table box (stbl)

Status: not decoded

This box contains information that describes how the data can be decoded.

func (*StsdBox) Encode

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

func (*StsdBox) Size

func (b *StsdBox) Size() uint64

func (*StsdBox) Type

func (b *StsdBox) Type() string

type StssBox

type StssBox struct {
	Version      byte
	Flags        [3]byte
	SampleNumber []uint32
}

Sync Sample Box (stss - optional)

Contained in : Sample Table box (stbl)

Status: decoded

This lists all sync samples (key frames for video tracks) in the data. If absent, all samples are sync samples.

func (*StssBox) Dump

func (b *StssBox) Dump()

func (*StssBox) Encode

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

func (*StssBox) Size

func (b *StssBox) Size() uint64

func (*StssBox) Type

func (b *StssBox) Type() string

type StszBox

type StszBox struct {
	Version           byte
	Flags             [3]byte
	SampleUniformSize uint32
	SampleNumber      uint32
	SampleSize        []uint32
}

StszBox - Sample Size Box (stsz - mandatory)

Contained in : Sample Table box (stbl)

Status : decoded

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) Dump

func (b *StszBox) Dump()

Dump dumps

func (*StszBox) Encode

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

Encode encodes

func (*StszBox) GetSampleSize

func (b *StszBox) GetSampleSize(i int) uint32

GetSampleSize returns the size (in bytes) of a sample

func (*StszBox) Size

func (b *StszBox) Size() uint64

Size returns the size of the box

func (*StszBox) Type

func (b *StszBox) Type() string

Type returns stsz

type SttsBox

type SttsBox struct {
	Version         byte
	Flags           [3]byte
	SampleCount     []uint32
	SampleTimeDelta []uint32
}

Decoding Time to Sample Box (stts - mandatory)

Contained in : Sample Table box (stbl)

Status: decoded

This table contains the duration in time units for each sample.

  • sample count : the number of consecutive samples having the same duration
  • time delta : duration in time units

func (*SttsBox) Dump

func (b *SttsBox) Dump()

func (*SttsBox) Encode

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

func (*SttsBox) GetTimeCode

func (b *SttsBox) GetTimeCode(sample uint32) (units uint32)

GetTimeCode returns the timecode (duration since the beginning of the media) of the beginning of a sample

func (*SttsBox) Size

func (b *SttsBox) Size() uint64

func (*SttsBox) Type

func (b *SttsBox) Type() string

type TkhdBox

type TkhdBox struct {
	Version          byte
	Flags            [3]byte
	CreationTime     uint64
	ModificationTime uint64
	TrackID          uint32
	Duration         uint64
	Layer            uint16
	AlternateGroup   uint16 // should be int16
	Volume           Fixed16
	Matrix           []byte
	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).

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 (*TkhdBox) Dump

func (b *TkhdBox) Dump()

Dump to terminal

func (*TkhdBox) Encode

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

Encode encodes to the writer

func (*TkhdBox) Size

func (b *TkhdBox) Size() uint64

Size returns the size of the box

func (*TkhdBox) Type

func (b *TkhdBox) Type() string

Type returns tkhd

type TrakBox

type TrakBox struct {
	Tkhd *TkhdBox
	Mdia *MdiaBox
	Edts *EdtsBox
	Udta *UdtaBox
	Tref *TrefBox
}

Track Box (tkhd - mandatory)

Contained in : Movie Box (moov)

A media file can contain one or more tracks.

func (*TrakBox) Dump

func (b *TrakBox) Dump()

func (*TrakBox) Encode

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

func (*TrakBox) Size

func (b *TrakBox) Size() uint64

func (*TrakBox) Type

func (b *TrakBox) Type() string

type TrefBox

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

Tref Box (apple)

Status: not decoded

func (*TrefBox) Encode

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

func (*TrefBox) Size

func (b *TrefBox) Size() uint64

func (*TrefBox) Type

func (b *TrefBox) Type() string

type UdtaBox

type UdtaBox struct {
	Meta *MetaBox
	Name *NameBox
	Chpl *ChplBox
	// contains filtered or unexported fields
}

User Data Box (udta - optional)

Contained in: Movie Box (moov) or Track Box (trak)

func (*UdtaBox) Encode

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

func (*UdtaBox) Size

func (b *UdtaBox) Size() uint64

func (*UdtaBox) Type

func (b *UdtaBox) Type() string

type UniBox

type UniBox struct {
	BoxHeader
	// contains filtered or unexported fields
}

UniBox - Universal not decoded Box

func DecodeUni

func DecodeUni(header BoxHeader) *UniBox

DecodeUni - decodes uni

func (*UniBox) Decode

func (u *UniBox) Decode(r io.Reader, size uint64) (Box, error)

Decode decodes a uni

func (*UniBox) Encode

func (u *UniBox) Encode(w io.Writer) error

Encode really encodes the box

func (*UniBox) Size

func (u *UniBox) Size() uint64

Size returns the true size of the box

func (*UniBox) Type

func (u *UniBox) Type() string

Type returns teh real type of the box

type VmhdBox

type VmhdBox struct {
	Version      byte
	Flags        [3]byte
	GraphicsMode uint16
	OpColor      [3]uint16
}

Video Media Header Box (vhmd - mandatory for video tracks)

Contained in : Media Information Box (minf)

Status: decoded

func (*VmhdBox) Encode

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

func (*VmhdBox) Size

func (b *VmhdBox) Size() uint64

func (*VmhdBox) Type

func (b *VmhdBox) Type() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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