[x264-devel] Animation images seem to darken or lose saturation when encoded with x264

Mo DeJong mo at modejong.com
Fri Jun 21 19:29:00 CEST 2013


Hello

I am looking into encoding Animations to h.264 using x264 via ffmpeg. When I say "animations", I mean computer generated colors, in this case created by an artist in Photoshop. This is not live video, the input clips are rendered frame by frame from Photoshop. What I am seeing is that encoding with x264 seems to make the pixel values darker than they were in the original PNG images. I started with baseline profile and 4:2:0, I also tried 4:2:2 and 4:4:4 and the darken thing seems to happen with each kind of encoding. I then decoded to try to encode with high444, the animation tune setting, and crf 0 in an attempt to disable any encoding that might cause this darken thing.

I am attaching a .apng file to this email so that folks can see what is going on. The animation switch from one image to another slowly, so that it is easy to see the color shift. The ffmpeg I used for this:

ffmpeg -y -i TristanCropped_690_0_720_970.mov -c:v libx264 -pix_fmt yuv444p -preset:v slow -profile:v high444 -tune:v animation -crf 0 TristanCropped_690_0_720_970_CRF_0_24BPP.m4v

This should encode the pixels as 4:4:4 and the crf setting is set to lossless. But, even so the output seems to get darker:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: JustTristan_png_vs_high444_crf0.apng
Type: application/octet-stream
Size: 50876 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x264-devel/attachments/20130621/f9dae188/attachment-0001.obj>
-------------- next part --------------


The darken is very slight with the lossless setting, it is easier to see with this animation which switches between a CRF23 encoding and the lossless one.

The most simple way to view these is to open in Firefox.

Any ideas why encoding with x264 seems to lose some color saturation or darken the input like this? With high444 lossless, it is not so bad, but the effect is much worse with baseline and the default crf 23. It makes the skin tone of the character look a bit like a zombie or something. Since the darken thing also seems to happen with lossless at crf0, could the problem actually be somewhere else in the code?

thanks much
Mo DeJong


More information about the x264-devel mailing list