After Effects: Trillions of colors possible?

  • Did some exporting from After Effects and it works great from what I can tell. But I couldn't set Trillions of Colors in the Output settings. Can that be enabled in some way? Especially for x265 encodes that would be very useful to not lose any precision. Currently only Millions of Colors can be selected.

  • Thanks a lot Vouk! That does unlock the option for Trillions of Colors however the output contrast/tone curve is pretty off, so I can't even quite tell if the full precision is being carried over. Did the test with ProRes 10 Bit 4:2:2 and compared it to an export using Millions of Colors. Generally speaking the image ends up a bit too dark but that doesn't quite fully describe the problem I think.


    My project was as follows: 32 bit linear floating point, in linearized sRGB. Output color space in the Color Management tab in the export options was set to HDTV (Rec 709).

  • Update: Seems AfterEffects is delivering a 15 bit color value per channel and FFmpeg expects a 16 bit value per channel... that's why its probably half as bright ...

  • Aaah. Funny that... Photoshop does the same. I believe in Photoshop it is a kind of faux 16 bit, where it uses 15 bits for the 2^15 values and the additional bit is used to simply add or subtract 1. They use that to have a perfect gray value which helps them with some filters apparently. I wonder what the correct way to translate that into 16 bit may be.


    Edit: Maybe it would be easier to disable the Trillions of Colors and instead allow floating point? That would take care of the weirdness and heighten the precision too.

  • Yes, I did this by doing the shuffle from argb64 to bgra64 with SSE2 first and then manually shifting one bit left while keeping the maximum at 65535 for each value. This works, but it's also very... "hacky" and slow.


    Maybe it would be easier to disable the Trillions of Colors and instead allow floating point? That would take care of the weirdness and heighten the precision too.

    Yes, thought about that too. That's the way I am doing it for premiere. But as FFmpeg doesn't accept float as input I'd have to convert float to uint16_t first, ... and another color conversion to the target format. Also slow and not really nice.

    Help to improve this plugin and support me on patreon or paypal. Thank you.

  • Well I'd argue converting from float to UInt16 is at least cleaner than doing the weird bit shifting and all that. And has more precision ultimately. Edit: However since you've already implemented the conversion, I suppose having the 16 bit option can't hurt. The floating point would be a nice addition ofc.


    While we're at it, I'm wondering another thing, does ffmpeg have dithering that can be activated to convert to the target pix_fmt? It seems that in the 8-bit mode, After Effects already delivers dithered data, but in the 16 (well, 15) bit mode, it does not appear to do any dithering. And given that output formats like ProRes or HEVC aren't full 16 bit anyway, it might make sense to have an option to activate dithering for 16+ bit input formats to reduce banding for very high dynamic range and low noise content.


    So for example for ProRes the the 16 bit or floating point content would be dithered down to 12 or 10 bit or whatever the encoder does.


    Dithering would be bad for any scientific applications but good for anything artistic, so would be nice to be able to choose. AVISynth for example provides three options: No dithering, ordered dithering and Floyd-Steinberg dither in its ConvertBits() function.


    I wouldn't expect you to implement such dithering yourself of course, just asking in case ffmpeg already offers that.

  • Found a nice SSE2 only way on simply pushing AfterEffects 15 bit data to that 16 bit FFmpeg compatible format. So you'll get AfterEffects' full 15 bit "trillions" precision without any hacks.


    I'll think about float later.


    Regarding dithering: I'm using https://ffmpeg.org/ffmpeg-filters.html#format-1 to do the conversion. Unfortunately it is not documented if dithering is being used.

    Files

    • setup.zip

      (1.08 MB, downloaded 47 times, last: )

    Help to improve this plugin and support me on patreon or paypal. Thank you.

  • Thanks, that seems to work fine!

    Does this take into account the 16th bit which only adds/subtracts a single value? Or is that not the case with AE?

  • Vouk

    Added the Label Done