MPEG-4 and alpha transparency - the ongoing saga

9.2k Views Asked by At

I'd like to reach some sort of definitive answer for the following questions:

  1. Is alpha transparency supported in MPEG-4-based codecs?
  2. Is there any way to be reasonably certain that there is no alpha-channel from the output of ffprobe?

Some links I've found on the subject:

Also, transparent alpha layers, an optional part of the H.264 specification, are now supported in H.264-based QuickTime movies.

The support for alpha channel in the H.264 decoder is now available in Intel® Integrated Performance Primitives 6.0 version.

The MPEG4 Simple Studio Profile supports auxiliary channels, which could be used for alpha or depth -- and presumably even displacement, motion vectors, normals, etc.

However, I've never seen a concrete example, or indeed any details on how you use these announced features.

2

There are 2 best solutions below

5
On

H.264 has an auxillary channel, set in place in codec and format specification as useable in providing transparency. I have not seen an encoder capable of using it.

(PDF download only) https://www.itu.int/rec/dologin_pub.asp?lang=e&id=T-REC-H.264-201106-S!!PDF-E&type=items you can read about it here. It's a bit dense, but the International Telecommunication Union's spec for H.264 encoding explicitly states transparency(and additional luma maps) as being a use for the specification's auxiliary channel. However it also notes "The... decoding of auxiliary coded pictures is not required" and I don't think it was ever used in an official capacity.

The confusion is likely because mp4 and quicktime can both use the h.264 codec, but quicktime, (both the container and player) supports transparency, so theoretically mp4 can be encoded with it as well, though it would require a dedicated decoder. I have seen a hack that simply encodes an alpha layer to another video or at the end of the file. Adobe video export can default to uncompressed RGBA in the case that quicktime alpha output is requested, meaning you can ask for h.264 quicktime, request alpha, and get a quicktime with transparency that is not h.264. This confused me in testing and took a couple tries to figure out what had actually happened to my file. Combined with confusion over quicktime player and wrapper(they support both H.264 and alpha but not simultaneously), all of this could be a source of public confusion.

This is incredibly late, I understand, but these videos, I believe, primarily come from After Effects' and Adobe's encoders and decoders, which are Apple-blessed, and therefore take advantage of Apple quicktime player's RGB+A decoding update which was not related to its h.264 characteristics. Adobe removed them when Apple deprecated both quicktime and the de4dicated player, but the wrapper was added back after years of public protest because there was no functionality to replace the workflow. It is indeed a saga.

Apple has deprecated quicktime, and it's been deprecated for years, but is still in active use in VFX because to my knowledge neither Apple nor Adobe supplied a replacement for video that was both heavily compressed and supported alpha. Webm is looking like a modern replacement, but its support by third parties is spotty, and AV1, touted as an h.264 replacement does not seem to officially support it at all.

(edited for correctness- mostly the bold stuff. sorry people who noted I had it a little backwards! quicktime being deprecated and prores and uncompressed RGBA using the same extension as quicktime really obfuscates things... premiere had the codec ommitted because it was uncompressed, which turned me around as I hadn't requested it.)

2
On

The short answer is that h.264 does not support an alpha channel since no decoder/encoder support the functionality. See this creativecow forum post for more info. While an alpha channel does not work in the h.264 video itself, it is possible to use 2 different h.264 videos to get the same effect. See my post to the creativecow forum for more info.