310.684.3047

The "WMODE" Embed Parameter De-Mystified

I'm continuing work on my talk for FITC Toronto 2011 on OSMF and Stage Video in Flash Player 10.2 (although I've come up with a much better title, which will hopefully be updated on the event site shortly).

As I'm doing a bit of research to fill in the details, I'm realizing that the documentation around the WMODE parameter (used when embedding the Flash Player in a web page) can be a bit confusing — in part, because for so long, WMODE was rarely used, and now its usage has changed three times with the last three Flash Player releases. And, at the time that I'm writing this post, Adobe's documentation page explaining WMODE's usage doesn't appear to include any of the information from these three major releases.

WMODE pre Flash Player 10

Prior to Flash Player 10, WMODE was really only used when you wanted your SWF to render transparently (most commonly, on top of other web page content):

  • wmode – Possible values: window, opaque, transparent. Sets the Window Mode property of the Flash movie for transparency, layering, and positioning in the browser.
    • window – movie plays in its own rectangular window on a web page.
    • opaque – the movie hides everything on the page behind it.
    • transparent – the background of the HTML page shows through all transparent portions of the movie. This option can slow animation performance.

WMODE in Flash Player 10

With the introduction of Flash Player 10, WMODE assumed new importance, as usefully described by Tinic in a blog post at the time:

direct: This mode tries to use the fastest path to screen, or direct path if you will. In most cases it will ignore whatever the browser would want to do to have things like overlapping HTML menus or such work. A typical use case for this mode is video playback. On Windows this mode is using DirectDraw or Direct3D on Vista, on OSX and Linux we are using OpenGL. Fidelity should not be affected when you use this mode.

gpu: This is fully fledged compositing (+some extras) using some functionality of the graphics card. Think of it being similar to what OSX and Vista do for their desktop managers, the content of windows (in flash language that means movie clips) is still rendered using software, but the result is composited using hardware. When possible we also scale video natively in the card. More and more parts of our software rasterizer might move to the GPU over the next few Flash Player versions, this is just a start. On Windows this mode uses Direct3D, on OSX and Linux we are using OpenGL.

WMODE in Flash Player 10.1

With Flash Player 10.1, the hardware acceleration behaviors were updated:

In addition to hardware H.264 decoding, mobile devices that support access to OpenGL ES 2.0 can use Flash Player 10.1 to render all graphical elements (except Pixel Bender shaders) using GPU hardware to increase graphics performance. Desktop players will continue to use software rendering; support for hardware rendering is expected in a future release.

Hardware rendering in Flash Player 10.1 differs substantially from the GPU support available in Flash Player 10. The earlier feature, known as hardware compositing or GPU compositing, involved Flash Player using the GPU to layer (composite) graphics when the HTML page included the wmode=gpu embed parameter. In Flash Player 10, the software renderer draws individual graphical elements and then the resulting image is composited to the screen by the GPU using the appropriate blend mode.

Although hardware compositing in Flash Player 10 improves performance in some cases, it can decrease performance in others. In addition, driver support varies widely on desktops. Given these challenges, Flash Player 10.1 on the desktop also composites SWF content included with the wmode=gpu embed parameter in software.

In contrast to the earlier hardware compositing, the new hardware rendering capability available in Flash Player 10.1 uses the GPU rather than with the software renderer to draw graphics. This shift yields dramatic performance improvements with optimized content. Hardware rendered objects include vector graphics, bitmaps, video, text, and filters. With hardware rendering, the GPU renders and composites graphic elements.

Flash Player 10.1 hardware rendering is automatically enabled on supported devices, and it's not necessary to add the wmode=gpu embed parameter to enable it. However, when working with Flash Player 10.1, the wmode=opaque or wmode=transparent embed parameters will disable hardware rendering, causing the software to render the graphics.

WMODE in Flash Player 10.2

Now, with Flash Player 10.2, Adobe has included a feature known as Stage Video, which is designed to further accelerate playback of higher-quality video. One of the catches? You should set the WMODE parameter to "direct" (as opposed to "gpu", which was established as the default with Flash Player 10.1) in order to utilize Stage Video to ensure consistent playback on desktop, mobile and TV devices (note that on the desktop, Stage Video can be used in Full Screen playback mode, regardless of of the WMODE setting):

To make sure stage video will be available, you must use wmode="direct" at all times. This mode is highly recommended for video playback. It uses Direct3D on Windows and OpenGL on Mac OS and Linux to actually perform video frame compositing directly through the GPU. The limitation is that, in this mode, Flash Player runs in its own context and having overlapping HTML content on top of the player is not possible, for instance. If you decide to go with any other mode, such as wmode="window", wmode="opaque", or wmode="transparent", you highly decrease the chances (see note) to have stage video available. As a result, for consistency, it is highly recommended to use wmode="direct" at all times.

In Summary…

Got it?

Before Flash Player 10, you basically used WMODE only if you wanted to make your SWF transparent (which you can still do).

With Flash Player 10, you had to use the WMODE parameter to implement hardware acceleration (at your own risk).

With Flash Player 10.1, Adobe not only improved hardware acceleration, but also made it the default WMODE setting (meaning, once again, you could safely go back to ignoring the WMODE parameter unless you wanted to utilize SWF transparency).

Now, with Flash Player 10.2, you are encouraged to set WMODE to "direct" if you wish to utilize the Stage Video features available in the latest player to improve the quality of the HD videos you are able to deliver to your viewers — this ensures compatibility of video playback on the desktop and mobile and set-top devices — otherwise, you are encouraged to leave it at the default "gpu".

And, don't forget that WMODE="transparent" is still supported in all of these versions (though its usage is discouraged as it conflicts with all hardware acceleration and its performance is not supported on many mobile devices).

Simple enough, right?

Cheerio,

-r

Category: Code & Samples

Tagged: , , , , , , ,

6 Responses

  1. Bauke says:

    Great article. One of the problems with the 'direct' wmode is that the settings menu of flash player seems not to be accesible anymore. Did you have heard of a solution for this?

  2. rblank says:

    Wow. Sir, you are correct. I'm adding that in to the notes for my talk.

    I will add that, since this post was published, Adobe released Flash Player 10.3. With Flash Player 10.3, you can consistently utilize Stage acceleration, with wmode of "gpu" as well as "direct".

    Thank you,

    -r

  3. Abhirama says:

    Thanks for the informative article. A couple of questions:

    "In contrast to the earlier hardware compositing, the new hardware rendering capability available in Flash Player 10.1 uses the GPU rather than with the software renderer to draw graphics."

    Is this applicable only for mobile devices or for desktops also?

    "Although hardware compositing in Flash Player 10 improves performance in some cases, it can decrease performance in other."

    Any pointers as to this happens under what circumstances?

  4. rblank says:

    Hello Abhirama:

    GPU acceleration is applicable to mobile devices, as well.

    In terms of when GPU acceleration can improve or reduce performance, no, I'm not very good at that. It depends on the content you are running, and what type of acceleration you are applying. For me, it's one of those "you know it when you see it" situations, and tweak and re-code as appropriate.

    The best source for info on acceleration, and the importance of wielding that power properly, is Tinic's blog: http://www.kaourantin.net/

    Cheers,

    -r

  5. [...] talk covers a lot of ground, from video compression optimization to WMODE settings — but mostly centers around the StageVideo enhancements in the recent versions of the Adobe Flash [...]

  6. [...] talk covers a lot of ground, from video compression optimization to WMODE settings — but mostly centers around the StageVideo enhancements in the recent versions of the Adobe [...]

Leave a Reply