Documentation
¶
Overview ¶
Package quicktime provides primitives for loading the tree of Atoms from a Quicktime file, and reading a subset of the atoms.
Index ¶
- Constants
- func DumpTree(tree AtomArray)
- func PrintAtom(atom *Atom, indent int)
- type Atom
- func (atom *Atom) BuildChildren()
- func (atom Atom) FindAtom(typeStr string) *Atom
- func (atom Atom) FindAtoms(typeStr string) (out []*Atom)
- func (atom Atom) HasData() bool
- func (atom *Atom) HeaderLength() uint64
- func (atom *Atom) IsContainer() bool
- func (atom Atom) IsType(typeStr string) bool
- func (atom *Atom) ReadChildren(r io.ReaderAt)
- func (atom *Atom) ReadData(r io.ReaderAt) (err error)
- func (atom *Atom) SetData(buf []byte)
- type AtomArray
- type BuildTreeConfig
- type CO64Atom
- type FTYPAtom
- type MDIAAtom
- type MINFAtom
- type MVHDAtom
- type STBLAtom
- type STSCAtom
- type STSZAtom
- type StringList
- type TKHDAtom
- type TRAKAtom
Constants ¶
const AtomHeaderLength = 8
AtomHeaderLength is the length of a standard Atom header in bytes: a 4 byte atom size, and a 4 byte atom type.
const ExtendedHeaderLength = 16
ExtendedHeaderLength is the length of an extended Quicktime Header: 4 bytes of size == 1 for extended headers 4 bytes of atom type 8 bytes of extended size
const Version = "v0.1.0"
Version stores the version
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Atom ¶
type Atom struct {
Offset uint64
Size uint64
DataSize uint64
Type string
IsExt bool
Children AtomArray
Data []byte `json:"-"`
}
The Atom struct stores a generic (not-decoded) Atom, including its type, size and optionally its Children and Data as a slice of the original byte buffer. If read from an io.ReaderAt it will also store the offset of the atom within the file (see ReadAtomAt)
func ParseAtom ¶
ParseAtom reads the first 8 bytes of the buffer and returns the appropriate Atom. Note this function doesn't set Data or Children for the Atom -- see ReadData and BuildChildren.
func ReadAtomAt ¶
ReadAtomAt reads the atom header from an io.ReaderAt and produces an Atom.
func (*Atom) BuildChildren ¶
func (atom *Atom) BuildChildren()
BuildChildren adds children to an Atom after its data has been loaded. If the Atom already has children, behavior is undetermined.
func (Atom) FindAtom ¶
FindAtom looks through an Atom's children for a given type, returning the first instance or nil of not found
func (Atom) FindAtoms ¶
FindAtoms looks through an Atom's children for a given type, returning an array of all instances. The array will be empty if not found.
func (*Atom) HeaderLength ¶
HeaderLength returns the number of bytes in the header, depending on whether the header is extended or not.
func (*Atom) IsContainer ¶
IsContainer returns true if a given atom type is a container, rather than a leaf. This is done using a switch ... if I've missed an atom, send me a pull request!
func (*Atom) ReadChildren ¶
ReadChildren adds children to an Atom by reading from a ReaderAt.
type AtomArray ¶
type AtomArray []*Atom
AtomArray is used to store the topmost level when building the atom tree ... there is no master top-level Atom in Quicktime.
func BuildTree ¶
func BuildTree(r io.ReaderAt, filesize uint64, options ...func(*BuildTreeConfig)) (AtomArray, error)
BuildTree builds a tree of Atoms from an io.ReaderAt. Rather than check for EOF, requires the io length to be pre-determined. Takes a list of configuration closures, each of which is passed the BuildTreeConfig. Returns the top-level AtomArray. On an error, this AtomArray will contain atoms up to the error.
type BuildTreeConfig ¶
type BuildTreeConfig struct {
// List of Atom types which should be eager-loaded while building the tree.
EagerloadTypes StringList
}
BuildTreeConfig stores parameters for the BuildTree function.
type CO64Atom ¶
A CO64Atom is a table of 64bit chunk offsets For simplicity, I internally convert STCO atoms to CO64, rather than duplicating functionality
func (CO64Atom) ChunkOffset ¶
ChunkOffset gives the offset for a given chunk (remember that chunks are enumerated base-1)
type MVHDAtom ¶
A MVHDAtom stores timing information about the movie
type STBLAtom ¶
A STBLAtom stores the three Atoms requires to look up the file offset of an individual frame ("sample") in the file: STSZ (sample size), STCO or CO64 (chunk offset) and STSC (samples per chunk)
func (STBLAtom) SampleOffset ¶
SampleOffset calculates the byte offset of a given sample within the quicktime file
type STSCAtom ¶
type STSCAtom struct {
Atom *Atom
Entries []stscEntry
}
A STSCAtom stores a table of samples per chunk
type STSZAtom ¶
A STSZAtom stores a table of sample sizes
func (STSZAtom) NumSamples ¶
NumSamples returns the number of samples in an STSZAtom
func (STSZAtom) SampleSize ¶
SampleSize looks up the size of a given sample in the STSZAtom