I'm trying to fit small part of a video on the larger static PNG background and the edges of the video are supposed to seamlessly blend to the background, ie. you shouldn't be able to recognize where the video ends and static image in the background starts.
However, I found out that every browser renders the video colors differently. In Chrome, it depends whether you add ANY CSS filter (-webkit-filter) property, for example
filter: saturate(100%)
(which shouldn't change the video at all). I created this JSFiddle to demonstrate the problem https://jsfiddle.net/bj4hshwz/1/. Without it, it renders the video slightly brighter. With the filter property, the video is darker/more saturated (and matches the background in my case). Firefox renders the video correctly and it matches the background and in Safari, it's always brighter, whether you add the filter or not.
Is there a way how to make the video in Safari also correct?
The no-op filter changing rendering is a bug. You should report it to the browser vendor. Your reduced test case is going to be helpful for fixing this.
Apart from that, there's a problem of color profile handling in videos, and it's a bit of a mess.
Images and CSS colors on the web generally settled on the sRGB color space, but videos internally use a few other color spaces, most commonly Rec. 709 (for HD) and BT. 601 (old SD TV).
The problem is these profiles are similar enough that a lot of software doesn't care about converting between them, or converts incorrectly (which so easy, because there are so many subtly incompatible color spaces called "YUV"). Only when you try to match colors exactly (like you do), the error becomes noticeable.
Rec 709 has gamma ~2.4 and sRGB has gamma ~2.2, so software that doesn't convert precisely between them is going to make brightness slightly off. 709/601 mix-up is going to shift hue a bit.
To get video colors match CSS colors exactly all the stars must align:
You can count on Safari doing all of this correctly, but in other browsers it's generally hopelessly buggy. Consider changing your design to hide the discrepancy?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With