Pixel format: RGB YUV and Bayer

The three have been confusing to me due to terminology. To be more accurate, I use rgb24 yuv420p and bayer_rggb8 instead, which can be found in the output of “ffmpeg -pix_fmts”

  1. rgb24: one byte for each RGB component, and therefore three bytes per pixel.
  2. yuv420p: one byte luma for each pixel, and two bytes chrominance is shared by four pixels. therefore, one and half bytes for each pixel.
  3. bayer_rggb8: only one byte per pixel. In another word, only one of the RGB color is saved for each pixel.

Their strength:

  1. rgb24: the most straightforward.
  2. yuv420p: 1. save memory spaceĀ  2. in different color space of YCbCr, therefore gives a different perspective of the colors
  3. bayer_rggb8: save memory space, and it’s in the same color space as rgb24.

Camera sensors use bayer_rggb8 instead of rgb24 in order to lower the cost. For each pixel, it would need three sensors to capture all three RGB components.


Literally, what does YUV420 mean?

We know what YUV420 is, but literally what does the 0 mean?

In short, 0 means 0 uv values are sampled in the second row.


4: for each 4 pixels in each row

2: 2 uv samples on first row.

0: 0 rv samples on second row: reusing uv samples on first row.

Therefore, for YUV422, second 2 means second row is sampled the same way as the first row.