What Is a Codec?
A codec (short for Coder-Decoder) is the method by which voice is compressed for transmission over the network and expanded again on the other side. The codec determines the audio quality and the amount of data each call uses.
What a codec is, and why you need one
Sound is a wave in the air. To send it over a computer network, it has to be turned into numbers: the microphone picks up the wave, and the phone "samples" it thousands of times a second — each sample is a number describing the loudness at that moment. This sequence of numbers is digital sound.
The problem is that such a sequence, unprocessed, takes up a lot of room. This is where the codec comes in. The name is short for Coder-Decoder: on the speaking side it encodes the sound — compresses it using a certain method — and on the listening side it decodes it back into sound. Both sides must use the same codec, otherwise one is speaking a "language" the other doesn't understand.
The word "codec" is also familiar from the world of video and music — audio and video files are encoded with codecs too. In telephony there is an additional requirement: the encoding has to happen very fast, within milliseconds, because a call is a live thing. That is why codecs for calls are built differently from codecs for files.
How a codec works in a call
- Sampling — the phone samples the sound. In classic codecs — 8,000 times a second; in HD codecs — 16,000 times or more.
- Compression — the codec reduces the data. A simple codec only rounds the numbers; an advanced codec uses a model of the human voice and sends only what matters for hearing.
- Packaging — the sound is cut into short slices, usually 20 milliseconds, and each slice is sent as a packet over the network.
- Decoding — on the other side the codec opens each packet and plays them back in sequence.
At the start of the call, the two sides agree on which codec to use. Each side presents the list of codecs it supports in order of preference, and a codec that both know is chosen. This negotiation is part of the SIP protocol.
The common codecs
- G.711 — the veteran codec, which was used even in the digital phone networks that preceded the internet. It barely compresses: 64 kilobits per second for voice alone. The quality is like that of a regular phone line, and it is robust and simple. It comes in two versions: A-law, used in Europe and Israel, and μ-law, used in North America and Japan.
- G.722 — a wideband codec, the basis of what is called "HD audio". It carries a frequency range roughly twice as wide as G.711, about 50 to 7,000 hertz, with about the same data use.
- G.729 — a highly compressed codec, about an eighth of G.711. It was used a lot when the internet was slow. The quality is lower, but it saves bandwidth.
- Opus — a modern, open codec, standardized in 2012. It adapts during the call: when the network is good it delivers very high quality, and when it is weak it lowers the rate and keeps the call continuous. It is very common in apps and in calls from the browser.
There are many other codecs, some specialized for cellular networks. For most offices, these four are all you need to know.
A quick comparison
| Codec | Quality | Data use | Best for |
|---|---|---|---|
| G.711 | Regular phone line | High | Calls to regular lines, a good network |
| G.722 | HD | Similar to G.711 | Calls between IP phones, conferences |
| G.729 | Fair | Very low | Very weak connections |
| Opus | Variable, up to very high | Adaptive | Apps, mobile, an unstable network |
Important to remember: the actual data use is higher than the codec's rate. Each packet gets "headers" added with addresses and sequence numbers, and in a G.711 call everything together comes to about 80–90 kilobits per second in each direction. This is still very little compared with today's internet connections, but in an office with many simultaneous calls it is worth calculating. See bandwidth.
HD audio: why it feels different
A regular phone line carries only the basic range of speech. Many consonant sounds — "s", "sh", "f", "t" — sit exactly in the frequencies that get cut. That is why on an old phone you're asked to spell a name, and you confuse "fifteen" with "fifty".
When both sides support a wideband codec, the call sounds significantly clearer: it is easier to understand names and numbers, easier to tell who is speaking, and the call is less tiring. In a conference with several participants the difference is especially noticeable.
But HD works only if the whole path supports it. A call between two IP phones in the office can be HD. A call to a regular line or to a mobile through the telephone network usually goes through the basic codec, and so it will sound like a regular phone — no matter how advanced your device is.
What a codec can't fix
A good codec doesn't fix a bad network. If packets get lost or arrive late, the sound cuts out, lags or sounds "robotic" — with any codec. These problems are measured in latency and jitter, and the solution is in the network: a suitable router, QoS that gives calls priority, and a cable instead of a congested Wi-Fi.
- Sound in one direction only — almost always a NAT or firewall problem, not a codec problem.
- Echo — usually a problem with a device, a loud speaker or a headset, not with a codec.
- No sound at all when calling a certain person — sometimes there is no codec common to both sides. This is rare with modern phones, but it happens with old equipment.
Fax and old modems are also sensitive to the codec: a compressed codec distorts their tones. This is one of the reasons fax over the internet doesn't always work well, and so a virtual fax is often a more convenient solution.
What you actually hear: narrowband vs. wideband
"HD" is a marketing term, but behind it is a difference that anyone can hear if they know how to listen. The table details what happens to each kind of sound in the two worlds: narrowband (like a regular phone line, up to about 3,400 hertz) and wideband (like G.722 or Opus, up to about 7,000 hertz and more).
| What you're trying to hear | Narrowband | Wideband |
|---|---|---|
| "s" vs. "sh", "f" vs. "t" | Sound almost the same; you have to spell | Clearly distinguishable |
| Last names and phone numbers | Repeated twice, you ask "again?" | Caught the first time |
| Who is speaking, when there are several people | Similar voices blend together | Each voice sounds different |
| A child's voice or a high voice | Thin and shrill | Natural |
| Background noise (office, street) | Blends in with the speech | Separate from the speech, easy to ignore |
| Music on hold | Flat, with no bass and no treble | Sounds like a radio |
| A one-hour call | Tiring; the brain fills in what is missing | Less effort |
| Depth and echoes in the room | Not noticeable | Noticeable — for better and for worse |
The last row is the other side of the coin: a wideband codec also carries what you don't want — the echo of an empty room, the air conditioner, the neighbor's keyboard. At call center stations with HD, a headset with a microphone close to the mouth is a better investment than a speaker.
When HD doesn't help, and why not to chase it
The codec of the call is set by the weakest link on the way. So there are situations in which an advanced phone and an excellent codec change nothing:
- A call to a regular line or to a mobile. As soon as the call leaves the PBX for the telephone network, it usually goes through the basic codec, because that is how the carriers' exchanges talk to each other. Even if the customer's mobile supports "HD voice" on its cellular network, the crossing between networks brings the call back to narrowband. Most of a business's calls are exactly like that — with customers, not between employees.
- One participant in a conference on a regular line. They will sound narrowband to everyone, even when all the others are on HD. HD benefits only those on IP phones.
- Cheap headsets or a speaker. A microphone that carries only a narrow range cancels the codec's advantage before the sound even leaves the device.
- Call recording. Recordings are usually stored compressed, to save space. The recording of an HD call doesn't necessarily sound HD.
- A weak network. On a network with packet loss, a wideband codec not only doesn't help — sometimes it sounds worse, because there is more to lose. An adaptive codec like Opus drops to lower quality on its own in such a case.
Where HD does pay off: internal calls between branches, conference rooms where all the participants are on IP phones, app-to-app calls, and call centers where agents talk for hours and get tired. For an ordinary business whose calls are mostly with customers on mobiles, the right investment is in a stable network, not in the codec.
From the field: symptoms that are related to the codec, and small numbers that explain them
| What you hear | What is probably happening | What to do |
|---|---|---|
| A "metallic," pressed sound, but continuous | The call goes through a heavily compressed codec (like G.729), or it is converted from codec to codec along the way | Check the order of preference on the devices; prefer G.711 or Opus when the network allows |
| Words are swallowed for a moment, as if someone cut them out | Packets were lost, and the codec "invents" what is missing (Packet Loss Concealment). At a low level it is hardly noticeable; above a few percent it stands out | A network problem: see latency and jitter |
| A fax that starts and drops in the middle of the page | A compressed codec distorts the fax tones, or there is no support for the dedicated fax protocol (T.38) | Use the G.711 codec for fax, or move to a virtual fax |
| Everything is excellent in the morning, and gets worse in the afternoon | Not the codec. The network fills up: backups, updates, video | QoS on the router and a cable instead of Wi-Fi |
- 50 packets a second. In slices of 20 milliseconds, each direction of a call sends fifty packets a second. Losing one packet is a 20-millisecond hole — the codec hides it. Losing five in a row is a tenth of a second, and that you can hear.
- 160 bytes. This is the size of the sound in one packet of G.711. The addresses and headers add about 40 more bytes — so network use is about a quarter higher than the codec's rate.
- Milliseconds for encoding. Compressed codecs need computing time and cause a small extra delay. In a regular call it isn't noticeable; in a call that already suffers from latency it is one more drop in the bucket.
A common mistake: changing codec settings on all the phones when the problem is one router. Before touching the codec, check whether the fault also exists in an internal call between two extensions in the office. If so — the local network. If not — the path out.
How it works with us at Kesher
Most of our customers don't need to think about codecs at all. The phones we supply — Yealink, Fanvil, Cisco and AudioCodes, desk phones, cordless phones and conference phones — arrive pre-configured and connect to the PBX without you having to enter the audio settings.
When the sound isn't good, the reason is usually in the network and not in the codec. If needed, we set up an orderly network rack: cables from every desk, a patch panel, a PoE switch, a router and a UPS. An infrastructure like this is the basis for clear calls.
In the control panel you can see for each extension whether it is registered, and from which device. If you have a question about audio quality — every question is answered by a person who knows your system, and together we check what the cause is.
FAQ
What is a codec in telephony?
The method by which sound is compressed for transmission over the network and opened on the other side. The codec determines the audio quality and the amount of data a call uses.
What is the difference between G.711 and G.722?
G.711 carries the quality of a regular phone line. G.722 carries a wider frequency range (HD), so the sound is clearer, with similar data use.
Why doesn't a call to a mobile sound HD?
Because HD works only when the whole path supports it. A call that passes through the telephone network usually arrives with the basic codec.
Will a good codec fix calls that cut out?
No. Cutting out usually comes from network problems — packet loss, latency or an unsuitable router. That is solved in the network.
How much internet does a call use?
With the veteran G.711 codec — about 80–90 kilobits per second in each direction, including the network overhead. Compressed codecs use less.
The customer presses keys in the IVR menu and the system doesn't respond. Is that related to the codec?
It can be. When the key tones are sent inside the sound itself and a compressed codec distorts them, the menu doesn't recognize them. The usual solution is to send the key presses as a separate event from the sound, and that is a setting on the device or the PBX.
Why does the recording sound worse than the call itself?
Recordings are usually stored compressed to save storage space. The call can be HD, and its recording in a basic codec — that is normal and doesn't indicate a fault.
Can you choose a codec for each call?
Not manually. The two sides negotiate automatically at the start of the call according to their preference lists. What you can set is the order of preference on the device or the PBX.