YUV4MPEG2

YUV4MPEG2

YUV4MPEG2 is a simple file format designed to hold uncompressed frames of YCbCr video formatted as YCbCr 4:2:0, YCbCr 4:2:2 or YCbCr 4:4:4 data for the purpose of encoding, likely to MPEG-2. The part "YUV" in its name just derives from the fact that the color space YCbCr (used for color encoding in digital media) is often falsely mixed up with the color space YUV (used in analog PAL based applications, including analog TV and video tapes).

[ edit]

Data Format

A Y4M file begins with a plaintext, quasi-freeform header. The first 10 bytes are a file signature of 'YUV4MPEG2 ' (last character is a space, ASCII 0x20). Following the signature is any number of parameters preceeded by a space (ASCII 0x20). The parameters that should definitely be present are width, height, and frame rate:

  • frame width: 'W' followed by a plaintext integer; example: 'W720'
  • frame height: 'H' followed by a plaintext integer; example: 'H480'
  • frame rate: 'F' followed by the number of frames per second, expressed as a fraction in the form numerator:denominator. Examples:
    • 'F30:1' = 30 FPS
    • '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)
  • interlacing: 'I' followed by a single letter to indicate interlacing mode:
    • 'Ip' = Progressive
    • 'It' = Top field first
    • 'Ib' = Bottom field first
    • 'Im' = Mixed modes (detailed in FRAME headers)
  • Parameter 'A': Pixel aspect ratio. Note that this is not the ratio of the picture as a whole, just the pixels. Examples:
    • '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)
  • Parameter 'C': Colour space
    • '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
  • Parameter 'X': Comment. Ignored, but passed, by a YUV4MPEG2 processor.

Following the header is any number of frames coded in YCbCr format in Y-Cb-Cr plane order. Each frame begins with the 5 bytes 'FRAME' followed by zero or more parameters each preceded by 0x20, ending with 0x0A. This is then followed by the raw bytes from each plane.

The length of each frame (excluding its header) can be computed as:

  • frame length = width * height * 3 / 2 (4:2:0)
  • frame length = width * height * 2 (4:2:2)
  • frame length = width * height * 3 (4:4:4)
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值