Skip to main content
bryan.gough
Inspiring
September 26, 2017
Answered

Exporting RGB workspace with H264 codec loses color contrast

  • September 26, 2017
  • 3 replies
  • 6919 views

I have a hex value that I'm working with (#60A630) on a project in After Effects. I have tried several RGB color spaces and export color management options... but every time, I get a color that does not reflect the source file.

I believe I have read that H264 (which is the codec I have to use) uses the YUV color space. So, there is some translation going on... and I don't know how to account for it.

Is there a way I can ensure that my hex value is translated properly—so that what I see in the source file, is what I can expect in the rendered video?

Correct answer Dave_LaRonde

If you're striving for absolutely-precise colors, you probably won't get it in H.264.

For one thing, it's 8-bit color.  There will be inevitable differences between the colors in a 16 or 32 bit comp and H.264.

For another thing, H.264 uses 4-2-0 color sampling, aka color resolution.  You can think of a video picture as being in two layers:  a black & white layer, and a color layer.  The B&W layer has a full-resolution image -- every pixel on the screen is represented in B&W.  But you can cheat on the color layer.  In rare video codecs you'll have 4-4-4 color sampling, meaning for each & every B&W pixel there's a corresponding color pixel.  It's far more common to have codecs using 4-2-2 color sampling -- for every two B&W pixels, there's one color pixel.  Amazingly, it looks really good, and you can't tell... and there are a boatload of codecs that are 4-2-2.

Then there's 4-2-0 color sampling.  For every FOUR B&W pixels there's one color pixel.  As you can guess, there's a lot of averaging of color values going on.  Oh, it's good enough to fool the human eye, but it won't fool a computer.  And you don't notice it unless there are hard, well-defined edges with lots of color contrast.  It's a virtual lock you'll notice it then.

So long story short -- H.264's the wrong codec for precise color reproduction.

3 replies

Participating Frequently
January 4, 2025

I too am waiting for any ideas to export my Adobe RGB 1998 files into any format I can export to that yield closest to original color-wise etc, maintain as many of the 16-bits as possible (10 is fine).  None of the YUV Apple codecs do the job (any ideas on tricks here, I directly upload things to youtube for one), even Prores 4444 XQ.  8-bit RGB uncompressed is the best I have found, closest to original color color but not as rich, may lack slight contrast.  Apply YUV just not good color-gamut wise.  Can anyone suggest help, advice, or tricks to try?  Most of my footage interpreted as "preserve RGB" and project settings are 16-bit using Adobe 1098 color space for wide gamut.

September 28, 2019

i think adobe community make my hardware work best and everything so cool

Dave_LaRonde
Dave_LaRondeCorrect answer
Inspiring
September 26, 2017

If you're striving for absolutely-precise colors, you probably won't get it in H.264.

For one thing, it's 8-bit color.  There will be inevitable differences between the colors in a 16 or 32 bit comp and H.264.

For another thing, H.264 uses 4-2-0 color sampling, aka color resolution.  You can think of a video picture as being in two layers:  a black & white layer, and a color layer.  The B&W layer has a full-resolution image -- every pixel on the screen is represented in B&W.  But you can cheat on the color layer.  In rare video codecs you'll have 4-4-4 color sampling, meaning for each & every B&W pixel there's a corresponding color pixel.  It's far more common to have codecs using 4-2-2 color sampling -- for every two B&W pixels, there's one color pixel.  Amazingly, it looks really good, and you can't tell... and there are a boatload of codecs that are 4-2-2.

Then there's 4-2-0 color sampling.  For every FOUR B&W pixels there's one color pixel.  As you can guess, there's a lot of averaging of color values going on.  Oh, it's good enough to fool the human eye, but it won't fool a computer.  And you don't notice it unless there are hard, well-defined edges with lots of color contrast.  It's a virtual lock you'll notice it then.

So long story short -- H.264's the wrong codec for precise color reproduction.

bryan.gough
Inspiring
September 26, 2017

Thanks Dave. We are delivering videos to mobile phones via MMS... and the way we do this is by using H264 to get the files small enough to pass mobile carrier file size limits... so H264 isn't something we can change—that is what is supported by all (most) mobile devices. So now I'm looking in to RGB to YUV conversion... because our END product needs to deliver "brand-approved" colors. Actually, it's more important (this whole thing was kicked off by our client's accessibility department complaining about low contrast ratios) that the contrast meet a AA standard. So... we'll work with client to find an RGB that, when converted to YUV, still provides enough contrast.

Dave_LaRonde
Inspiring
September 26, 2017

Well, as long as the client likes it, you're okay.  And the client looks at the files on just one phone.  Because colors will look different on iPhones, Samsung phones, etc.

Consistent color is beyond your control once it's in the real world.  Just walk into a Best Buy and look at all the big, fancy TV sets on the same channel.  You'll be hard-put to see any consistency!