Friday, December 24, 2010

Video YUV 420 NV12 Format and Test Clip

IYUV and I420

This format is the most popular YUV420 format. They comprise an NxN Y plane followed by (N/2)x(N/2) U and V planes. Full marks to Intel for registering the same format twice and full marks to Microsoft for not picking up on this and rejecting the second registration.

Y Sample Period11
U Sample Period22
V Sample Period22

Positive biHeight implies top-down image (top line first)


YUV 4:2:0 image with a plane of 8 bit Y samples followed by an interleaved U/V plane containing 8 bit 2x2 subsampled colour difference samples. It is called as XDM_YUV_420SP by TI XDM.

Y Sample Period11
V (Cr) Sample Period22
U (Cb) Sample Period22

Microsoft defines this format as follows:

"A format in which all Y samples are found first in memory as an array of unsigned char with an even number of lines (possibly with a larger stride for memory alignment), followed immediately by an array of unsigned char containing interleaved Cb and Cr samples (such that if addressed as a little-endian WORD type, Cb would be in the LSBs and Cr would be in the MSBs) with the same total stride as the Y samples. This is the preferred 4:2:0 pixel format."

For conversion from yuv420 IYUV/I420 to yuv420 NV12 to make NV12 test clip, ffmpeg can be used as a IYUV2NV12 converter:

ffmpeg -pix_fmt yuv420p -s 1600x1200 -i 1600x1200_10_420.yuv -pix_fmt nv12 1600x1200_10_nv12.yuv


Ran Shalit said...


Thanks for this post!
I've tried to use the ffmpeg convert to nv12,
I used carphone qcif sample:
But the result seems wrong with any yuv player I've used (i remembered to change the setting for qcif 176x144, and NV12 but it did not help).
Is there something wrong with ffmpeg convert ?


Ran Shalit said...

this is the conversion command I've used:

ffmpeg -pix_fmt yuv420p -s 176x144 -i carphone_qcif.yuv -pix_fmt nv12 carphone_qcif_nv12.yuv


Blog Archive

About Me

My Photo
HD Multimedia Technology player