The never ending issue of dual-encoding

2
Official Construct Team Post
Ashley's avatar
Ashley
  • 30 Oct, 2013
  • 1,459 words
  • ~6-10 mins
  • 2,271 visits
  • 0 favourites

I've ranted a fair deal about the problem of audio codecs in HTML5 already. Here's some older Scirra blog posts on the subject - note however that some of the details are now out of date, especially regarding browser support:

The last one is coming up to 2 years old, though. And given that it's still a problem, things have changed a bit, and we now have our own personal blogs on Scirra... yep... time for another blog post about it! :)

The tl;dr of those previous blog posts is:

  • Audio codecs are a way of compressing audio so it's quicker to transmit. Some examples are: MP3, AAC, Ogg Vorbis, WMA...
  • Browser makers cannot agree on a single audio format for the web.
  • As a result, there is not one audio format that plays in all browsers.
  • This is a problem if you're making a HTML5 game. What format should your sounds and music be?
  • We've found AAC and Ogg Vorbis covers all modern browsers, so Construct 2 dual-encodes all your audio to both of those formats.
  • However, it would sure be nice if we could just have one format that plays everywhere.
  • In my opinion that format should be Ogg Vorbis, since it's free, open source, and very good.
  • But Microsoft and Apple don't want to support Ogg Vorbis.

So what's changed?

AAC/H.264 and the history of the Internet

Mozilla now support decoding formats that the operating system can, and they plan to adopt Cisco's new open source H.264 decoder, which may also cover AAC audio. If that's the case, we're pretty close to having universal support for H.264 and AAC for video and audio in all browsers.

Unfortunately, it's the wrong choice.

The Internet is built on a slew of open, patent-free, royalty-free technologies. To name a few, these include Ethernet, IPv4/IPv6, TCP, UDP, DHCP, HTTP, IMAP, POP, TLS/SSL, HTML, Javascript, CSS, PNG and JPEG. These cover everything from the network interfaces at your ISP to the format of photos in a web page. There are even more: see Wikipedia's article on Internet protocol suite to go further.

MPEG-4 AAC and H.264 are the first cases I'm aware of where non-free patent-covered technologies look poised to gain a serious position in the long list of Internet technologies. Imagine if TCP, or HTTP, were covered by patents and in some cases required royalties. Could the Internet have become as successful as it is now with a corporation exterting its control over it? I doubt it. The codec situation sets a dangerous precedent.

The Internet is surely one of mankind's greatest engineering accomplishments, and it probably got there in part by being free, open and not under any single organisation's control. Any attempts to change that must be resisted.

Mozilla have tried their best to resist this, but they more or less stood alone. They may fight for the right thing, but they also have to make a competitive browser - so they've had to compromise and support patented formats in some cases.

It's not over though: we can continue to work towards universally supporting a format that is free and open. Then perhaps one day in future we can switch over to using that. In the mean time, I have strong criticism especially for Microsoft and Apple who are holding back on supporting free and open formats like Ogg Vorbis. While both companies have done a great deal for the web in their own ways, this does seem to be a case of trying to exert corporate control over the web at the expense of those who use it.

Even more codecs!

There are already loads of codecs for both audio and video. However only a few have ever gained any traction with web browsers - mainly Ogg Vorbis, MP3, and AAC. There's also WAV, which is usually uncompressed PCM data, and far too large to be practical for delivery over the web. MP3 has such a ridiculous license it shouldn't be touched with a barge pole. AAC is still patent-encumbered; it's free for end-users to use, but it may not be forever, and it's not free for tool developers like us since shipping encoders still comes with fees. Microsoft and Apple appear to be hiding behind the excuse that Ogg Vorbis is vulnerable to "submarine patents", which in my humble opinion is corporate-speak nonsense that translates in to "ermahgerd, we can't make money off that!". (Google have supported Ogg Vorbis for ages now, and if they're not a juicy patent torpedo target, who is?)

So how do we solve this problem? Obligatory XKCD!

Invent a new one! Opus is a new, open-source, royalty-free audio codec, also designed to dodge any patent issues. To be fair, it looks pretty great. It merges a speech-specific codec with a general purpose codec, so it's suitable for everything from voice calls to downloading music. It would be a good candidate for mandatory support with WebRTC calls.

But will everyone support it? The W3C did try to standardise Ogg Vorbis for HTML5, but a few companies threw their toys out of the pram and insisted, and we ended up with dual-encoding. At time of writing, only Firefox already supports Opus (check on caniuse for more up-to-date support). And even if every browser supported it tomorrow, there are still lots of old browsers to support, and those will still need AAC or Vorbis. Three-way encoding is ridiculous especially if the two current formats already cover everything. So at best, we could replace our dual-encoding with just the single Opus format a few years after it becomes universally supported. Even at best this is years away.

On the video front, Mozilla and Xiph are working on a new codec called Daala. Again, Theora already exists and is free and open, and still didn't see universal adoption.

I hope that both Opus and Daala are so good everyone wants to support it! The fact some browser makers have already put up significant resistance against existing free formats worries me, but we'll have to wait and see what happens.

Keep up the pressure

The best way to move on from here is keep up the demand for free and open formats. If you speak to any Microsoft or Apple employees or representatives through work or events, let them know we want support for free codecs. If you work for Microsoft or Apple, push the issue internally - it can count for a lot more if the pressure comes from within. It's important for the future of the web, and is also technically far superior to have one format that works everywhere. In fact, it's completely ridiculous that it's not already the case, but we've learned to live with it - in part thanks to tools like Construct 2 that make it relatively painless to dual-encode.

Although I would throw in: the AAC files Construct 2 encodes sound pretty crap compared to the Vorbis ones, because we don't ship our own encoder. We have a similar problem as Mozilla does with Firefox - we want to avoid patent fees - so we ask Windows to do the encoding instead. (That's also why it's only Windows 7 and newer that can encode AAC - older versions of Windows don't have a built-in AAC encoder). And Windows ships with a pretty crap encoder. So if you were going to argue AAC sounds better than Vorbis, it doesn't - it sounds like crap, because the free encoders are crap, and you have to pay for a better one. The free Vorbis encoder is excellent quality, and produces a better quality sound and a smaller file size.

At Scirra we will also keep up the pressure by retaining the dual-encoding and always having an Ogg Vorbis set of audio beside your AAC. Our engine also always chooses Vorbis first if supported. So even if AAC is universally supported, Construct 2 will still be producing content with free formats. And if they are supported, they are quicker to download and sound better. Then, if in future everyone finally agrees to support Ogg Vorbis, existing Construct 2-authored web content is supported. This reduces the need to keep AAC support.

Hopefully one day there will be free and open video and audio formats that are universally supported on the web. It doesn't seem likely to arrive soon, though, but better late than never. In the mean time if you're wondering why you still end up with two sets of audio files in Construct 2 - that's why!

Subscribe

Get emailed when there are new posts!