Template is not defined.

Codecs

Introduction

A codec, or coder-decoder, is a program or device that compresses and decompresses digital media such as audio, video, and images. It is used to reduce the size of digital media for efficient transmission and storage while preserving the quality of the media. In this article, we will explore the different types of codecs, their working principles, and the advantages and disadvantages of each type.

Types of Codecs

There are two primary types of codecs: lossy and lossless.

  1. Lossy Codecs: Lossy codecs are designed to compress digital media by discarding some data that is deemed less essential to the perception of the media by a human. They achieve higher compression ratios by sacrificing some data. Lossy codecs are commonly used in applications where the compressed file size is more important than the preservation of all the data. Examples of lossy codecs include MP3, AAC, and JPEG.
  2. Lossless Codecs: Lossless codecs are designed to compress digital media without losing any data. They preserve all the original data, and the uncompressed data is identical to the original. Lossless codecs are commonly used in applications where compressed file size is not the primary consideration. Examples of lossless codecs include FLAC, ALAC, and PNG.

Working Principles of Codecs

Codecs work by applying a set of algorithms to digital media to reduce its size while maintaining its quality. There are two primary types of algorithms used by codecs: Transform Coding and Predictive Coding.

  1. Transform Coding: Transform Coding is an algorithm that applies mathematical transforms to digital media to reduce the amount of data needed to represent it. The most common type of transform coding used in audio codecs is the Discrete Cosine Transform (DCT), which converts time-domain audio samples into the frequency domain. By removing the higher frequency components that are less perceptible to the human ear, the DCT algorithm can reduce the file size of an audio file significantly.
  2. Predictive Coding: Predictive Coding is an algorithm that uses previously encoded data to predict the value of future samples. The algorithm stores the predicted value and the difference between the predicted value and the actual value as an error signal. The error signal is then compressed and transmitted along with the predicted value. The most common predictive coding algorithm used in audio codecs is the Adaptive Differential Pulse Code Modulation (ADPCM) algorithm.

Codecs in Asterisk

Asterisk is an open-source PBX software that offers a wide range of features and capabilities for building a powerful and flexible voice communication system. One of the key aspects of Asterisk is its support for various codecs, which are used to encode and decode audio signals for transmission over a network. We shall further explore the different codecs supported by Asterisk and their advantages and disadvantages, as well as the SLIN codec and its uses.

Codecs
The Types of VoIP Codecs
Source: GL Communications

Asterisk supports several codecs, in this article, we have labelled asterisk codecs based on status, usage and popularity.

Popularity Legend
  • Essential: This module is one you’ll never want to be without.
  • Useful: This module is current, maintained, popular, and recommended.
  • Usable: The module works but may be incomplete and/or is not recommended
  • New: This module is new, it works but its completeness is unknown.
  • Insignificant: Very Old modules. May be incompatible & has no community support.
  • Unreliable: The module is new and is in testing. Not recommended for Production
  • Deprecated: This module has been replaced by something considered superior.
  • Limited: This module has limitations that may make it unsuitable to your requirements.
NamePurposePopularity
G.711This is the standard codec used for transmitting voice over an IP network. It uses pulse-code modulation (PCM) to digitize analogue signals and is uncompressed, which means that it requires high bandwidth to transmit. However, it offers high-quality audio and is widely supported by most VoIP devices.Essential
(Excellent Quality)
G.729This is a low-bitrate codec that compresses audio signals to reduce the amount of data that needs to be transmitted. It uses a technique called conjugate-structure algebraic-code-excited linear prediction (CS-ACELP) to compress audio data, which reduces the bandwidth requirements. However, it offers lower audio quality than G.711.Essential (Excellent Quality)
G.723.1This is another low-bitrate codec that compresses audio data to reduce bandwidth requirements. It uses a technique called code-excited linear prediction (CELP) to compress audio data, which reduces the bandwidth requirements even further than G.729. However, it offers even lower audio quality than G.729.Essential
G.726This is a family of codecs that compresses audio data to reduce bandwidth requirements. It uses a technique called adaptive differential pulse-code modulation (ADPCM) to compress audio data, which reduces the bandwidth requirements while offering better audio quality than G.729 and G.723.1.Useful
OpusBitrates from 6 kb/s to 510 kb/s (Narrowband to Wideband). Opus is unmatched for interactive speech and music transmission over the Internet but is also intended for storage and streaming applications. This is a relatively new codec that offers high-quality audio with low bandwidth requirements. It uses a technique called variable bitrate (VBR) encoding to adjust the compression rate based on the complexity of the audio signal, which reduces the bandwidth requirements without sacrificing audio quality.Useful
codec_resampleFor SLIN Codec. Resamples between 8-bit and 16-bit signed linear. Usable
Table 1: Asterisk Codecs Translators. Learn more about Supported Audio Codecs Translators
For Popularity comments meaning, See also Popularity/Status Legend

Each codec has its advantages and disadvantages, depending on the specific use case. For example, if you need high-quality audio, G.711 may be the best choice, but if you have limited bandwidth, G.729 or G.723.1 may be a better option.

SLIN Codec

SLIN, or Signed Linear, is another codec supported by Asterisk. SLIN is an uncompressed codec that is used for internal audio processing within Asterisk. It is designed to provide high-quality audio with low processing overhead, making it ideal for use in an IVR system or other voice applications.

SLIN uses a 16-bit signed linear encoding scheme to represent audio data. This encoding scheme is similar to the PCM encoding used by G.711 but is not compressed, which means that it requires a higher bandwidth to transmit. However, because SLIN is used for internal audio processing within Asterisk, the bandwidth requirements are not as important as the audio quality and processing overhead.

SLIN is typically used for audio processing within Asterisk, such as in an IVR system or other voice applications. It is not recommended for use in transmission over a network, as it is not compressed and would require high bandwidth to transmit.

Asterisk Codec Translators

Codec Translators (often called transcoders) are software components responsible for bridging the gap between incompatible codecs, enabling different systems to communicate with each other seamlessly. Codec translators are designed to address this challenge by providing a bridge between different codecs. These components are able to recognize the input codec of a data stream and then convert it into a compatible output codec.

The codec translators allow Asterisk to convert audio stream formats between calls. So if a call comes in on a PRI circuit (using G.711) and needs to be passed out a compressed SIP channel (e.g., using G.729, one of many codecs that SIP can handle), the relevant codec translator would perform the conversion.

NamePurposePopularity
codec_alawA-law Pulse Code Modulated (PCM) codec is used all over the world on the PSTN (except Canada/USA). This codec (along with ulaw) should be enabled on all your channelsEssential
(Excellent Quality)
codec_ulawMu-law PCM codec used on PSTN in Canada/USA. It’s more formally written as μ-law, but not many people have the Greek letter μ on their keyboard, so it’s popularly written as ulaw. This is often the default codec and should be enabled on all your channelsEssential (Excellent Quality)
codec_dahdiUtilizes proprietary Digium hardware transcoding cardEssential
codec_a_muA-law to mu-law direct converterUseful
codec_opusBitrates from 6 kb/s to 510 kb/s (Narrowband to Wideband). Opus is unmatched for interactive speech and music transmission over the Internet but is also intended for storage and streaming applications.Useful
codec_g722Wideband audio codec ITU standard codec that provides 7 kHz wideband audio at data rates from 48, 56 and 64 kb/s.Useful (High Definition)
codec_gsmGlobal System for Mobile Communications (GSM) codec. Compress 3.1 kHz audio into between 6.5 and 13 kb/sUsable
codec_resampleFor SLIN Codec. Resamples between 8-bit and 16-bit signed linear. Usable
Table 1: Asterisk Codecs Translators. Learn more about Supported Audio Codecs Translators
For Popularity comments meaning, See also Popularity/Status Legend

Format Interpreters

Format interpreters and Codecs transcoders/translators perform the functions, but they handle more than just audio and do their work on files rather than channels. For example, If you have a recording on a menu that has been stored as GSM, a format interpreter would need to be used to play that recording to any channels not using the GSM codec.

When transcoding is in use, the CPU may experience a significant burden caused by certain codecs, which means that a system capable of handling multiple hundreds of channels without transcoding might be limited to only a few dozen. In other combat the efficiency cost of some codecs, for example if you save a recording in multiple formats like WAV, GSM, etc. In that case, Asterisk will choose the most economical format for a channel that needs the recording.

NamePlays files stored inDistributed with AsterisksPopularity
format_g722G.722 .g722YesUseful
format_wav.wavYesUseful
format_g729G.729 .g729Codec (NO) / Format (YES)Useful
format_sln8-bit signed linear .sln .rawYesUseful
format_sln1616-bit signed linear .sln16YesUseful
format_pcmVarious Pulse-Coded Modulation formats:  .alaw,  .al,  .alw, .pcm,  .ulaw,  .ul,  .mu, .ulw,  .g722,  .au YesUseful
format_siren14G.722.1 Annex C (14 kHz) .siren14YesNew
format_siren7G.722.1 (7 kHz) .siren7YesNew
format_h264H.264 – video .h264YesUsable
format_h263H.263 – video .h263YesUsable
format_ogg_vorbisOgg container .oggCodec (NO) / Format (YES)Usable
format_gsmRPE-LTP (original GSM codec) .gsmYesUsable
format_wav_gsmGSM audio in a WAV container .WAV, .wav49YesUsable
Table 2: Asterisk Format interpreters. Learn more about Supported Format interpreters
For Popularity comments meaning, See also Popularity/Status Legend

Codec Overhead

Codec overhead refers to the additional data or bits required to transmit the audio or video stream encoded by a codec. This overhead includes various components such as protocol headers, error correction codes, synchronization bits, and framing information. The overhead is necessary for the proper functioning of the codec and the reliable transmission of the encoded data. However, it increases the overall bandwidth or data size required to transmit the media stream.

The amount of overhead can vary depending on the specific codec and its configuration. Different codecs use different techniques and protocols, resulting in varying amounts of overhead. Some codecs may have more efficient compression algorithms and require less overhead, while others may have additional data for error detection and correction, resulting in higher overhead.

Overhead is typically expressed as a percentage of the total bandwidth. For example, if a codec has an overhead of 10%, it means that 10% of the total bandwidth is used for transmitting the additional data associated with the codec.

It’s important to consider the overhead when dimensioning network bandwidth or storage requirements for media streams, as it affects the actual data rate or size that needs to be transmitted or stored. By taking into account the codec overhead, you can ensure that sufficient bandwidth or storage capacity is allocated to accommodate the additional data required by the codec.

Table Showing Codecs Bandwidths and Overhead

Regular
Audio Codecs
namebandwidth
(No overhead)
bandwidth
(incl. overhead)
bandwidth for
5 concurrent calls
quality
G.711 a/u-lawPCM64.00 Kibps80 kbit/s512 kbit/sISDN
G.729CS-CELP8.00 Kibps32 kbit/s200 kbit/sgood
iLBCiLBC15.20 Kibps32 kbit/s200 kbit/sgood
G.722G.72256.00 Kibps72.80 kbit/s464 kbit/sgood
G.722 over ISDNG.72264.00 Kibps80.00 kbit/s512 kbit/sISDN good
G.723.1 over
Dual rate speech coder
MP-MLQ1 – 6.10 Kibps21 kbit/s110 kbit/saverage
G.723A-CELP15 kbit/s80 kbit/saverage
GSM fullrateGSM13.00 Kibps13 kbit/s80 kbit/saverage
G.726AD-PCM32.00 Kibps55 kbit/s386 kbit/sGSM
SpeeXSpeeX4 – 15 kbit/s25 – 80 kbit/svariable
Table Showing Codecs Bandwidths and Overhead
Note:
1 KB =1,000 bytes; 1 kibibyte (KiB) =1,024 bytes.
1 megabyte (MB) = 1,000 KB; 1 mebibyte (MiB) = 1,024 KiB.
1 GB = 1,000 MB; 1 GiB = 1,024 MiB.

Conclusion

Codecs are an essential part of modern telecommunications systems. They are used to compress and decompress audio and video data, making it easier to transmit over a network. Asterisk supports a wide range of codecs, including G.711, G.729, G.723, and GSM. When setting up Asterisk, it is important to choose the appropriate codecs for your system based on your bandwidth and audio quality needs.

Codec translators, on the other hand, are critical components of modern communication systems that enable different devices to communicate with each other seamlessly. These software components bridge the gap between incompatible codecs, ensuring that data is transmitted with minimal data loss and maximum quality. While codec translators have some limitations, they play an essential role in enabling efficient and effective communication between different devices and systems.

As multimedia communication continues to evolve and become more widespread, codec translators will become even more important. As such, it is essential for organizations to understand the role of codec translators in communication systems and to invest in the development and maintenance of these critical components. With the right approach and expertise, codec translators can enable efficient, high-quality communication that enhances collaboration and productivity across a wide range of industries and use cases.

Table of Contents