API / Minn\Media\Av / Riff

Riff final class

Minn\Media\Av\Riff · public/minn/src/Minn/Media/Av/Riff.php · 351 lines

RIFF files, WAV audio and AVI video, as the reference's media reader measures them (probe media-meta). A WAV's format chunk describes its stream (the codec named by its format tag, lossless only for PCM) and its data chunk times it. An AVI's headers give the frames and their rate, each stream's format, and the movie list that holds the data; its video has the bitrate the audio's leaves. MP3 audio in an AVI (or in a WAV that states its rate) is described from its first frame.

Constants and properties

privateFORMAT_TAGS = '0=Microsoft Unknown Wave Format|1=Pulse Code Modulation (PCM)|2=Microsoft ADPCM|3=IEEE Float|4=Compaq Computer VSELP|5=IBM CVSD|6=Microsoft A-Law|7=Microsoft mu-Law|8=Microsoft DTS|10=OKI ADPCM|11=Intel DVI/IMA ADPCM|12=Videologic MediaSpace ADPCM|13=Sierra Semiconductor ADPCM|14=Antex Electronics G.723 ADPCM|15=DSP Solutions DigiSTD|16=DSP Solutions DigiFIX|17=Dialogic OKI ADPCM|18=MediaVision ADPCM|19=Hewlett-Packard CU|20=Yamaha ADPCM|21=Speech Compression Sonarc|22=DSP Group TrueSpeech|23=Echo Speech EchoSC1|24=Audiofile AF36|25=Audio Processing Technology APTX|26=AudioFile AF10|27=Prosody 1612|28=LRC|30=Dolby AC2|31=Microsoft GSM 6.10|32=MSNAudio|33=Antex Electronics ADPCME|34=Control Resources VQLPC|35=DSP Solutions DigiREAL|36=DSP Solutions DigiADPCM|37=Control Resources CR10|38=Natural MicroSystems VBXADPCM|39=Crystal Semiconductor IMA ADPCM|3a=EchoSC3|3b=Rockwell ADPCM|3c=Rockwell Digit LK|3d=Xebec|40=Antex Electronics G.721 ADPCM|41=G.728 CELP|42=MSG723|50=MPEG Layer-2 or Layer-1|52=RT24|53=PAC|55=MPEG Layer-3|59=Lucent G.723|60=Cirrus|61=ESPCM|62=Voxware|63=Canopus Atrac|64=G.726 ADPCM|65=G.722 ADPCM|66=DSAT|67=DSAT Display|69=Voxware Byte Aligned|70=Voxware AC8|71=Voxware AC10|72=Voxware AC16|73=Voxware AC20|74=Voxware MetaVoice|75=Voxware MetaSound|76=Voxware RT29HW|77=Voxware VR12|78=Voxware VR18|79=Voxware TQ40|80=Softsound|81=Voxware TQ60|82=MSRT24|83=G.729A|84=MVI MV12|85=DF G.726|86=DF GSM610|88=ISIAudio|89=Onlive|91=SBC24|92=Dolby AC3 SPDIF|93=MediaSonic G.723|94=Aculab PLC Prosody 8kbps|97=ZyXEL ADPCM|98=Philips LPCBB|99=Packed|ff=AAC|100=Rhetorex ADPCM|101=IBM mu-law|102=IBM A-law|103=IBM AVC Adaptive Differential Pulse Code Modulation (ADPCM)|111=Vivo G.723|112=Vivo Siren|123=Digital G.723|125=Sanyo LD ADPCM|130=Sipro Lab Telecom ACELP NET|131=Sipro Lab Telecom ACELP 4800|132=Sipro Lab Telecom ACELP 8V3|133=Sipro Lab Telecom G.729|134=Sipro Lab Telecom G.729A|135=Sipro Lab Telecom Kelvin|140=Windows Media Video V8|150=Qualcomm PureVoice|151=Qualcomm HalfRate|155=Ring Zero Systems TUB GSM|160=Microsoft Audio 1|161=Windows Media Audio V7 / V8 / V9|162=Windows Media Audio Professional V9|163=Windows Media Audio Lossless V9|200=Creative Labs ADPCM|202=Creative Labs Fastspeech8|203=Creative Labs Fastspeech10|210=UHER Informatic GmbH ADPCM|220=Quarterdeck|230=I-link Worldwide VC|240=Aureal RAW Sport|250=Interactive Products HSX|251=Interactive Products RPELP|260=Consistent Software CS2|270=Sony SCX|300=Fujitsu FM Towns Snd|400=BTV Digital|401=Intel Music Coder|450=QDesign Music|680=VME VMPCM|681=AT&T Labs TPC|8ae=ClearJump LiteWave|1000=Olivetti GSM|1001=Olivetti ADPCM|1002=Olivetti CELP|1003=Olivetti SBC|1004=Olivetti OPR|1100=Lernout & Hauspie Codec (0x1100)|1101=Lernout & Hauspie CELP Codec (0x1101)|1102=Lernout & Hauspie SBC Codec (0x1102)|1103=Lernout & Hauspie SBC Codec (0x1103)|1104=Lernout & Hauspie SBC Codec (0x1104)|1400=Norris|1401=AT&T ISIAudio|1500=Soundspace Music Compression|181c=VoxWare RT24 Speech|1fc4=NCT Soft ALF2CD (www.nctsoft.com)|2000=Dolby AC3|2001=Dolby DTS|2002=WAVE_FORMAT_14_4|2003=WAVE_FORMAT_28_8|2004=WAVE_FORMAT_COOK|2005=WAVE_FORMAT_DNET|674f=Ogg Vorbis 1|6750=Ogg Vorbis 2|6751=Ogg Vorbis 3|676f=Ogg Vorbis 1+|6770=Ogg Vorbis 2+|6771=Ogg Vorbis 3+|7a21=GSM-AMR (CBR, no SID)|7a22=GSM-AMR (VBR, including SID)|fffe=WAVE_FORMAT_EXTENSIBLE|ffff=WAVE_FORMAT_DEVELOPMENT'
privateVIDEO_CODECS = '3IV1=3ivx MPEG-4 v1|3IV2=3ivx MPEG-4 v2|3IVX=3ivx MPEG-4|AASC=Autodesk Animator|ABYR=Kensington ?ABYR?|AEMI=Array Microsystems VideoONE MPEG1-I Capture|AFLC=Autodesk Animator FLC|AFLI=Autodesk Animator FLI|AMPG=Array Microsystems VideoONE MPEG|ANIM=Intel RDX (ANIM)|AP41=AngelPotion Definitive|ASV1=Asus Video v1|ASV2=Asus Video v2|ASVX=Asus Video 2.0 (audio)|AUR2=AuraVision Aura 2 Codec - YUV 4:2:2|AURA=AuraVision Aura 1 Codec - YUV 4:1:1|AVDJ=Independent JPEG Group\\\'s codec (AVDJ)|AVRN=Independent JPEG Group\\\'s codec (AVRN)|AYUV=4:4:4 YUV (AYUV)|AZPR=Quicktime Apple Video (AZPR)|BGR =Raw RGB32|BINK=RAD Game Tools Bink Video|BLZ0=Blizzard DivX MPEG-4|BT20=Conexant Prosumer Video|BTCV=Conexant Composite Video Codec|BW10=Data Translation Broadway MPEG Capture|CC12=Intel YUV12|CDVC=Canopus DV|CFCC=Digital Processing Systems DPS Perception|CGDI=Microsoft Office 97 Camcorder Video|CHAM=Winnov Caviara Champagne|CJPG=Creative WebCam JPEG|CLJR=Cirrus Logic YUV 4:1:1|CMYK=Common Data Format in Printing (Colorgraph)|CPLA=Weitek 4:2:0 YUV Planar|CRAM=Microsoft Video 1 (CRAM)|CVID=Radius Cinepak|CWLT=Microsoft Color WLT DIB|CYUV=Creative Labs YUV|CYUY=ATI YUV|D261=H.261|D263=H.263|DIV3=DivX ;-) MPEG-4 v3.x Low-Motion|DIV4=DivX ;-) MPEG-4 v3.x Fast-Motion|DIV5=DivX MPEG-4 v5.x|DIVX=DivX MPEG-4 v4 (OpenDivX / Project Mayo)|DMB1=Matrox Rainbow Runner hardware MJPEG|DMB2=Paradigm MJPEG|DSVD=?DSVD?|DUCK=Duck TrueMotion 1.0|DV25=Matrox DVCPRO codec|DV50=Matrox DVCPRO50 codec|DVAN=?DVAN?|DVE2=InSoft DVE-2 Videoconferencing|DVHD=IEC Standard DV 1125 lines @ 30fps / 1250 lines @ 25fps|DVSD=IEC 61834 and SMPTE 314M DVC/DV Video|DVSL=IEC Standard DV compressed in SD (SDL)|DVX1=Lucent DVX1000SP Video Decoder|DVX2=Lucent DVX2000S Video Decoder|DVX3=Lucent DVX3000S Video Decoder|DX50=DivX v5|DXT1=Microsoft DirectX Compressed Texture (DXT1)|DXT2=Microsoft DirectX Compressed Texture (DXT2)|DXT3=Microsoft DirectX Compressed Texture (DXT3)|DXT4=Microsoft DirectX Compressed Texture (DXT4)|DXT5=Microsoft DirectX Compressed Texture (DXT5)|DXTC=Microsoft DirectX Compressed Texture (DXTC)|EKQ0=Elsa ?EKQ0?|ELK0=Elsa ?ELK0?|EM2V=Etymonix MPEG-2 I-frame (www.etymonix.com)|ESCP=Eidos Escape|ETV1=eTreppid Video ETV1|ETV2=eTreppid Video ETV2|ETVC=eTreppid Video ETVC|FLJP=D-Vision Field Encoded Motion JPEG|FLV1=Sorenson Spark|FPS1=FRAPS v1|FRWA=SoftLab-Nsk Forward Motion JPEG w/ alpha channel|FRWD=SoftLab-Nsk Forward Motion JPEG|FVF1=Iterated Systems Fractal Video Frame|GLZW=Motion LZW (gabest@freemail.hu)|GPEG=Motion JPEG (gabest@freemail.hu)|GWLT=Microsoft Greyscale WLT DIB|H260=Intel ITU H.260 Videoconferencing|H261=Intel ITU H.261 Videoconferencing|H262=Intel ITU H.262 Videoconferencing|H263=Intel ITU H.263 Videoconferencing|H264=Intel ITU H.264 Videoconferencing|H265=Intel ITU H.265 Videoconferencing|H266=Intel ITU H.266 Videoconferencing|H267=Intel ITU H.267 Videoconferencing|H268=Intel ITU H.268 Videoconferencing|H269=Intel ITU H.269 Videoconferencing|HFYU=Huffman Lossless Codec|HMCR=Rendition Motion Compensation Format (HMCR)|HMRR=Rendition Motion Compensation Format (HMRR)|I263=FFmpeg I263 decoder|I420=Intel Indeo 4|IAN =Intel Indeo 4 (RDX)|ICLB=InSoft CellB Videoconferencing|IGOR=Power DVD|IJPG=Intergraph JPEG|ILVC=Intel Layered Video|ILVR=ITU-T H.263+|IPDV=I-O Data Device Giga AVI DV Codec|IR21=Intel Indeo 2.1|IRAW=Intel YUV Uncompressed|IUYV=Interlaced version of UYVY (www.leadtools.com)|IV30=Intel Indeo 3.0|IV31=Intel Indeo 3.1|IV32=Ligos Indeo 3.2|IV33=Ligos Indeo 3.3|IV34=Ligos Indeo 3.4|IV35=Ligos Indeo 3.5|IV36=Ligos Indeo 3.6|IV37=Ligos Indeo 3.7|IV38=Ligos Indeo 3.8|IV39=Ligos Indeo 3.9|IV40=Ligos Indeo Interactive 4.0|IV41=Ligos Indeo Interactive 4.1|IV42=Ligos Indeo Interactive 4.2|IV43=Ligos Indeo Interactive 4.3|IV44=Ligos Indeo Interactive 4.4|IV45=Ligos Indeo Interactive 4.5|IV46=Ligos Indeo Interactive 4.6|IV47=Ligos Indeo Interactive 4.7|IV48=Ligos Indeo Interactive 4.8|IV49=Ligos Indeo Interactive 4.9|IV50=Ligos Indeo Interactive 5.0|JBYR=Kensington ?JBYR?|JPEG=Still Image JPEG DIB|JPGL=Pegasus Lossless Motion JPEG|KMVC=Team17 Software Karl Morton\\\'s Video Codec|LEAD=LEAD Video Codec|LSVM=Vianet Lighting Strike Vmail (Streaming) (www.vianet.com)|M261=Microsoft H.261|M263=Microsoft H.263|M4S2=Microsoft Fully Compliant MPEG-4 v2 simple profile (M4S2)|MC12=ATI Motion Compensation Format (MC12)|MCAM=ATI Motion Compensation Format (MCAM)|MJ2C=Morgan Multimedia Motion JPEG2000|MJPG=Microsoft Motion JPEG DIB|MMES=Matrox MPEG-2 I-frame|MP42=Microsoft MPEG-4 (low-motion)|MP43=Microsoft MPEG-4 (fast-motion)|MP4S=Microsoft MPEG-4 (MP4S)|MP4V=FFmpeg MPEG-4|MPEG=Chromatic Research MPEG-1 Video I-Frame|MPG4=Microsoft MPEG-4 Video High Speed Compressor|MPGI=Sigma Designs MPEG|MRCA=FAST Multimedia Martin Regen Codec|MRLE=Microsoft Run Length Encoding|MSVC=Microsoft Video 1|MSZH=LCL (Lossless Codec Library) (www.geocities.co.jp/Playtown-Denei/2837/LRC.htm)|MTX1=Matrox ?MTX1?|MTX2=Matrox ?MTX2?|MTX3=Matrox ?MTX3?|MTX4=Matrox ?MTX4?|MTX5=Matrox ?MTX5?|MTX6=Matrox ?MTX6?|MTX7=Matrox ?MTX7?|MTX8=Matrox ?MTX8?|MTX9=Matrox ?MTX9?|MWV1=Aware Motion Wavelets|NTN1=Nogatech Video Compression 1|NVS0=nVidia GeForce Texture (NVS0)|NVS1=nVidia GeForce Texture (NVS1)|NVS2=nVidia GeForce Texture (NVS2)|NVS3=nVidia GeForce Texture (NVS3)|NVS4=nVidia GeForce Texture (NVS4)|NVS5=nVidia GeForce Texture (NVS5)|NVT0=nVidia GeForce Texture (NVT0)|NVT1=nVidia GeForce Texture (NVT1)|NVT2=nVidia GeForce Texture (NVT2)|NVT3=nVidia GeForce Texture (NVT3)|NVT4=nVidia GeForce Texture (NVT4)|NVT5=nVidia GeForce Texture (NVT5)|PDVC=I-O Data Device Digital Video Capture DV codec|PGVV=Radius Video Vision|PHMO=IBM Photomotion|PIM1=MPEG Realtime (Pinnacle Cards)|PIM2=Pegasus Imaging ?PIM2?|PIMJ=Pegasus Imaging Lossless JPEG|PIXL=MiroXL, Pinnacle PCTV|PVEZ=Horizons Technology PowerEZ|PVMM=PacketVideo Corporation MPEG-4|PVW2=Pegasus Imaging Wavelet Compression|QPEG=Q-Team QPEG 1.0|RGBT=Raw RGB w/ Transparency|RLE =Microsoft Run Length Encoder|RLE4=Run Length Encoded (4bpp, 16-color)|RLE8=Run Length Encoded (8bpp, 256-color)|RMP4=REALmagic MPEG-4 (unauthorized XVID copy) (www.sigmadesigns.com)|RPZA=Quicktime Apple Video (RPZA)|RT21=Intel Indeo RealTime Video 2.1|RV20=RealVideo G2|RV30=RealVideo 8|RV40=RealVideo 9|SDCC=Sun Communication Digital Camera Codec|SFMC=CrystalNet Surface Fitting Method|SMSC=Radius SMSC|SMSD=Radius SMSD|SP54=Logitech Sunplus Sp54 Codec for Mustek GSmart Mini 2|SPIG=Radius Spigot|SQZ2=Microsoft VXTreme Video Codec V2|STVA=ST Microelectronics CMOS Imager Data (Bayer)|STVB=ST Microelectronics CMOS Imager Data (Nudged Bayer)|STVC=ST Microelectronics CMOS Imager Data (Bunched)|STVX=ST Microelectronics CMOS Imager Data (Extended CODEC Data Format)|STVY=ST Microelectronics CMOS Imager Data (Extended CODEC Data Format with Correction Data)|SV10=Sorenson Video R1|SVQ1=Sorenson Video|SVQ3=Sorenson Video 3 (Apple Quicktime 5)|TLMS=TeraLogic Motion Intraframe Codec (TLMS)|TLST=TeraLogic Motion Intraframe Codec (TLST)|TM20=Duck TrueMotion 2.0|TM2X=Duck TrueMotion 2X|TMIC=TeraLogic Motion Intraframe Codec (TMIC)|TMOT=Horizons Technology TrueMotion S|TR20=Duck TrueMotion RealTime 2.0|TSCC=TechSmith Screen Capture Codec|TV10=Tecomac Low-Bit Rate Codec|TVJP=Pinnacle/Truevision Targa 2000 board (TVJP)|TVMJ=Pinnacle/Truevision Targa 2000 board (TVMJ)|TY0N=Tecomac Low-Bit Rate Codec (www.tecomac.com)|TY2C=Trident Decompression Driver|TY2N=Trident ?TY2N?|U263=UB Video H.263/H.263+/H.263++ Decoder|UCOD=eMajix.com ClearVideo|ULTI=IBM Ultimotion|V422=Vitec Multimedia 24-bit YUV 4:2:2 Format|V655=Vitec Multimedia 16-bit YUV 4:2:2 Format|VCR1=ATI Video Codec 1|VCR2=ATI Video Codec 2|VCR3=ATI VCR 3.0|VCR4=ATI VCR 4.0|VCR5=ATI VCR 5.0|VCR6=ATI VCR 6.0|VCR7=ATI VCR 7.0|VCR8=ATI VCR 8.0|VCR9=ATI VCR 9.0|VDCT=Vitec Multimedia Video Maker Pro DIB|VDOM=VDOnet VDOWave|VDTZ=Darim Vison VideoTizer YUV|VGPX=Alaris VideoGramPiX|VIDS=Vitec Multimedia YUV 4:2:2 CCIR 601 for V422|VIFP=VFAPI Reader Codec (www.yks.ne.jp/~hori/)|VIVO=Vivo H.263 v2.00|VIXL=Miro/Pinnacle Video XL|VLV1=VideoLogic/PURE Digital Videologic Capture|VP30=On2 VP3.0|VP31=On2 VP3.1|VP50=On2 VP5|VP60=On2 VP6|VP70=On2 VP7|VP80=On2 VP8|VQC2=Vector-quantised codec 2 (research) http://eprints.ecs.soton.ac.uk/archive/00001310/01/VTC97-js.pdf)|VX1K=Lucent VX1000S Video Codec|VX2K=Lucent VX2000S Video Codec|VXSP=Lucent VX1000SP Video Codec|VYU9=ATI YUV (VYU9)|VYUY=ATI YUV (VYUY)|WBVC=Winbond W9960|WHAM=Microsoft Video 1 (WHAM)|WINX=Winnov Software Compression|WJPG=AverMedia Winbond JPEG|WMV1=Windows Media Video V7|WMV2=Windows Media Video V8|WMV3=Windows Media Video V9|WNV1=Winnov Hardware Compression|XLV0=NetXL Video Decoder|XMPG=Xing MPEG (I-Frame only)|XVID=XviD MPEG-4 (www.xvid.org)|XXAN=?XXAN?|Y411=YUV 4:1:1 Packed|Y41P=Brooktree PC1 YUV 4:1:1 Packed|Y8 =Grayscale video|YC12=Intel YUV 12 codec|YUV8=Winnov Caviar YUV8|YUV9=Intel YUV9|YUVP=Extended PAL format YUV palette (www.riff.org)|YUY2=Uncompressed YUV 4:2:2|YUYV=Canopus YUV|YV12=YVU12 Planar|ZLIB=Lossless Codec Library zlib compression (www.geocities.co.jp/Playtown-Denei/2837/LRC.htm)|ZPEG=Metheus Video Zipper|cvid=Radius Cinepak|divx=DivX MPEG-4|dvsd=IEC 61834 and SMPTE 314M DVC/DV Video|i263=Intel ITU H.263 Videoconferencing (i263)|m4s2=Microsoft Fully Compliant MPEG-4 v2 simple profile (m4s2)|mp4s=Microsoft MPEG-4 (mp4s)|qpeq=Q-Team QPEG 1.1|rv20=RealVideo G2|rv30=RealVideo 8|s422=Tekram VideoCap C210 YUV 4:2:2|smsv=WorldConnect Wavelet Video|tmot=Horizons TrueMotion Video Compression|vivo=Vivo H.263|x263=Xirlink H.263'

Public

staticdetects(string $head): bool#

Whether a file's first bytes are a RIFF WAVE or AVI file.

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

The file's analysis: format, type, timing and its streams.

@return array<string, mixed>
staticvideoCodec(string $code): string#

The name an AVI video codec code has; empty for one it does not know.

Internals 13

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

privatewave(Minn\Media\Av\Source $source): array#
@return array<string, mixed>
privateavi(Minn\Media\Av\Source $source): array#
@return array<string, mixed>
privatechunks(Minn\Media\Av\Source $source, int $from, int $to): array#

The chunks between two offsets: each one's id, where its body starts and its size (bodies are padded to an even length).

@return list<array{id: string, start: int, size: int}>
privatestream(Minn\Media\Av\Source $source, array $list): array#

A stream list's header and format: its type, codec code, rate and scale, and its bitmap or wave format.

$listarray{id: string, start: int, size: int}
@return array<string, mixed>
privatewaveFormat(string $body): ?array#

A wave format's fields: its tag, channels, sample rate, average bytes a second and bits a sample.

@return array{tag: int, channels: int, sampleRate: int, average: int, bits: int}|null
privateaudio(array $format, array $dataformats): array#

A stream described by its wave format alone.

$formatarray{tag: int, channels: int, sampleRate: int, average: int, bits: int}
$dataformatsarray<string, int>the tags with a format name of their own
@return array<string, mixed>
privatescannedAudio(array $format, array $scan): array#

MP3 audio in a wave file, described from all its frames: the first frame's channels and rate, the frames' mean bitrate (variable when any frame's differs), the tag; the codec, the encoder's options and the lossless flag only when the wave format states a rate.

$formatarray{tag: int, channels: int, sampleRate: int, average: int, bits: int}
$scanarray{first: array<string, int>, bitrate: float, variable: bool}
@return array<string, mixed>
privateac3Audio(array $format, array $frame): array#

AC-3 audio in a wave file, described from its first frame: the frame's rate, bitrate, channel mode and channels (a low frequency channel counted as ".1", which the ratio counts too), then the tag and codec; the sample size only for an extensible format.

$formatarray{tag: int, channels: int, sampleRate: int, average: int, bits: int}
$framearray{sampleRate: int, bitrate: int, channels: int|string, mode: string}
@return array<string, mixed>
privatempegAudio(array $format, array $frame): array#

MP3 audio described from its first frame, the wave format's tag and codec beside: a rate the format states comes early, one read from the frame late.

$formatarray{tag: int, channels: int, sampleRate: int, average: int, bits: int}
$framearray<string, int>
@return array<string, mixed>
privatefirstAudioFrame(Minn\Media\Av\Source $source, ?array $movie, int $index): ?array#

The first MPEG frame header of an AVI's audio stream, from its first chunk in the movie list.

$moviearray{id: string, start: int, size: int}|null
@return array<string, int>|null
privatevideo(array $stream, int $frames, int|float $rate, int|float|null $bitrate): array#

An AVI's video stream: its size and depth from its bitmap header, the frames and their rate, its codec named by the stream's handler (or failing that the bitmap's compression), and the bitrate it has.

$streamarray<string, mixed>
@return array<string, mixed>
privateformatName(int $tag): string#

The codec a wave format tag names; empty for one it does not know.

privatevideoCodecs(): array#
@return array<string, string> code => name