Turn image sequence into video with transparency


I've got what seems like it should be a really simple problem, but it's proving much harder than I expected. Here's the issue:

I've got a fairly large image sequence consisting of numbered frames (output from Maya, for what its worth). The images are currently in Targa (.tga) format, but I could convert them to PNGs or other arbitrary format if that matters. The important thing is, they've got an alpha channel.

What I want to do is programatically turn them into a video clip. The format doesn't really matter, but it needs to be lossless and have an alpha channel. Uncompressed video in a Quicktime container would probably be ideal.

My initial thought was ffmpeg, but after wasting most of a day on it it seems it's got no support at all for alpha channels. Either I'm missing something, or the underlying libavcodec just doesn't do it.

So, what's the right way here? A command line tool like ffmpeg would be nice, but any solution that runs on Windows and could be called from a script would be fine.

Note: Having an alpha chanel in your video isn't actually all that uncommon, and it's really useful if you want to composite it on top of another video clip or a still image. As far as I know uncompressed video, the Quicktime Animation codec, and the Sorenson Video 3 codec all support tranparency, and I've heard H.264 does as well. All we're really talking about is 32-bit color depth, and that's pretty widely supported; both Quicktime .mov files and Windowss .avi files can handle it, and probably a lot more too.

Quicktime Pro is more than happy to turn an image sequence into a 32-bit .mov file. Hit export, change color depth to "Millions of Colors+", select the Animation codec, crank the quality up to 100, and there you are – losslessly compressed video, with an alpha chanel, and it'll play back almost anywhere since the codec has been part of Quicktime since version 1.0. The problem is, Quicktime Pro doesn't have any sort of command-line interface (at least on Windows). ffmpeg supports encoding using the Quicktime Animation codec (which it calls qtrle), but it only supports a bit-depth of 24 bits.

The issue isn't finding a video format that supports an alpha channel. Quicktime Animation would be ideal, but even uncompressed video should work. The problem is finding a tool that supports it.

Best Solution

Yes ffmpeg certainly does support alpha channel in a video file. Not all codecs in ffmpeg seem to support alpha yet tho. Motion PNG in a .MOV file is one good combination for alpha.

To encode/import images with alpha to a video with alpha try: ffmpeg -i %d.png -vcodec png z.mov

Quicktime will play that.

To decode/export a video with alpha to images with alpha try: ffmpeg -i z.mov -f image2 export2\%d.png

Note that I exported them to a directory called 'export2'. Be sure to leave the %d parts in there. These commands will work as is on a Windows system. Linux/Mac users may need to add quote marks and swap some \ for / as usual.

Related Question