Log in

View Full Version : Confusion about AVC MP4 gamma and color space


RiMark
15th April 2007, 18:24
Hi, does anyone know how, or with what tool, I can find out the gamma at which an AVC MP4 file was encoded? I found a web page on apple’s web site (http://developer.apple.com/documentation/QuickTime/QT6WhatsNew/Chap1/chapter_1_section_9.html#//apple_ref/doc/uid/TP40000937-DontLinkChapterID_1-TPXREF146) stating that the gamma and color space information should be stored in the MPEG-4 video.

I’ve been looking at the MPEG-4 AVC / H.264 MP4 files created by the new Sanyo CG65 digital movie camera (http://forum.doom9.org/showthread.php?t=124161) and I’m confused about the gamma and color space situation. When I view the files using Quicktime for Windows, the colors look ok, but are washed out. When I view the files using an open source solution then the video looks too dark. If I change the renderer from "default" to a DirectX 3D renderer, then the colors look ok but washed out. The best result for me appears to render using the "default" renderer while setting the gamma image adjustment to 1.3, but I don’t know if this is correct. Therefore I would like to know what the gamma setting for the MP4 files are? The color is encoded YV12 in those MP4 files.

I’m viewing the videos on my PC with a high contrast CRT monitor calibrated to a gamma of 2.2.

Thank you.

bond
15th April 2007, 19:21
i dont know any avc encoder that outputs something different than YV12 colorspace, i would be surprised if you are having something different (the decoder you are using could make a colorspace conversion tough)

you can also try to read out the VUI information of a raw .264 stream with h264_parse from mpeg4ip, it might say there what colorspace it is (tough normally it doesnt)

RiMark
15th April 2007, 21:51
Yes thanks, the color space is YV12. What I didn’t understand is how this color space transforms into RGB space relative to correct gamma, and so I wanted to know where the correct “camera gamma” was registered in the MP4 file or AVC video stream.

I’m now assuming that since this camera appears to follow the NTSC standard, the camera gamma must be 0.454 (1/2.2) (unless it’s using the new ITU-R BT.709 1/1.956? I don’t know). But assuming it is using a camera gamma of 1/2.2, the colors should look perfectly correct rendered on my 2.2 gamma calibrated CRT.

I’ve been searching the web for a while and I came across possible explanations as to why the colors don’t appear to render correctly. From what I can gather the "default" renderer (overlay) does not properly convert YV12 to the RGB color space. It looks too dark on my CRT monitor (gamma 2.2 calibrated). The DirectX 9 renderer however, as found in VLC (DirectX 3D) or MPC (VMR9) utilize my (ATI X800) video card’s YV12 to RBG converter, which apparently does the conversion correctly. This is why the colors look ok using the DX9 renderer. But from what I read, the reason the video looks washed out it because proper YV12 to RGB conversion results in a limited RGB color range, of between 16-235. So the colors have less contrast and appear a little washed out. I seemed to be getting better results using the default (overlay) renderer and bumping up the gamma by 1.3 so that the contrast remained, but the video was less dark. So I think this kinda answers my question, but somehow I’m not quite satisfied with the answer. If anyone can help confirm/clarify this, I would be grateful, thanks.

KoD
18th April 2007, 11:34
Your monitor was calibrated by modifying the LUT table of your video card. However, when using the hardware overlay, the LUT table is not used. That's why even if your desktop and other renderers are now calibrated, the overlay renderer is not.

And yes, it's not easy to guess what was the transfer function used by your camera or any other device or software encoder. A color calibrated workflow outside the desktop publishing realm and some movie studios is still a dream.

RiMark
20th April 2007, 18:19
KoD, thanks very much for that explanation, I hadn't come across this as for why the overlay video looked so different.
Cheers.