by donatj · 2y ago · 0 comments
The first video was the content I desired, the second video was solid white but for the same length of time as the first video. I was honestly a little flummoxed about the white stream for about 15 seconds before it hit me "this must be an alpha channel".
I don't suspect I have ever seen it in action, so I am extremely curious how well alpha channels can possibly turn out with lossy video formats where the result of any given frame is a matter of interpretation? In lossless formats like GIF the borders of objects at any given frame are perfectly defined, but lossy formats, especially ones using discrete cosine transform, where the object ends and background begins is not clear cut.
From my testing VP9 videos with transparency are fine if you aren't stingy with bitrate, and in general if source material isn't CGI things will be crusty at edges anyway (e.g. greenscreen with motion blur).
What's that?
A blurry alpha channel is just having soft edges. A naive encoder will cause some of the previously transparent background bleed into visible pixels, usually causing darkened halos around the edges. This is a common problem in video game assets, and the fixes are the same: either bleed color around the edges (make transparent pixels have the right RGB values), or use premultiplied alpha color space. AVIF (also in theory) supports marking images as having premultiplied alpha.
Also premultiplication is just a way to cache the multiplication operation:
// using normal image
// note that everything after the plus depends entirely on the image
out = current * (1-img.a) + vec4(img.r*img.a, img.g*img.a, img.b*img.a, img.a)
// using premultiplied image
out = current * (1-img.a) + img
Which might make sense if you're drawing same bitmap very many times. a statement that the GIF image file format is limited to 256 colors is simply false.
https://web.archive.org/web/20140908023322/http://phil.ipal....How is pretty sneaky.
(still feels very stupid to have to do it but until Google Docs lets you embed a silent auto playing mp4…)
A gif is lossless in that it does not lose data. When you define a frame within the formats limitations, you will always receive that exact frame in return.
The conversion might have lost data but that's not the gif losing it. That's just what happens trying to fit a larger domain in a smaller domain.
The individual frames within a gif are bitmaps that do not lose detail across saves, extractions, rotations, etc. Each individual pixel is displayed exactly as originally defined.
Compare this to JPEG or MP4 where your individual pixel becomes part of a larger cosine field. There is no guarantee this pixel will exist and even if it does, its exact value is almost certainly changed. This is what "lossy" is.
Only assuming your base images have that many bits of information.
Most cameras max out at 16 bits per channel when shooting RAW, and even those rarely have mostly noise in the lower bits.
I'm sure you can find an example of some supercooled telescope sensor that actually does capture 16 bits per channel, maybe even more.
In the real world your image source is usually either JPG (24 bits per pixel, already debayered and already lossy) or RAW (16 bits per pixel max, bayered).