Skip to main content

Crate alpha2_container

Crate alpha2_container 

Source
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§

AudioTrack
An audio track’s sound facts.
FourCc
A four-character code, as MP4 sample entries name codecs.
MatroskaReader
Reads Matroska and WebM files: their tracks and each track’s packets, timed as FFmpeg’s Matroska demuxer and generic demuxing layer time them.
MatroskaWriter
Writes Matroska or WebM files: the header, clusters of blocks with millisecond timestamps, cues at the end, then the SeekHead and 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, Matroska TrackNumber).
TrackInfo
One track of a container.
VideoTrack
A video track’s picture facts.
WavWriter
A writer of one PCM track into a RIFF WAVE file.

Enums§

AudioCodec
An audio codec, as the container declares it.
ContainerFormat
The container formats this layer reads, as a sniff of the first bytes finds them.
DemuxError
Why a file could not be read.
MatroskaFlavor
Which flavor of Matroska to write.
Mp4Flavor
Which brand of ISO base media file to write.
MuxError
Why a file could not be written.
TrackKind
What a track carries.
VideoCodec
A video codec, as the container declares it.

Traits§

ContainerReader
A demuxer: the tracks of one file and their packets.
ContainerWriter
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 kind flagged default, else the first of kind.
open
Opens path with the demuxer its first bytes call for.
open_source
Opens the file source holds 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.
wave_channel_layout
The WAVE_FORMAT_EXTENSIBLE channel mask of speakers, None for the default layout of their count, and the order of the planes in a frame, which a mask fixes to its bit order.