- Extension: .y4m
- Samples: http://samples.mplayerhq.hu/yuv4mpeg2/
YUV4MPEG2 is a simple file format designed to hold uncompressed frames of YCbCr video formatted as YCbCr 4:2:0 data for the purpose of encoding, likely to MPEG-2. The part "YUV" in its name just derives from the fact that the color space YCbCr (used for color encoding in digital media) is often falsely mixed up with the color space YUV (used in analog PAL based applications, including analog TV and video tapes).
A Y4M file begins with a plaintext, quasi-freeform header. The first 9 bytes form a file signature of 'YUV4MPEG2' followed by a space (ASCII 0x20). Following the signature is any number of parameters separated by a space (ASCII 0x20). The parameters that should definitely be present are width, height, and frame rate:
- frame width: 'W' followed by a plaintext integer; example: 'W720'
- frame height: 'H' followed by a plaintext integer; example: 'H480'
- frame rate: 'F' followed by the number of frames per second, a colon, and a 1 (need more information on this one --Multimedia Mike); example: 'F30:1'
Other parameters include:
- interlacing: 'I' followed by a p to denote progressive scan (what indicates interlaced? 'i'? Are there any other modes? --Multimedia Mike); example: 'Ip'
- Parameter 'A': Unknown; perhaps aspect ratio? example: 'A0:0'
Following the header is any number of frames coded in YCbCr 4:2:0 format in Y-Cb-Cr plane order. Each frame begins with the 5 bytes 'FRAME' followed by a sixth byte of 0x0A. The length of each frame can be computed as:
frame length = width * height * 3 / 2