canvas-sketch icon indicating copy to clipboard operation
canvas-sketch copied to clipboard

[cli] MP4 utility – loss of color richness

Open mattdesl opened this issue 5 years ago • 3 comments

Not sure what's going on but I've noticed a pretty significant loss of colour richness when converting frames into MP4. I'm not sure if this is some limitation of the H264 but it seems like it should be possible to get just as rich colours as with GIF.

For reference:

problem

mattdesl avatar Mar 07 '19 12:03 mattdesl

Would it be possible to have a test case with that picture and the command line used to generate the outputs (or maybe it's already somewhere?) it'd help other people play with the encoder parameters or inspect the original asset colorspace.

dlespiau avatar Mar 20 '19 11:03 dlespiau

After some discussion on Twitter I've landed on the following settings which have a pretty significant improvement in colour richness, and still uploads to Twitter. Have not tested IG but imagine its probably alright there.

ffmpeg -framerate 20 -i tmp/%02d.png -y -an -c:v libx264 -tune animation \
  -preset slow -crf 18 -profile:v high -pix_fmt yuvj420p \
  -x264opts colormatrix=bt709 output.mp4

Some of the richness is still lost, and generally it produces a "brighter" (higher contrast) result than the original. I've also noticed playing the MP4 in QuickTime will always look faded compared to VLC and Twitter video players.

test3

@dlespiau that is a good idea, if I get some time I'll try to put together a set of images for a test like that.

mattdesl avatar Mar 20 '19 11:03 mattdesl

Small update: The colormatrix options produce different results in QuickTime (Version 10.4 / 928.13), but seem to result in the same Twitter/VLC colors regardless of what option you pick. bt470bg and YCgCo seem to be visually the same in these tests, and look the richest in QuickTime compared to the others, so I will use one of those as the default in canvas-sketch-cli.

mattdesl avatar Mar 20 '19 12:03 mattdesl