VoIP

VoIP Codecs Compared: G.711, G.729, G.722 and Opus

Himanshu Pal

Himanshu Pal

What a codec decides

The codec is the single configuration choice that most directly determines what your calls sound like and what they cost in bandwidth. It governs how audio is digitised and compressed at one end and reconstructed at the other, and both ends must agree on one or the call fails to negotiate at all.

Most VoIP deployments only ever need to reason about four.

G.711 — the universal default

G.711 samples at 8 kHz and runs at 64 kbps. It applies only minimal companding rather than real compression, which is precisely why it sounds clean: there is very little processing between the microphone and the wire.

It comes in two regional variants — µ-law (ulaw), used in the US and Japan, and A-law (alaw), used across Europe and most of the rest of the world. They are functionally equivalent; the difference is the companding curve.

Two properties make it the sensible default. It is royalty-free, and it is supported by essentially every device and carrier in existence, so it is the fallback that always negotiates. Because it is uncompressed, it also carries DTMF tones and fax reliably where compressed codecs mangle them.

The cost is bandwidth. At 20 ms packetisation, a G.711 call consumes roughly 87 kbps in each direction once IP, UDP, RTP and Ethernet headers are counted — you can work out the exact figure for your setup with our VoIP bandwidth calculator.

G.729 — the bandwidth saver

G.729 compresses aggressively, down to 8 kbps of payload. On a constrained WAN link that is a decisive advantage: with header overhead it lands near 31 kbps per direction over Ethernet at 20 ms, against G.711's 87 kbps.

Note that this is roughly a 3× saving, not 8×. The codec bitrate falls by a factor of eight but the per-packet IP/UDP/RTP header does not shrink at all, and at 50 packets per second that overhead dominates a small payload.

Quality is noticeably narrowband — perfectly intelligible for speech, poor for anything else. It also degrades badly if transcoded more than once along a path, so avoid designs where the audio is re-encoded at several hops.

Licensing has historically been the catch. G.729 has been patent-encumbered, and Asterisk's own documentation notes a free version usable in countries without applicable patents or for educational use, with a pass-through option otherwise. Pass-through means Asterisk relays the encoded audio without decoding it — no licence needed, but also no transcoding, so both ends must speak G.729. The core patents have now expired, which has made this much less of an obstacle than it once was, but check your jurisdiction and vendor terms.

G.722 — wideband, and free

G.722 samples at 16 kHz, double the rate of G.711, which doubles the reproduced frequency range. The result is immediately audible: voices sound present rather than muffled, and consonants that are easily confused on a narrowband call become distinct.

It runs at 64 kbps — the same bandwidth as G.711 — and requires no licence. Asterisk has supported full transcoding for it since 1.6.

If your calls are internal, or your carrier supports wideband, G.722 is close to free quality: same bandwidth as your existing default, materially better audio. The limitation is that the PSTN is narrowband, so any call that touches a traditional phone network is downsampled anyway.

Opus — the modern choice

Opus is the codec that WebRTC standardised on, and it behaves differently from the others: rather than a fixed bitrate, it adapts continuously, typically across roughly 6 to 510 kbps, adjusting to available bandwidth in real time.

It handles both speech and music well, supports sample rates up to full band, and includes built-in packet-loss concealment that degrades far more gracefully than the older codecs when a network gets lossy. It is royalty-free and open.

For browser-based calling it is the obvious answer. For traditional SIP trunking, support is improving but not universal — many carriers still do not offer it, so treat it as the internal and WebRTC default rather than something to demand from a carrier.

Others you may encounter

Asterisk also ships support for G.726 (ADPCM, commonly 32 kbps, licence-free), GSM (licence-free, low bandwidth, dated quality), iLBC (licence-free, designed to tolerate packet loss), Speex (licence-free, variable 4–48 kbps) and G.723.1 (very low bitrate, licensing complications). LPC10 exists and is explicitly not recommended.

These turn up in legacy equipment more than new designs. Unless something specific requires one, you are better served by the main four.

Choosing, in practice

  • Default: G.711 (alaw or ulaw to match your region). Always negotiate it as a fallback.
  • Internal / HD calling: G.722 — better audio at no extra bandwidth or licence cost.
  • Constrained links: G.729, accepting narrowband quality for roughly a third of the bandwidth.
  • WebRTC and softphones: Opus.

Configure the preference order explicitly rather than allowing everything — an unconstrained codec list invites negotiations you did not intend and forces needless transcoding, which costs CPU and degrades quality at every hop.

Frequently asked questions

Which codec should I use?

G.711 unless you have a specific reason not to. It is free, universally supported, sounds good, and handles DTMF and fax cleanly. Add G.722 for internal HD calls and G.729 only where bandwidth genuinely constrains you.

Why does my call fail with 488 Not Acceptable Here?

The two ends found no codec in common, or one requires encrypted media the other did not offer. Compare the codec lists on both sides and look at the SDP in a trace — see our SIP code lookup for the full picture.

Is G.729 still licensed?

The core patents have expired, so it is far less restricted than it once was. Historically Asterisk offered a free build for patent-free jurisdictions and educational use, with pass-through as the alternative. Confirm your own position rather than assuming.

Does a low-bitrate codec break fax and DTMF?

Yes — compressed codecs distort the pure tones both rely on. Use G.711 for fax, or better T.38, and always use RFC 4733 DTMF rather than inband on a compressed codec.