YUV4MPEG2格式
- 文件扩展名:.y4m
- 格式样例:samples.mplayerhq.hu/yuv4mpeg2/
YUV4MPEG2格式是一种未压缩的视频文件格式,由文件头和各个帧的数据组成,每帧数据是YCbCr420,YCbCr422或YCbCr444格式。下图是y4m格式文件的结构。
数据格式
文件头: 文件头是以明文形式存储的,前10个字节为固定的"YUV4MPEG2 "第十个字节为空格(ASCII 0x20)。紧接着是各个参数,以空格分割(ASCII 0x20)。然后文件头尾部是一个换行(ASCII 0x0A)。
文件头的参数如下:
-
帧宽:'W'后跟明文整数,如'W720'表示帧宽为720
-
帧高:'H'后跟明文整数,如'H480'表示帧高为480
-
帧率:'F'后跟以':'分隔的两个明文整数
- 'F30:1' = 30fps
- 'F25:1' = 25 FPS (PAL/SECAM standard)
- 'F24:1' = 24 FPS (Film)
- 'F30000:1001' = 29.97 FPS (NTSC standard)
- 'F24000:1001' = 23.976 FPS (Film transferred to NTSC)
-
交错方式:'I'后跟一个单字符
- 'Ip' = Progressive
- 'It' = Top field first
- 'Ib' = Bottom field first
- 'Im' = Mixed modes (detailed in FRAME headers)
-
参数'A':表示像素宽高比(注意不是图像宽高比)
- 'A0:0' = unknown
- 'A1:1' = square pixels
- 'A4:3' = NTSC-SVCD (480x480 stretched to 4:3 screen)
- 'A4:5' = NTSC-DVD narrow-screen (720x480 compressed to a 4:3 display)
- 'A32:27' = NTSC-DVD wide-screen (720x480 stretched to a 16:9 display)
-
参数'C':颜色空间
- 'C420jpeg' = 4:2:0 with biaxially-displaced chroma planes
- 'C420paldv' = 4:2:0 with vertically-displaced chroma planes
- 'C420' = 4:2:0 with coincident chroma planes
- 'C422' = 4:2:2
- 'C444' = 4:4:4
-
参数'X':被忽略,不处理
下图是一个y4m视频的格式信息。
Reference
感兴趣的请关注微信公众号Video Coding
