mp4

package
v0.0.0-...-f9ed69e Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrShortMVHD = formatError("MVHD too short")
View Source
var ErrShortTKHD = formatError("TKHD too short")

Functions

This section is empty.

Types

type Box

type Box struct {
	Offset, Size int64 // size and offset of the box in the original file

	Ext bool // false: 8-byte header, true: 16-byte header

	Type string // 4-byte cc4

	Raw []byte // raw content, if loaded

	Child []Box // child boxes
}

func (*Box) ContentSize

func (b *Box) ContentSize() int64

ContentSize returns the payload length, or -1 if the box goes to EOF (or the end of its parent)

func (*Box) Find

func (b *Box) Find(typ ...string) *Box

func (*Box) HeaderSize

func (b *Box) HeaderSize() int64

type File

type File struct {
	Box

	Header *MVHD // movid header
}

func Parse

func Parse(r io.Reader) (*File, error)

Parse parses an MP4 file from r. If r is a io.ReadSeeker then it is used to seek forward within r when necessary.

func (*File) AddUuid

func (f *File) AddUuid(data []byte)

AddUuid inserts the an uuid box into f. The first 16 bits of data is the 16-byte UUID.

func (*File) FrameSize

func (f *File) FrameSize() (width, height int, err error)

FrameSize returns the frame size of f.

func (*File) Optimize

func (f *File) Optimize() error

type MVHD

type MVHD struct {
	Version      byte
	Flags        [3]byte
	DateCreated  time.Time
	DateModified time.Time

	TimeUnit        uint32 // time unit per second (default = 600)
	DurationInUnits uint64 // time length (in time units)

	Raw []byte // undecoded data after decoded bits above
}

func DecodeMVHD

func DecodeMVHD(p []byte) (*MVHD, error)

func (*MVHD) Duration

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

func (*MVHD) Len

func (m *MVHD) Len() int

encoded length in bytes

type TKHD

type TKHD struct {
	Version      byte
	Flags        [3]byte
	DateCreated  time.Time
	DateModified time.Time

	TrackId         uint32
	DurationInUnits uint64 // time length (in time units; see MVHD)

	Width, Height uint32 // fixed point, see FrameSize
}

func DecodeTKHD

func DecodeTKHD(p []byte) (*TKHD, error)

func (*TKHD) FrameSize

func (t *TKHD) FrameSize() (w, h int)

Jump to

Keyboard shortcuts

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