I’ve had several questions since we launched Flash Player 9.0.115.0 about what new APIs need to be called to play back H.264 video. The short answer is that you don’t need to do anything to use H.264 other than have the new player and some H.264 content.
Well, that is pretty much the long answer too. The cool thing though is that you just don’t need to re-build your SWFs at all. If you have a video player SWF that is exported for Flash Player 7, it can play H.264 media files just the same as it can play FLV files. The “magic” is all in the new player.
I think some of the confusion comes in the form of just what the heck a compatible H.264 file is. There are a few topics that when I try to wrap my brain around them, I feel less informed than when I started. During the development process for 9.0.115, I added video to that list. Let me try and explain what I’ve learned so far in hopes that you can avoid some of the confusion I was suffering from.
Up until this version of Flash Player, we supported two codecs (Sorenson Spark and On2 VP6). Both of these were packaged in an FLV container (how the video bits are organized in a file). Now we have added support for a new codec, H.264, but we require that H.264 content to be in an Mpeg 4 container.
The good news is that this is a really common configuration. Many .mov, .3Gp, and .M4V files are H.264 content in MP4 containers. However, there are times where a .mov file or .m4v file may contain something different. In those cases, Flash Player can’t do anything with them. If you are encoding your files it is pretty easy to get it encoded correctly, but if you are working with already encoded content, the easiest way to see if the file is compatible is to just try playing it in Flash Player and see if it plays back.
Now, if all of that about video codecs and container types (file formats) made sense, thanks for reading, but please stop now. I don’t want to bring yopu back into confusion. For those that are still scratching their heads, let me try a metaphor.
Let’s say that I wanted to communicate the concept of “hello” from a server down to a SWF. The concept gets “encoded” into the English word “hello.” If I had chosen to speak Spanish, I could encode the concept into language as “hola.” Think of this choice as the codec. I started with a raw mental concept of a greeting and chose either an English or Spanish codec.
Now, I need to get that actual word down to a running SWF. That could be through XML or it could be through AMF (remoting). Either way I am sending the English word “hello” but for the SWF to correctly process it and use it in the application I need to serialize the data in a format like XML:
<message>hello</message>
This XML wrapper is like the MP4 file format where FLV might be something more like AMF. Both are great but you can’t use them interchangeably.
For bonus points, There are also things called “profiles” of H.264. Flash Player supports a lot of them, but if you want to extend the metaphor above, a profile is like the character encoding of the text. The concept is still the same, it is still English, and it still will be delivered in HTML, but the way the system turns the characters back into the specific characters h-e-l-l-o is different.
If that last bit lost you don’t worry, you’ll probably get a deeper dive on it should you run into the issue head first. Luckily as a Flash developer that should be a rare case since Flash Player supports such a wide range of profiles.