Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn image sequence into video with transparency [closed]

People also ask

Is there a video format that supports transparency?

The file types that currently support an Alpha (transparency) channel are FLV, F4V, AVI, Quicktime, and WebM. If you're using free programs, you may find they can export in these formats. Often, there will be a named codec for an Alpha channel within the settings of these, or a PNG option.

Can a video file have a transparent background?

The only way to create a video with a transparent background is to have it initially shot in front of a green screen. Once you upload a green screen video to VSDC (or any other video editor that has the Chroma Key tool), you can remove the green color from it, thus leaving the background transparent.


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.


I know this topic is a bit old, but I am posting anyway.

FFMPEG with Quicktime Animation (RLE) or FFVHUFF/HUFFYUV will do.

  • ffmpeg -i yoursequence%d.png -vcodec qtrle movie_with_alpha.mov
  • ffmpeg -i yoursequence%d.png -vcodec ffvhuff movie_with_alpha.avi
  • ffmpeg -i yoursequence%d.png -vcodec huffyuv movie_with_alpha.avi

You will get video files with transparency(alpha channel) preserved.

I have also heard On2-VP6 variation (Not the WebM-VP8 yet) can handle alpha, but I do not have their codec at hand.

This also works. - ffmpeg -i yoursequence%d.png -vcodec png movie_with_alpha.mov


For web developers reaching this question and banging their heads against the wall in frustration… It is possible to create a transparent WebM video, but at the moment you might need to compile ffmpeg and the required libraries from source.

I wanted to display a rendered Blender video in a website but preserve the transparency. The first step was to render the Blender output as individual PNG files. After that, I spent quite a while trying to coerce ffmpeg to convert those PNG files into a single video. The basic command is simple:

ffmpeg -i input%04d.png output.webm

This command loads all PNGs with the filenames input0000.png through input9999.png and turns them into a video. The transparency was promptly lost. Combing through the output I realized ffmpeg was helpfully selecting a non-transparent format:

Incompatible pixel format 'yuva420p' for codec 'flv', auto-selecting format 'yuv420p'

At this point I was realizing I might have to recompile ffmpeg from scratch. I struggled with a few other tools, but ultimately ended up back with ffmpeg. After compiling libvbx and ffmpeg from the latest source, things worked a charm.