Bluish Coder

Programming Languages, Martials Arts and Computers. The Weblog of Chris Double.


H.264/AAC/MP3 decoding support for Boot To Gecko

Bug 714408 landed on mozilla-central today. This adds the ability to decode video and audio that uses the H.264, AAC and MP3 codecs on B2G. This support is exposed through the standard HTML video and audio elements. If you're running B2G built from the latest mozilla-central then the following video MP4 video should work:

Sorry, your browser doesn't support HTML video

Of course, WebM works on B2G too using our builtin decoders:

Sorry, your browser doesn't support HTML video

Support for the H.264, AAC and MP3 codecs is provided by using the android 'libstagefright' library which allows hardware accelerated decoding of some video formats. The current implementation is still a work in progress and there are some bugs and performance issues that need to be addressed but playback is at least working.

The Firefox decoding engine was modified to enable decoders to be loaded from a shared library. This 'PluginDecoder' is enabled using the compile time configure switch "--enable-media-plugins". One specific plugin is implemented, omx-plugin. Building this is enabled using the configure switch "--enable-omx-plugin". The combination of these two switches gives support on B2G and those switches are turned on by default in the mozilla-b2g git repository.

What about support for Firefox on Android? The same basic approach can work on some devices running stock Android. There is work ongoing to get H.264/AAC/MP3 decoding working reliably on Android. There are differences between Android versions in the stagefright API and this needs to be handled. Possibly by having different plugins for each android version, or having the plugin dynamically determine what functions to use at run time. B2G was easier (and one reason why it was done first) since we control the specific libstagefright version used.

What about support for desktop? This is trickier since some desktop operating systems don't include H.264, AAC or MP3 decoders. Exactly what the desktop story is is under discussion (I believe - I'm not aware of any specific decision being made about support yet). A GStreamer decoder was recently landed but is not built by default. Using the configure switch "--enable-gstreamer" results in it being built and provides support for H.264. This works on Linux. It may work on GStreamer for Windows/Mac but I haven't tried.

If you're testing B2G please try out the new decoding support and raise bugs for things that don't work. This will help us have better Android support too if we can squash as many implementation issues as possible at this early stage while Android support is being worked on.


This site is accessable over tor as hidden service 6vp5u25g4izec5c37wv52skvecikld6kysvsivnl6sdg6q7wy25lixad.onion, or Freenet using key: