On HTML5 audio formats - AAC and Ogg

1
Official Construct Post
Ashley's avatar
Ashley
  • 18 Jul, 2011
  • 1,178 words
  • ~5-8 mins
  • 19,154 visits
  • 0 favourites

In your HTML5 games made with Construct 2, I'm sure you want sound effects. I've been thinking about the audio features that we need to add. I've ended up worrying a lot about audio formats, because there's no one format that all browsers support. Let's look at the situation as it is now.

There are basically four options to choose from: WAV, MP3, Ogg and AAC. Not all browsers support all of them, but we'll come to that.

Wave (WAV)

WAV (in its most common PCM format) is uncompressed audio. As a result, the files tend to be really big. It would be a shame if nobody played your game because instead of downloading in 10 seconds, it took 2 minutes, of which 1 minute 50 seconds was downloading WAV files. It's like having all the images on your website in BMP format. Nobody does that! So we really need a compressed format.

MP3

The best-known compressed format is MP3. However, it is stringed up with royalty payments. The license requirements for MP3 state you have to pay 2% of all revenue over $100k if you distribute MP3 files. More importantly, there's an ambiguous page stating if you distribute 5000 copies of a game using MP3 technology, you're obliged to pay a $2500 license. Does that mean 5000 pageviews of a HTML5 game? It's not clear, so MP3 is probably best avoided.

Ogg Vorbis

Ogg is basically an open-source, patent-free, royalty-free version of MP3. Great! Unfortunately Internet Explorer and Safari don't support it.

(Note: Ogg is the container and Vorbis is the audio codec, but I'll refer to it as Ogg for brevity.)

Advanced Audio Coding (AAC)

AAC, part of MPEG-4, is a successor to MP3 (which was part of MPEG-1 - MP3 derives from "MPEG-1 layer 3"). It's a modernised compressed audio format, which creates smaller files than MP3 which also sound better. Amazingly, the license fees for AAC are much more relaxed than MP3! You are free to use AAC as much as you like in your games. For us, we might need to use an encoder to save your sounds in AAC for you. I'm not certain so I've emailed them to check, but it looks like we need to pay a $0.98 royalty per unit sold. That's fine - no web developers have to pay, we're just a special case since we want to encode AAC files in Construct 2. AAC is a great technology developed over many years by hard-working individuals. It's not unfair they ask us for royalties to encode it, and in fact very generous to let web developers use it royalty-free. You'd never have to worry about license fees to use AAC in your games. Great - but Firefox doesn't support it!

HTML5 browser audio support

These browsers were tested on Windows 7. The AAC audio was in .m4a format.

Browser Ogg MP3 AAC Wav
Internet Explorer 9 No Yes Yes No
Firefox 5 Yes No No Yes
Chrome 12 Yes Yes Yes Yes
Safari 5 No Yes Yes Yes
Opera 11.5 Yes No No Yes

The format support headache

So, we have AAC that Firefox doesn't support, and Ogg that Internet Explorer and Safari don't support. (Shout out to Chrome: thanks for being awesome and supporting both! Opera, sorry but you're a bit too small to get angsty over AAC for. Good job supporting Ogg, though.) Ogg is an open standard and royalty free - there's really no reason for anyone not to support it. However, AAC is also very relaxed about its license. It doesn't cost anyone anything to use it, except Mozilla, who need to pay for a decoder license, and us, since we want to distribute an AAC encoder. I'm not in charge of the licensing, but judging by the site, it would cost Mozilla a one-off $300,000 to support AAC (for "PC enabling software"). Hopefully the developers of a browser over a quarter of all internet users use aren't so hard up that they can't afford this.

Mozilla argue that Ogg is better for the web because it's royalty and patent free. AAC may involve patented technology, but it's royalty free as well, for web developers! It's a good enough deal that Chrome, Internet Explorer and Safari all support AAC. In theory, the AAC license fees could change and they could start hounding users for money. However, this would be suicide with Ogg there as an option. I bet AAC would be dumped in favour of Ogg pretty quick! If Internet Explorer and Safari still didn't support it, I guess those users just wouldn't get sound, so there'd have to be a little message telling them another browser could be doing better so they should switch... but that's a question for if it happens. It probably won't - especially not if Ogg is a well-supported free alternative.

Internet Explorer and Safari have no good reason whatsoever to not support Ogg. Ogg is the preferable option, since we can encode it in Construct 2 for free. They might blow some security issues way out of proportion like Microsoft did with WebGL, but basically they're making life more difficult for us HTML5 developers for no good reason at all. Thanks, guys.

(If you're at Microsoft and reading this, hi! Please support Ogg in Internet Explorer! By the way, my internship was fun, thanks!)

Anyways, for the time being, we will grudgingly endorse this ridiculous technology circus and support two formats when one could have done the job just fine. Mozilla, please get over your bearded-hippy idealism and just pay the AAC license so we can have one format that works near enough everywhere. Internet Explorer and Safari, please get over your corporate feet-dragging over open standards so we can have one format that works everywhere, and to force AAC to stay free, and so smaller browser makers can get away with just Ogg ($300k might be a bit of a hit for Opera or any innovative new browsers). Come on everyone, this is stupid. Some of us are trying to develop for the web here. Thanks.

(P.S. Maybe the same is true in the video format war - if everyone supports both a patented codec and a free one, the patented one is forced to stay free. The patented one is probably also better, since it probably had commercial research put in to it, resulting in the patents. So if everyone supports both, we get a commercial-quality format for free, backed up by a good-enough patent-free format. Then, lo and behold, we can actually upload one file and have it work in all browsers! It might be a sane situation for web developers! Hurrah! Oh, well, one can dream.)

Edit 20th July: updated compatibility table, removed some over the top angsty-ness. :) But hey, it's a frustrating situation for us.

Subscribe

Get emailed when there are new posts!