IsoMedia final class
Minn\Media\Av\IsoMedia · public/minn/src/Minn/Media/Av/IsoMedia.php · 364 lines
MPEG-4 and QuickTime files (MP4, M4A, M4V, MOV) as the reference's media reader measures them (probe media-meta). The movie header gives the playing time and the time it was made; each track's first sample entry gives its codec. Only AAC ("mp4a") is read as audio, and it alone makes a file audio/mp4 (or video/mp4 beside a video track); anything else is video/quicktime. A video entry with a vendor is read the QuickTime way (its compressor's name, lossless false); one without, the ISO way (a named codec, and "mp4" as the format for the codecs it knows). Only H.264 and MPEG-4 video have the bitrate the audio leaves.
Constants and properties
| private | VIDEO = 'avc1=H.264/MPEG-4 AVC|cvid=Cinepak|dvc =DVC-NTSC|dvcp=DVC-PAL|gif =GIF|h263=H263|hvc1=H.265/HEVC|jpeg=JPEG|kpcd=PhotoCD|mjpa=Motion JPEG-A|mjpb=Motion JPEG-B|mp4v=|png =PNG|raw =RAW|rle =|rpza=Video|smc =Graphics|SVQ1=Sorenson Video 3|SVQ3=Sorenson Video 3 (Apple Quicktime 5)|tiff=TIFF|v216=|v308=|v408=|v410=|yuv2=ComponentVideo' | Video codecs the ISO way names, and makes a file "mp4" for (code => name, empty for none). |
| private | DATAFORMATS = array ( 'mp4v' => 'mpeg4', '3IV1' => '3ivx', '3IV2' => '3ivx', '3ivx' => '3ivx', 'DIVX' => 'divx', 'divx' => 'divx', 'DIV3' => 'divx', 'div3' => 'divx', 'XVID' => 'xvid', 'xvid' => 'xvid', ) | |
| private | CONTAINERS = array ( 0 => 'moov', 1 => 'trak', 2 => 'mdia', 3 => 'minf', 4 => 'stbl', 5 => 'udta', 6 => 'ilst', 7 => 'covr', ) | |
| private | EPOCH = 2082844800 | Seconds between 1904, where the movie's clock starts, and 1970. |
| private | MOOV_LIMIT = 67108864 | |
| private | BOX_LIMIT = 4096 | The most boxes read at one level (the file's, or a container's). |
Public
| static | detects(string $head): bool# | Whether a file's first bytes are an MPEG-4 or QuickTime box. |
| static | read(Minn\Media\Av\Source $source): array# | The file's analysis: format, type, playing time and bitrate, the audio and video streams, the movie header for its creation time and the cover. @return array<string, mixed> |
Internals 13
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | movie(Minn\Media\Av\Source $source): array# | The movie box's bytes (null when there is none, or it is too large to read) and where the first media data begins. @return array{moov: ?string, dataStart: ?int} | ||||||
| private | boxHeader(string $bytes, int $room): array# | A box's size, type and header length from its first bytes; a size of 0 runs to $room, a size of 1 is the 64-bit size that follows. @return array{0: int, 1: string, 2: int} | ||||||
| private | children(string $bytes, int $start, int $end): array# | The boxes inside a run of bytes, each with its body's place. @return list<array{type: string, start: int, end: int}> | ||||||
| private | find(string $bytes, array $boxes, array $path): ?array# | The first box of a type along a path of containers, or null.
@return array{type: string, start: int, end: int}|null | ||||||
| private | movieHeader(string $bytes, array $moov): ?array# | The movie header's timescale, duration and creation time.
@return array{timescale: int, duration: int, created: int}|null | ||||||
| private | track(string $bytes, array $trak): array# | A track's size (from its header) and its first sample entry, read as audio or video.
@return array{entry: array<string, mixed>|null} | ||||||
| private | aac(string $entry): array# | An AAC sample entry's stream: its rate and channels as the version 0 layout places them (whatever the version), and the average bitrate an elementary stream descriptor directly inside it gives. @return array<string, mixed> | ||||||
| private | averageBitrate(string $esds): ?int# | The average bitrate an elementary stream descriptor's decoder configuration gives; null without one. | ||||||
| private | afterLength(string $bytes, int $at): int# | Where a descriptor's body starts, after its length of one to four bytes. | ||||||
| private | videoEntry(string $entry, array $trackSize): array# | A video sample entry read the QuickTime way (it names a vendor) or the ISO way.
@return array<string, mixed> | ||||||
| private | cover(string $bytes, array $moov): ?array# | The cover an iTunes tag list holds: its bytes and type.
@return array<string, mixed>|null | ||||||
| private | ordered(array $video): array# | A video stream's fields in the order the reference keeps them.
@return array<string, mixed> | ||||||
| private | videoCodecs(): array# | @return array<string, string> code => name |
Nothing matches.