Introduction
A .yuv file holds uncompressed video frames one after another, with no
header at all. Each pixel is stored as a brightness value (Y, or luma) and two colour
difference values (U and V, or chroma), usually with the colour at lower resolution
than the brightness. Codec developers and researchers use these files as the input and
output of encoders and decoders.
Because nothing in the file says how it is laid out, the width, height, frame rate and pixel format must be given separately, often in the file name. Opening the file with the wrong settings gives a scrambled picture.
Structure
The most common layout is 8-bit planar 4:2:0, also called I420 or
yuv420p. Each frame is the full Y plane, one byte per pixel, then the U
plane and the V plane, each half the width and half the height. A frame therefore takes
width × height × 1.5 bytes, and the number of frames is the file size divided by
that.
Other layouts exist: NV12 stores U and V interleaved in a single plane, 4:2:2 and 4:4:4 keep more colour detail, and 10-bit formats use two bytes per sample.
0Y plane of frame 0, one byte per pixelw × h…U plane of frame 0w/2 × h/2…V plane of frame 0w/2 × h/2…the planes of the next framerepeated
Links
Software
- YUView, a viewer for raw video (Windows, macOS, Linux)
- FFmpeg and ffplay, with
-f rawvideoand the size and pixel format given (Windows, macOS, Linux) - mpv, with the raw video options set (Windows, macOS, Linux)
Developers
- libswscale, C, FFmpeg’s library for converting between pixel formats