mp4

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package mp4 extracts ALAC audio tracks and sample tables from MP4/M4A containers.

Index

Constants

View Source
const (
	// Bound the allocations made while reading a progressive track.
	MaxMovieSize  = 16 << 20
	MaxPacketSize = 4 << 20
	MaxPackets    = 1 << 20
)

Variables

View Source
var (
	ErrNoALACTrack        = errors.New("mp4: no ALAC track found in container")
	ErrInvalidEntry       = errors.New("mp4: invalid ALAC sample entry")
	ErrInvalidBoxSize     = errors.New("mp4: invalid box size")
	ErrNoChunkOffset      = errors.New("mp4: no chunk offset box (stco/co64)")
	ErrInvalidChunkOffset = errors.New("mp4: chunk offset beyond the seekable range")
	ErrInvalidCo64        = errors.New("mp4: invalid co64 payload")
	ErrNoStsc             = errors.New("mp4: no stsc box")
	ErrInvalidStsc        = errors.New("mp4: invalid stsc payload")
	ErrNoStsz             = errors.New("mp4: no stsz box")
	ErrInvalidStsz        = errors.New("mp4: invalid stsz payload")
	ErrTableTooLarge      = errors.New("mp4: sample table larger than its box")
)

MP4 container parsing error sentinels.

Functions

func Sniff

func Sniff(prefix []byte) bool

Sniff reports whether the prefix starts with a recognized top-level MP4 box.

Types

type SampleInfo

type SampleInfo struct {
	Offset uint64
	Size   uint32
}

SampleInfo holds the byte offset and size of a single encoded ALAC packet within the MP4 container.

func FindALACTrack

func FindALACTrack(ctx context.Context, reader io.ReadSeeker) ([]byte, []SampleInfo, error)

FindALACTrack walks the MP4 box tree to locate the first track containing an ALAC sample entry. It returns the magic cookie and a flat sample table.

Jump to

Keyboard shortcuts

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