cover image
< Home
Web

Web Audio Codecs

With the rise of video streaming and video calls, the need for good audio quality has become more important than ever. This article will give you an overview of the different audio codecs used on the web and how they compare to each other.

Audio Codecs

An audio codec is a software or hardware component that compresses or decompresses digital audio data. The term codec is short for "coder-decoder" which refers to the process of encoding audio data for transmission or storage and decoding it for playback.

An audio codec can be used to reduce the size of audio files, making them easier to transmit or store. Compression is achieved by removing redundant or irrelevant data from the audio signal, while maintaining its overall quality as much as possible.

WAV

The Waveform Audio Format (WAV) was jointly developed by Microsoft and IBM in 1991. Usually the audio data is stored uncompressed in the linear pulse-code modulation (LPCM) format. LCPM is also used in audio CDs. It stores two-channel LPCM audio sampled at 44.1 kHz with 16 bits per sample. Thus, is it of high quality, but its file size is also very large.

The big file size makes it unsuitable for audio streaming. However, it is still used for audio editing and archiving.

It can also contain metadata in the INFO chunk. WAV is an audio file format as well as a container format for other audio formats.

MP3

MP3 is a coding format for digital audio and was created by the Fraunhofer Society in Germany in 1991. It is a lossy audio compression format. Thus, a big reduction in file size in comparison with other formats like WAV is achieved. However, the quality is also reduced. It uses psychoacoustic modeling to remove the portions of the audio that are not perceived by the human ear.

MP3 is the most popular audio format on the web. It is supported by all major browsers. It is also supported by all major operating systems. MP3 now is patent free in the European Union and the United States.

AAC

AAC (Advanced Audio Coding) is a lossy audio compression format. It was developed by a consortium of different companies including Bell, Fraunhofer, Sony and more in 1997. It was designed as the successor to the MP3 format.

AAC is a lossy audio compression format. It is used in many Apple products like iTunes and iPod. Android also supports this format. The browser support is not as good as for MP3, but it is still supported by all major browsers. Due to patent issues, Firefox only supports AAC when the operating system supports it. In Chromium AAC support is not available.

It is an open standard but is not free.

FLAC

FLAC (Free Lossless Audio Codec) is a lossless audio compression format. It was developed by Josh Coalson in 2001 and is now administrated by the Xiph.org foundation. Being lossless, it does not reduce the quality of the audio. Thus, it is great for archival of audio and puposes where the audio quality is important.

FLAC is not covered by any patents and is open source and royalty free. FLAC playback is supported by all major browsers (except Opera) and operating systems.

ALAC

ALAC (Apple Lossless Audio Codec) is a lossless audio compression format. It was developed by Apple in 2004. It is used in Apple products like iTunes and iPod. Developed as proprietary by Apple, it is now an open source format. But cross-platform support is not good. As for browsers, only the Safari browser supports it. For operating systems, only macOS and iOS support it.

G.711

G.711 was specifically designed for use in the telephony system in 1972. G.711 passes audio signals in the range of 300–3400 Hz and samples them at the rate of 8,000 samples per second. Thus, it only captures the human voice, all other information is discarded. The standard is managed by the ITU-T organization. All patents have expired and it can be used for free.

This codec is now supported by all major web browsers in connection with WebRTC.

G.722

G.722 is an ITU 7 kHz audio codec developed in 1988. Like G.711 it is mainly used in the telephony system. In G.722 the audio signal is encoded using Adaptive Differential Pulse Code Modulation (ADPCM), in which each sample is represented not by its absolute value, but as a value indicating how much the new sample differs from the previous sample.

G.722 is now supported by all major web browsers in connection with WebRTC.

Vorbis

The Xiph.org foundation developed Vorbis as an open source alternative to MP3. Initially released in 2000, it is a lossy audio compression format. Depending on the quality setting used during encoding, the resulting bit rate can vary from around 45 kbps to 500 kbps.

Because it does not have the financial backing of a large company, it is not as widely supported as MP3. However, it is supported by all major browsers, except Safari.

Vorbis is usually used in the Ogg or WebM container format.

Opus

Like Vorbis, Opus was also developed by the Xiph.org foundation. Touted as a successor to Vorbis, it enhances it in multiple ways. Especially it has low latency which makes it ideal for real-time communication. It is a good general-purpose audio codec that can efficiently handle both low-complexity audio such as speech as well as music and other high-complexity sounds. As a codec, it is free and open source. It is also patent free. It was standardized by the IETF as RFC 6716.

Opus has great support in ally major browsers. It can also be used in WebRTC. It is also supported by all major operating systems, although within different containers.

Conclusion

As you can see, there are many different audio formats. Each has its own advantages and disadvantages. For example, MP3 is the most popular format, but it is not open source. For speech applications, G.711 and G.722 are good choices. But the general purpose Opus codec may be the best choice for most applications as it is free, open source, patent free and supported by modern browsers.

References

  • MDN Web Audio Codec Guide: https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Audio_codecs

  • Wikipedia Comparison of Audio Coding Formats: https://en.wikipedia.org/wiki/Comparison_of_audio_coding_formats

Published

3 Mar 2023

Thomas Derflinger

Written by Thomas Derflinger

I am a visionary entrepreneur and software developer. In this blog I mainly write about web programming and related topics like IoT.