What Is a Voice Codec?
A voice codec (coder-decoder) is an algorithm that converts analog voice signals into digital data for transmission and reconstructs them at the receiving end. It is one of the most fundamental technical components in VoIP and SIP communications, directly determining call quality, bandwidth consumption, and end-to-end latency.
Choosing the right codec requires balancing voice quality, bandwidth usage, and processing delay. Different use cases prioritize these dimensions differently: international long-distance routes may focus on bandwidth savings, while call centers prioritize voice clarity.
This article systematically compares the four most commonly used codecs in SIP trunk deployments — G.711, G.729, G.722, and Opus — to help you make the best selection for your needs.
G.711 (PCM)
Technical Overview
G.711 is the classic voice coding standard published by ITU-T in 1972, using Pulse Code Modulation (PCM) technology. It digitizes voice at an 8kHz sampling rate with 8-bit quantization per sample, producing a constant 64kbps bitrate. G.711 adds virtually no codec delay (less than 1ms), delivering the highest voice quality among traditional codecs but with the largest bandwidth requirement.
G.711 has two variants:
- G.711 A-law (PCMA): Used primarily in Europe, international circuits, and China
- G.711 mu-law (PCMU): Used primarily in North America and Japan
Key Parameters
| Parameter | Value |
|---|---|
| Bitrate | 64 kbps |
| Bandwidth (with IP/RTP/UDP overhead) | ~87.2 kbps |
| Sampling Rate | 8 kHz |
| Frame Size | 20ms (typical) |
| Algorithmic Delay | < 1ms |
| Theoretical MOS | 4.1 |
| Complexity | Very Low |
| Standard | ITU-T G.711 |
Strengths & Limitations
- Maximum compatibility: All SIP devices, PBXs, and softswitches support G.711 — it is the de facto lowest common denominator
- Zero compression loss: No compression is applied, preserving the full voice waveform
- Lowest latency: Adds virtually no extra codec delay
- High bandwidth consumption: Each call requires ~87kbps, which can be costly at high concurrency
Best Practice: When bandwidth is ample and maximum compatibility is needed, G.711 is the most reliable choice. Cainiao Voice SIP trunks support both G.711 A-law and mu-law by default.
G.729 (CS-ACELP)
Technical Overview
G.729 is an efficient voice compression standard published by ITU-T, using Conjugate Structure Algebraic Code-Excited Linear Prediction (CS-ACELP) technology. It compresses 64kbps voice down to 8kbps — an 87.5% bandwidth savings — making it the codec of choice for low-bandwidth links.
G.729 has multiple annex versions: G.729a (low-complexity annex) is the most commonly deployed implementation, while G.729b adds Voice Activity Detection / Discontinuous Transmission (VAD/DTX) for further average bandwidth reduction.
Key Parameters
| Parameter | Value |
|---|---|
| Bitrate | 8 kbps |
| Bandwidth (with IP/RTP/UDP overhead) | ~31.2 kbps |
| Sampling Rate | 8 kHz |
| Frame Size | 10ms |
| Algorithmic Delay | 10-15ms |
| Theoretical MOS | 3.9 |
| Complexity | Medium |
| Standard | ITU-T G.729 |
Strengths & Limitations
- Extreme bandwidth savings: Each call uses only ~31kbps, carrying nearly 3x the concurrent calls compared to G.711
- Acceptable voice quality: MOS 3.9 is clear enough for most scenarios
- Slightly higher latency: 10-15ms algorithmic delay, but generally not noticeable in conversations
- Poor with music and tones: Parametric encoding causes quality degradation for non-speech content (e.g., music, DTMF)
License Note: G.729 patents expired in 2017 and it is now free to use. However, some commercial PBX systems (e.g., Cisco, Avaya) may still require a software license.
G.722 (ADPCM)
Technical Overview
G.722 is a wideband voice coding standard published by ITU-T, using Adaptive Differential Pulse Code Modulation (ADPCM) technology. Unlike G.711's 8kHz sampling rate, G.722 uses 16kHz sampling, extending the audio band from the traditional 300-3400Hz to 50-7000Hz for High Definition (HD) Voice.
G.722 supports three bitrate modes: 48kbps, 56kbps, and 64kbps, and can dynamically switch during a call.
Key Parameters
| Parameter | Value |
|---|---|
| Bitrate | 48 / 56 / 64 kbps |
| Bandwidth (with IP/RTP/UDP overhead) | ~71.2 / 79.2 / 87.2 kbps |
| Sampling Rate | 16 kHz |
| Frame Size | 20ms (typical) |
| Algorithmic Delay | < 2ms |
| Theoretical MOS | 4.2 |
| Complexity | Low |
| Standard | ITU-T G.722 |
Strengths & Limitations
- HD Voice: 16kHz sampling provides richer, more natural voice quality — significantly improving conference and customer service experiences
- Low latency: Algorithmic delay under 2ms, comparable to G.711
- Good backward compatibility: Most modern SIP phones and PBXs support G.722
- Higher bandwidth: Comparable to G.711, not suitable for low-bandwidth scenarios
- PSTN downgrade: HD voice quality degrades to narrowband when routed through traditional telephone networks
Ideal Use Cases: G.722 excels in enterprise SIP calls, customer service centers, and conference calls where voice clarity is paramount.
Opus
Technical Overview
Opus is an open-source, royalty-free audio codec published by the IETF (RFC 6716), combining Skype's SILK speech encoder with Xiph.org's CELT audio encoder. Opus automatically switches between speech and music modes based on content, delivering outstanding quality across a wide range from 6kbps to 510kbps.
Opus is the mandatory standard codec for WebRTC and is widely adopted by WhatsApp, Discord, YouTube, Zoom, and other major platforms.
Key Parameters
| Parameter | Value |
|---|---|
| Bitrate | 6 - 510 kbps (variable) |
| Sampling Rate | 8 / 12 / 16 / 24 / 48 kHz |
| Frame Size | 2.5 / 5 / 10 / 20 / 40 / 60 ms |
| Algorithmic Delay | 2.5 - 60ms (depends on frame size) |
| Theoretical MOS | 4.5+ |
| Complexity | Medium-High (adjustable) |
| License | Open-source, royalty-free (BSD license) |
| Standard | RFC 6716 |
Strengths & Limitations
- Ultimate flexibility: From narrowband to fullband audio, from low bitrate to high fidelity — a single codec covers all scenarios
- Superior quality: At equivalent bitrates, Opus delivers significantly better voice quality than all traditional codecs
- Open-source & free: No patent licensing fees; freely integrable into any product
- WebRTC standard: Natively supported by all modern browsers, ideal for web applications
- Compatibility: Some legacy SIP devices and traditional PBXs may not support Opus
Industry Trend: Opus has been adopted by WhatsApp, Discord, YouTube, Zoom, and other major platforms. For new VoIP systems and WebRTC applications, Opus is the best choice. Cainiao Voice SIP trunks fully support Opus encoding.
Codec Comparison Table
| Codec | Bitrate | Bandwidth (with IP overhead) | MOS | Latency | Complexity | License | Best For |
|---|---|---|---|---|---|---|---|
| G.711 (PCM) | 64 kbps | 87.2 kbps | 4.1 | < 1ms | Very Low | Free | Maximum compatibility, PSTN interop |
| G.729 (CS-ACELP) | 8 kbps | 31.2 kbps | 3.9 | 10-15ms | Medium | Free (patents expired) | Low-bandwidth international routes |
| G.722 (ADPCM) | 48/56/64 kbps | 71.2-87.2 kbps | 4.2 | < 2ms | Low | Free | HD voice, conferencing, call centers |
| Opus | 6-510 kbps | Variable | 4.5+ | 2.5-60ms | Medium-High | Open-source, free | Modern VoIP, WebRTC |
Selection Guide
The optimal codec choice depends on your specific business scenario:
| Use Case | Recommended Codec | Rationale |
|---|---|---|
| High-quality customer service / conferencing | G.722 or Opus | Wideband audio delivers clearer speech, improving communication efficiency. Opus offers better quality at lower bandwidth. |
| Low-bandwidth international routes | G.729 | Each call uses only ~31kbps, allowing more concurrent calls on bandwidth-constrained international links. |
| Maximum compatibility / PSTN interop | G.711 | All SIP devices support G.711 — the only codec guaranteed to work across every network. |
| Modern WebRTC applications | Opus | Natively supported by browsers, best audio quality, open-source and free. Mandatory codec for WebRTC. |
In production deployments, a preferred negotiation + fallback strategy is common: negotiate Opus first, then fall back to G.711 if unsupported. This approach delivers Opus performance while ensuring universal interoperability.
SIP Codec Negotiation
Codec Lists in SDP
SIP uses the Session Description Protocol (SDP) to negotiate a mutually supported codec before the call is established. The sender lists all supported codecs and their payload type numbers in the SDP m=audio line:
m=audio 5004 RTP/AVP 96 0 8 18
Where the payload types mean:
- 96 — Dynamically assigned, typically used for Opus (defined in
a=rtpmapattribute) - 0 — G.711 mu-law (PCMU)
- 8 — G.711 A-law (PCMA)
- 18 — G.729
Priority & Fallback Mechanism
The order of codecs in SDP represents priority. The sender typically lists preferred codecs first. The receiver selects the first supported codec from the list in its 200 OK response to use for the call.
Recommended codec priority configuration:
- Opus (best quality and flexibility)
- G.722 (HD voice)
- G.711 A-law (compatibility baseline)
- G.729 (low-bandwidth fallback)
Note: Switching codecs mid-call requires a SIP re-INVITE to renegotiate SDP, which may cause 50-200ms of brief silence. We recommend establishing the optimal codec at call setup to avoid mid-call switching.
Frequently Asked Questions
Q: Which codec should I use for SIP trunking?
A: We recommend negotiating Opus first, falling back to G.711. Opus delivers the best quality while G.711 guarantees compatibility. Consider G.729 for bandwidth-constrained international routes.
Q: Is G.729 still paid?
A: G.729 patents expired in 2017 and it is now free to use. However, some commercial PBX systems may still require a software license.
Q: Does switching codecs cause call interruptions?
A: SIP negotiates codecs via SDP before the call is established. Mid-call switching requires a re-INVITE, which may cause brief silence.
Q: Why is Opus considered the best codec?
A: Opus combines SILK (speech) and CELT (audio) encoders, automatically switching based on content. At just 6kbps it maintains intelligibility, and at high bitrates it approaches CD quality. It is open-source and free, adopted by WhatsApp, Discord, and YouTube.
Need Professional International Voice Routes?
Cainiao Voice provides premium SIP trunk services supporting G.711, G.729, G.722, and Opus — covering 200+ countries
Free ConsultationRelated articles: SIP Trunk Setup Guide | Asterisk/FreeSWITCH SIP Trunk Checklist | SIP TLS & SRTP Encryption Explained