December 15, 2010
Flash video gets dramatically more efficient
Flash Player didn’t start out trying to become the world’s most popular video player, but life takes some interesting turns. Instead of just playing linear media files, Flash makes video part of a flexible rendering pipeline. Engineer Mike Melanson posted an excellent summary earlier this year:
In addition to decoding the data, [Flash] has to convert YUV data to the RGB colorspace and combine the image with other Flash elements. Then it has to cooperate with another application (web browser) to present the video to the user… It plays linear media files from start to finish while combining the video with a wide array of graphical and interactive elements (buttons, bitmaps, vector graphics, filters), as well as providing network, webcam, and microphone facilities, all programmable via a full-featured scripting language.
Good news, though: the new Flash Player 10.2 (download the beta) offers a new, video-playback-optimized mode called Stage Video. Building on top of the GPU acceleration added earlier this year, Stage Video can
leverage complete hardware acceleration of the video rendering pipeline, from video decoding to scaling/blitting, enabling best-in-class playback performance. Stage Video can dramatically decrease processor usage and enables higher frame rates, reduced memory usage, and greater pixel fidelity and quality.
Here’s a demo* showing a 10X reduction (!) in CPU usage:
Stage Video requires Flash developers to update the code in video players, so simply updating to the new player won’t automatically improve CPU usage on all sites, but YouTube has already updates its player & others will follow. If you’re a Flash developer and want to start experimenting, check out this tutorial from Lee Brimelow.
* For some reason the audio/video sync in the footage is slightly screwed up. That’s a problem with the source video file, not with Flash Player.