Flash, FLV, and alpha channels: straight or premultiplied?

| 6 Comments

[Today's post is from Tim Kurkoski, After Effects quality engineer.]

When you render and export an FLV file with an alpha channel and then import the FLV file into Adobe Flash Professional (the Flash authoring application), you may get a colored halo in semi-transparent areas of the image if the background color of your After Effects composition is not black.

To work around this problem, do either of the following and re-render the FLV file:
* Change the background color of your composition to black.
* Change the Color setting to Straight in the Video Settings section of the Output Module Settings dialog box.

This problem occurs because the FLV encoder (the Adobe Media Encoder) only embeds alpha channels as premultiplied with black. The encoding happens after After Effects renders each frame and passes it on to the Adobe Media Encoder, according to the output module settings. This means that if After Effects rendered a frame as premultiplied and the background color was not black, then the background color will become embedded in the visible pixels of the frame.

Adobe Flash Professional and Flash Player only support alpha channels that are premultiplied with black. This is faster and simpler for Flash Player to decode than straight alpha channels. Flash Professional does not have a function to control how alpha channel colors are interpreted.

It is safe to use the straight alpha mode in the output module settings because straight mode does not embed the background color into the pixels. Thus there is no color contamination when the FLV encoder converts the alpha to premultiplied with black. However, the default Color setting is Premultiplied (with the composition background color), so you must change this setting manually every time. If you use this setting frequently you can create a new output module template.

Note: Earlier versions of After Effects have the opposite problem: black as the background color will cause a black halo, while other premultiplied colors may appear OK in Flash. FLV encoding in After Effects CS4 was changed so the default options (black background and premultiplied alpha) will produce a good-looking image. For any version of After Effects, choosing straight alpha will produce a good-looking image.

6 Comments

Thanks a lot for this informative post!

I'm confused: Are you saying the preferred path is to render a straight alpha channel, or premultiplied with black? There are points where both seem to be advocated. Although both may yield "good-looking" results, they won't give the _same_ results, and one would have to be more correct than the other.

These two choices will give different results in AE: the alpha channel will be the same, but the latter will have the background color (black) blended into the color channels where the alpha is semitransparent. And if Flash is expecting the source to be premultiplied with black, then it's going to try to unmultiply black out of the color in semitransparent areas, resulting in a change in the final appearance if black wasn't premultiplied into those areas in the first place.

thanks for any clarification -
Chris

Chris,

You get the same results with either of these two options: straight or premultiplied with black. The reason is that the Adobe Media Encoder takes the straight output and then premultiplies it with black. So these are both routes to the same thing---premultiplication with black.

What you don't want to do is premultiply with a (background) color other than black.

Hi,

I used CS4 AE to export composition after applying Chroma Key and other effects. I generates XFL file (which is ZIP file) and if I extract FLV file from this, it works fine except sudio is missing. What is the problem?

Uday, as the Help document states, audio is not exported to the XFL file.

From "Export a composition as an XFL file to Flash Professional":

"Audio is not exported to the XFL file."

Also, comments on a blog post are not a good way to get answers. If you have a question, ask it on the After Effects user-to-user forum.

very informative post. Thanks for given this great post...

Leave a comment

About this Entry

This page contains a single entry by Todd Kopriva published on June 8, 2009 5:22 PM.

RED REDCODE importer plug-in version 1.7 released was the previous entry in this blog.

mask expansion and rounded corners is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.