Audio Codecs

Unless you’re going to stick to films made before 1927 or so, you’re going to want an audio track in your video. Like video codecs, audio codecs are encoding algorithms, in this case used for audio streams. As with video codecs, there are lossy and lossless audio codecs. And like lossless video, lossless audio is really too big to put on the Web, so I’ll concentrate on lossy audio codecs.

Actually, we can narrow the focus even further, because there are different categories of lossy audio codecs. Audio is used in many places where video is not (telephony, for example), and there is an entire category of audio codecs optimized for encoding speech. You wouldn’t rip a music CD with these codecs, because the result would sound like a four-year-old singing into a speakerphone. But you would use them in an Asterisk PBX, because bandwidth is precious, and these codecs can compress human speech into a fraction of the size of general-purpose codecs. However, due to lack of support in both native browsers and third-party plug-ins, speech-optimized audio codecs never really took off on the Web. So I’ll concentrate on general-purpose lossy audio codecs.

As I mentioned in Video Codecs, when you “watch a video,” your computer is doing several things at once:

  1. Interpreting the container format

  2. Decoding the video stream

  3. Decoding the audio stream and sending the sound to your speakers

The audio codec specifies how to do #3—decoding the audio stream and turning it into digital ...

Get HTML5: Up and Running now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.