Expand description
alpha2’s own media container layer, for hosts without libavformat.
open sniffs a file and returns a ContainerReader that lists its tracks and hands out
compressed packets per track; ContainerWriters write MP4/MOV and Matroska/WebM. Timestamps
are in each track’s timescale, on the presentation timeline after edit lists, and match what
FFmpeg’s demuxer reports for the same file, which the tests use as the oracle.
Inputs are untrusted: sizes, counts and dimensions are bounded before anything is allocated
(frames at most 16384 pixels per side and 2^26 pixels in all, as the engine refuses larger).
Arithmetic with an operand from the file uses the checked_, saturating_ or wrapping_
method that says what an out-of-range result means, since release builds panic on overflow.
Memory is bounded per file, not only per allocation: at most 256 tracks and 2^23
MP4 index entries over all tracks.
Structs§
- Audio
Track - An audio track’s sound facts.
- FourCc
- A four-character code, as MP4 sample entries name codecs.
- Matroska
Reader - Reads Matroska and
WebMfiles: their tracks and each track’s packets, timed asFFmpeg’s Matroska demuxer and generic demuxing layer time them. - Matroska
Writer - Writes Matroska or
WebMfiles: the header, clusters of blocks with millisecond timestamps, cues at the end, then theSeekHeadand duration filled in by seeking back. - Mp4Reader
- Reads MP4, MOV and M4A files: their tracks and each track’s packets, timed as
FFmpeg’s MOV demuxer times them. - Mp4Writer
- Writes MP4 or MOV files with the index before the media data (faststart), tracks interleaved in chunks of about half a second.
- Packet
- One compressed frame of one track.
- PcmFormat
- How PCM samples are stored.
- TrackId
- A track’s number within its container (MP4
track_ID, MatroskaTrackNumber). - Track
Info - One track of a container.
- Video
Track - A video track’s picture facts.
Enums§
- Audio
Codec - An audio codec, as the container declares it.
- Container
Format - The container formats this layer reads, as a sniff of the first bytes finds them.
- Demux
Error - Why a file could not be read.
- Matroska
Flavor - Which flavor of Matroska to write.
- Mp4Flavor
- Which brand of ISO base media file to write.
- MuxError
- Why a file could not be written.
- Track
Kind - What a track carries.
- Video
Codec - A video codec, as the container declares it.
Traits§
- Container
Reader - A demuxer: the tracks of one file and their packets.
- Container
Writer - A muxer: writes tracks’ packets into one file.
- Source
- A seekable byte stream a demuxer reads a file from.
Functions§
- default_
track - The first enabled track of
kindflagged default, else the first ofkind. - open
- Opens
pathwith the demuxer its first bytes call for. - open_
source - Opens the file
sourceholds with the demuxer its first bytes call for. - sniff
- The format of a file starting with
head(at least its first 4096 bytes when it has them). - vorbis_
order - The speakers of Vorbis’s coded channel order (also Opus mapping family 1) for 1 to 8 channels.