mp4read

package
v0.2.17 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: AGPL-3.0 Imports: 5 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 mp4read reads the video track of the MP4 files Reolink cameras write (to their SD card, and over FTP): a plain moov with an avc1 or hvc1 track, or a fragmented file (battery doorbells) whose moov is empty and whose samples sit in moof+mdat pairs. Just enough to hand the samples back as Annex-B access units, parameter sets in front of each keyframe, and the AAC track beside them, if there is one, as ADTS frames.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Audio added in v0.2.8

type Audio struct {
	Timescale uint32
	// Start is when the first sample plays, in Timescale units, on the
	// same footing as Track.Start.
	Start int64
	// Object is the MPEG-4 audio object type (2 is AAC-LC), Rate the
	// sample rate in Hz, Channels the channel configuration.
	Object, Rate, Channels int
	Samples                []Sample
	// contains filtered or unexported fields
}

Audio is a file's AAC track.

func (*Audio) ADTS added in v0.2.8

func (a *Audio) ADTS(i int) ([]byte, error)

ADTS reads audio sample i with an ADTS header in front: the framing a raw AAC stream, and MPEG-TS, carry it in.

type Sample

type Sample struct {
	Offset int64
	Size   uint32
	// Dur is how long it shows, in Track.Timescale units.
	Dur uint32
	Key bool
}

Sample is one access unit in the file.

type Track

type Track struct {
	Codec     string // "H264" or "H265"
	Timescale uint32
	// Start is when the first sample shows, in Timescale units: its decode
	// time less the edit list's skip. It is what lines the audio up with
	// the picture.
	Start   int64
	Params  [][]byte // VPS/SPS/PPS or SPS/PPS, without start codes
	Samples []Sample
	// Audio is the file's AAC track, or nil when it has none, or one that
	// ADTS cannot frame.
	Audio *Audio
	// contains filtered or unexported fields
}

Track is a file's video track.

func Open

func Open(path string) (*Track, error)

Open reads path's video track. Close the track when done.

func (*Track) AnnexB

func (t *Track) AnnexB(i int) ([]byte, error)

AnnexB reads sample i as Annex-B, with the parameter sets in front of a keyframe so a decoder can start there.

func (*Track) Close

func (t *Track) Close() error

Close closes the file.

func (*Track) LastKey

func (t *Track) LastKey() int

LastKey is the index of the last keyframe, or -1.

Jump to

Keyboard shortcuts

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