官方英文文档链接:https://docs.microsoft.com/en-us/windows/desktop/medfound/video-fourccs
基于05/31/2018
中间跳过了一些,先把media foundation相关的弄完再视频编码知识
许多视频格式都有对应的 FOURCC 码。FOURCC 码是通过四个 ASCII 字符创建的32位无符号整数。例如 YUY2 的FOURCC 码是 'YUY2'。
已经有了各种 C/C++ 宏,用于在代码中声明 FOURCC 码。例如,Mmsystem.h 中定义的 MAKEFOURCC 宏,Aviriff.h 中的 FCC 宏等等。你也可以通过反转字符顺序来直接定义一个 FOURCC 码。因此,以下的语句是等价的:
syntaxCopy
DWORD fccYUY2 = MAKEFOURCC('Y','U','Y','2');
DWORD fccYUY2 = FCC('YUY2');
DWORD fccYUY2 = '2YUY'; // Declares the FOURCC 'YUY2'.
(上面的例子中,必须反转字节顺序,因为 Windows 使用 little-endian 结构。 'Y' = 0x59, 'U' = 0x55, and '2' = 0x32, so '2YUY' is 0x32595559.)
一些 DirectX Video Acceleration 2.0 APIs 使用 D3DFORMAT 值来描述视频格式。FOURCC 码也可以像下面这样使用:
syntaxCopy
D3DFORMAT fmt = (D3DFORMAT)MAKEFOURCC('Y','U','Y','2');
D3DFORMAT fmt = (D3DFORMAT)FCC('YUY2');
D3DFORMAT fmt = D3DFORMAT('2YUY'); // Coerce to D3DFORMAT type.
FOURCC Constants
下面名列出了一些常用的 FOURCC 码
FOURCC value | Description |
---|---|
'H264' | H.264 video. |
'I420' | YUV video stored in planar 4:2:0 format. |
'IYUV' | YUV video stored in planar 4:2:0 format. |
'M4S2' | MPEG-4 part 2 video. |
'MP4S' | Microsoft MPEG 4 codec version 3. This codec is no longer supported. |
'MP4V' | MPEG-4 part 2 video. |
'MPG1' | MPEG-1 video. |
'MSS1' | Content encoded with the Windows Media Video 7 screen codec. |
'MSS2' | Content encoded with the Windows Media Video 9 screen codec. |
'UYVY' | YUV video stored in packed 4:2:2 format. Similar to YUY2 but with different ordering of data. |
'WMV1' | Content encoded with the Windows Media Video 7 codec. |
'WMV2' | Content encoded with the Windows Media Video 8 codec. |
'WMV3' | Content encoded with the Windows Media Video 9 codec. |
'WMVA' | Content encoded with the older, obsolete version of the Windows Media Video 9 Advanced Profile codec. |
'WMVP' | Content encoded with the Windows Media Video 9.1 Image codec. |
'WVC1' | SMPTE 421M ("VC-1"). Content encoded with Windows Media Video 9 Advanced Profile. |
'WVP2' | Content encoded with the Windows Media Video 9.1 Image v2 codec. |
'YUY2' | YUV video stored in packed 4:2:2 format. |
'YV12' | YUV video stored in planar 4:2:0 or 4:1:1 format. Identical to I420/IYUV except that the U and V planes are switched. |
'YVU9' | YUV video stored in planar 16:1:1 format. |
'YVYU' | YUV video stored in packed 4:2:2 format. Similar to YUY2 but with different ordering of data. |