API / Minn\Media\Av / Matroska

Matroska final class

Minn\Media\Av\Matroska · public/minn/src/Minn/Media/Av/Matroska.php · 314 lines

Matroska and WebM files (MKV, MKA, WebM) as the reference's media reader measures them (probe media-meta). The segment information gives the playing time and the date; the first video and audio tracks give the streams, named by their codec where the reader knows it (and by the codec identifier where it does not). MP3 and MP2 audio is described from its first frame, FLAC from its stream information, AC-3 from its first frame; the bitrate is the file's over its playing time, the video keeping what a known audio bitrate leaves.

Used by 1

Constants and properties

privateSEGMENT = 408125543
privateCONTAINERS = array ( 0 => 440786851, 1 => 408125543, 2 => 357149030, 3 => 374648427, 4 => 174, 5 => 224, 6 => 225, )
privateVIDEO = array ( 'V_VP8' => 'vp8', 'V_MPEG4/ISO/AVC' => 'h264', 'V_MPEG4/ISO/ASP' => 'mpeg4', 'V_MS/VFW/FOURCC' => 'vcm', )
privateAUDIO = array ( 'A_AAC' => 'aac', 'A_AC3' => 'ac3', 'A_MPEG/L3' => 'mp3', 'A_MPEG/L2' => 'mp2', 'A_FLAC' => 'flac', 'A_PCM/INT/LIT' => 'pcm', 'A_VORBIS' => 'vorbis', )
privateFRAMED = array ( 0 => 'A_MPEG/L3', 1 => 'A_MPEG/L2', 2 => 'A_AC3', )

The audio codecs described from their first frame, whose rate a file of audio alone keeps.

privateHEAD = 262144
privateEPOCH = 978307200

Seconds between 1970 and 2001, where a Matroska date is counted from.

Public

staticdetects(string $head): bool#

Whether a file's first bytes are an EBML header.

staticread(Minn\Media\Av\Source $source): array#

The file's analysis.

@return array<string, mixed>

Internals 10

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatewalk(string $bytes, int $at, int $end, array $found, ?array $track = NULL): void#

The elements from $at to $end that matter here, gathered into $found.

$foundarray<string, mixed>
privateelement(int $id, string $value, array $found, ?array $track): void#

One element's value kept where it belongs.

$foundarray<string, mixed>
$trackarray<string, mixed>|null
privateaudio(array $track, string $bytes, ?int $segment): array#

A track's audio as the reference describes it: the codec's name, rate, channels, language and depth, then what the codec's own reader adds.

$trackarray<string, mixed>
@return array<string, mixed>
privatevideo(array $track, int|float|null $bitrate): array#

A track's video: its codec's name (an AVI codec's named as AVI does), size, display size, frame rate and the bitrate it has.

$trackarray<string, mixed>
@return array<string, mixed>
privatefirstBlock(string $bytes, ?int $segment, int $number): ?string#

The first frame of a track, from the first cluster's blocks.

privateblockFor(string $block, int $number): ?string#

A block's payload when it belongs to the track numbered $number.

privateidentifier(string $bytes, int $at): ?int#

An element id at $at, which it moves past: a variable-length number with its marker kept.

privatesize(string $bytes, int $at): ?int#

An element size at $at, which it moves past: its marker dropped, all ones (an unknown size) read as the most there can be.

privatefloat(string $value): float#

A float element's value (four or eight bytes, big-endian).

privatesigned(string $value): int#

A signed big-endian integer element's value.