Install Free G.729 Codec in Asterisk

Complete guide to installing bcg729 open-source G.729 codec for Asterisk and Vicidial — save 75% bandwidth on every call

8 kbps
G.729 Bit Rate
75%
Bandwidth Savings
Free
Open Source

1. What is G.729 and Why It Matters

G.729 is an audio codec standardized by the ITU-T that compresses voice data to just 8 kbps — compared to 64 kbps for G.711 (ulaw/alaw). This represents a 75% reduction in bandwidth per call while maintaining near-toll-quality audio (MOS score of 3.7–4.0).

For VoIP deployments, especially those handling hundreds or thousands of concurrent calls, the bandwidth savings are enormous. A single T1 line (1.544 Mbps) can carry approximately 17 simultaneous G.711 calls but up to 50+ G.729 calls.

When to Use G.729

  • WAN / Internet trunks — Where bandwidth is limited or expensive
  • Call centers (Vicidial) — High concurrent call volumes
  • Remote offices over VPN — Limited WAN bandwidth between sites
  • SIP trunks to carriers — Many providers support or prefer G.729
  • International calls — Long-distance paths with bandwidth constraints

When NOT to Use G.729

  • LAN-only calls — Use G.711 for best quality when bandwidth is free
  • Fax / modem signals — G.729 destroys fax signals; use G.711 or T.38
  • Music on Hold — Lossy compression degrades music quality; transcode at the endpoint
  • DTMF-heavy IVR — In-band DTMF can be unreliable; use RFC 2833 instead

2. Codec Comparison: G.711 vs G.729 vs Opus

FeatureG.711 (ulaw/alaw)G.729Opus
Bit Rate64 kbps8 kbps6–510 kbps
Bandwidth per Call (with overhead)~87 kbps~31 kbps~32 kbps
Audio Quality (MOS)4.1–4.43.7–4.04.0–4.5
LicenseRoyalty-freePatents expired (2017)Royalty-free
CPU Usage (Transcoding)Very LowModerateModerate–High
Packet Size20ms frames10–20ms frames2.5–60ms frames
Ideal Use CaseLAN / High bandwidthWAN / Low bandwidthWebRTC / Modern VoIP
Asterisk SupportBuilt-in (ulaw/alaw)Module required (bcg729)Built-in (Asterisk 13+)

Key takeaway: G.729 provides the best balance of bandwidth savings and compatibility. Opus offers better quality and flexibility but is not supported by all SIP providers and legacy equipment.

3. Free vs Commercial G.729 Options

The G.729 patents expired in 2017, making free open-source implementations fully legal worldwide. Here are the available options:

bcg729 (Open Source)RECOMMENDED

Open-source implementation by Oxa (Oxa BCG729). Became the standard free option after G.729 patents expired in 2017. Recommended for all new installations.

License: Free / GPLv3+  |  Quality: Excellent (ITU-T compliant)
Digium codec_g729a (Commercial)

Previously the only legal option. Per-channel licenses tied to a specific server. No longer necessary since patent expiration but still sold for support.

License: Paid ($10/channel)  |  Quality: Excellent
Intel IPP-based codec_g729

Uses Intel Integrated Performance Primitives library. Good performance on Intel CPUs but complex to build and maintain. Less common today.

License: Free (with Intel IPP)  |  Quality: Excellent

4. Installing bcg729 Library (Step by Step)

The bcg729 library is the underlying G.729 encoder/decoder. Asterisk's codec_g729 module links against this library. You must install bcg729 first, then compile the Asterisk module.

Step 1: Install Prerequisites

# CentOS / RHEL / AlmaLinux
yum install -y gcc make cmake git

# Debian / Ubuntu
apt-get install -y gcc make cmake git

# Check Asterisk version (you will need this later)
asterisk -rx "core show version"

Step 2: Download and Compile bcg729

cd /usr/src
git clone https://gitlab.linphone.org/BC/public/bcg729.git
cd bcg729
git checkout master

# Build with cmake
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
make
make install

# Verify the library is installed
ls -la /usr/lib/libbcg729*
# or on 64-bit systems:
ls -la /usr/lib64/libbcg729*

# Update library cache
ldconfig

Step 3: Verify bcg729 Installation

# Check if the shared library is found
ldconfig -p | grep bcg729
# Expected output:
# libbcg729.so.0 (libc6,x86-64) => /usr/lib/libbcg729.so.0
# libbcg729.so (libc6,x86-64) => /usr/lib/libbcg729.so

5. Compiling codec_g729 for Asterisk

With bcg729 installed, you need to compile the codec_g729.so module against your specific Asterisk version's source headers.

Method A: Using Asterisk Source (Recommended)

# Determine your Asterisk version
ASTVER=$(asterisk -rx "core show version" | grep -oP 'Asterisk \K[0-9]+\.[0-9]+')
echo "Asterisk version: $ASTVER"

# Download matching Asterisk source (if not already present)
cd /usr/src
wget https://downloads.asterisk.org/pub/telephony/asterisk/asterisk-${ASTVER}-current.tar.gz
tar xzf asterisk-${ASTVER}-current.tar.gz
cd asterisk-${ASTVER}*/

# Configure Asterisk source (needed for headers)
./configure
make menuselect.makeopts

# Now get the codec_g729 module source
cd /usr/src
git clone https://github.com/AoiYamada/asterisk-g72x.git
cd asterisk-g72x

# Build for your Asterisk version
./autogen.sh
./configure --with-asterisk-includes=/usr/src/asterisk-${ASTVER}*/include \
            --with-bcg729
make
make install

Method B: Quick Build with asterisk-g72x (Alternative)

# Clone the asterisk-g72x project
cd /usr/src
git clone https://github.com/arkosgit/asterisk-g72x.git
cd asterisk-g72x

# For Asterisk 18
./autogen.sh
./configure --with-bcg729 --with-asterisk18
make
make install

# For Asterisk 20
./configure --with-bcg729 --with-asterisk20
make
make install

# For Asterisk 21+
./configure --with-bcg729 --with-asterisk21
make
make install

Step: Verify the Module

# Check the module is in the right directory
ls -la /usr/lib/asterisk/modules/codec_g729.so
# or
ls -la /usr/lib64/asterisk/modules/codec_g729.so

# Load the module in Asterisk
asterisk -rx "module load codec_g729.so"

# Verify it is loaded
asterisk -rx "module show like g729"
# Expected output:
# codec_g729.so     G.729 Coder/Decoder (bcg729)    0    Running

6. Configuration (sip.conf / pjsip.conf)

sip.conf (Legacy chan_sip)

; /etc/asterisk/sip.conf

[general]
; Disable all codecs first, then allow specific ones in priority order
disallow=all
allow=g729
allow=ulaw
allow=alaw

; G.729 Annexb (silence suppression / comfort noise)
; Set to "no" to disable Annex B - recommended for better compatibility
g729_annexb=no

[my-trunk]
type=peer
host=sip.provider.com
disallow=all
allow=g729        ; G.729 as primary codec
allow=ulaw        ; G.711 ulaw as fallback
dtmfmode=rfc2833  ; Always use RFC 2833 for DTMF with G.729
qualify=yes

pjsip.conf (Modern PJSIP)

; /etc/asterisk/pjsip.conf

[my-endpoint]
type=endpoint
context=from-trunk
disallow=all
allow=g729         ; G.729 as primary codec
allow=ulaw         ; G.711 as fallback
dtmf_mode=rfc4733  ; RFC 4733 (RFC 2833) for DTMF
rtp_symmetric=yes
force_rport=yes

; To disable G.729 Annex B (silence suppression)
; Most endpoints work best with Annex B disabled
; This is handled automatically in most PJSIP configurations

modules.conf — Auto-load the Module

; /etc/asterisk/modules.conf
[modules]
autoload=yes

; Ensure G.729 module loads at startup
load => codec_g729.so

7. Vicidial-Specific Configuration

Vicidial uses Asterisk as its telephony engine. After installing the G.729 codec at the Asterisk level, you need to configure Vicidial to use it for carrier trunks and agent phones.

Carrier Configuration

In the Vicidial Admin panel, navigate to Admin → Carriers and update your carrier trunk:

; In the carrier "Registration String" or custom dialplan:
; Set codec in the carrier trunk peer definition

[carrier-trunk]
type=peer
host=carrier.example.com
disallow=all
allow=g729
allow=ulaw
dtmfmode=rfc2833
insecure=invite,port
canreinvite=no

Phone Configuration

For agent phones (softphones or hardware phones), configure the phone entry in Admin → Phones:

; In the phone SIP peer definition:
[agent-phone]
type=friend
context=default
host=dynamic
disallow=all
allow=g729       ; Saves bandwidth between agent phone and Asterisk
allow=ulaw       ; Fallback
nat=force_rport,comedia
qualify=yes

Important Vicidial Considerations

  • Agent-to-Carrier Same Codec: Use the same codec (G.729) on both the agent phone and the carrier trunk to avoid transcoding. Transcoding consumes CPU and degrades quality.
  • Conferencing / Recording: Vicidial uses MeetMe or ConfBridge for call recording. These may require transcoding to a common codec internally. Monitor CPU usage after enabling G.729.
  • Dial String: The Vicidial dial string does not need changes for codec selection. Codec negotiation happens at the SIP level.
  • Multiple Servers: If running a Vicidial cluster, install bcg729 and codec_g729 on every Asterisk server in the cluster.
  • Vicibox: If using Vicibox (Vicidial appliance), bcg729 may already be included. Check with asterisk -rx "module show like g729" before installing.

8. Testing the G.729 Codec

Verify Codec is Loaded

# Check if G.729 appears in the codec list
asterisk -rx "core show codecs" | grep -i g729
# Expected output:
#   18    audio   g729     (8000)    8    G.729

# Show codec translation paths (verify G.729 can transcode)
asterisk -rx "core show translation"
# Look for the g729 row/column - values should be numbers (ms), not "-"
# Example: ulaw -> g729 shows a value like "5" meaning 5ms to transcode

# Verify the module is running
asterisk -rx "module show like g729"
# Expected:
# codec_g729.so    G.729 Coder/Decoder    0    Running

Test a Call with G.729

# Make a test call and check which codec is negotiated
asterisk -rx "core show channels verbose"
# Look for the "NativeFormat" or "Format" column - should show "g729"

# During an active call, check the channel details
asterisk -rx "core show channel <channel_name>"
# Look for:
#   Native Formats: (g729)
#   Read Format: g729
#   Write Format: g729

# Check SIP negotiation (for chan_sip)
asterisk -rx "sip show channel <channel>"
# Look for "Negotiated codec: g729"

# Check PJSIP negotiation
asterisk -rx "pjsip show channel <channel>"
# Look for negotiated media formats

Quick Dialplan Test

; Add this to extensions.conf for a G.729 codec test extension
[internal]
exten => 729,1,Answer()
 same => n,Playback(tt-weasels)
 same => n,Hangup()

; Call extension 729 from a G.729-enabled phone
; Check the console output for the negotiated codec

9. Troubleshooting Common Issues

ProblemCauseSolution
module load codec_g729.so failsbcg729 library not foundRun ldconfig after installing bcg729. Check /usr/lib or /usr/lib64 for libbcg729.so. Try: ln -s /usr/lib/libbcg729.so.0 /usr/lib64/libbcg729.so
codec_g729.so not found in modules dirModule not compiled or installed to wrong pathCheck /usr/lib/asterisk/modules/ and /usr/lib64/asterisk/modules/. Recompile with correct --with-asterisk-includes path.
488 Not Acceptable Here on callsRemote side does not support G.729Add a fallback codec: allow=ulaw after allow=g729. Ensure the remote peer also has G.729 configured.
Audio is robotic / garbledPacket loss or jitter on the networkG.729 is more sensitive to packet loss than G.711. Check network quality with ping and traceroute. Consider a jitter buffer.
High CPU usage after enabling G.729Transcoding between G.729 and other codecsUse the same codec end-to-end to avoid transcoding. If transcoding is needed, monitor with: asterisk -rx "core show translation"
No audio on G.729 callsRTP ports blocked or NAT issueSame as any codec: open UDP 10000-20000, configure NAT settings. G.729 uses RTP like any other codec.
Version mismatch error on module loadModule compiled for different Asterisk versionRecompile codec_g729 against the exact Asterisk version source headers. Version must match exactly.
"Unable to register format g729" in logsAnother G.729 module already loadedCheck if both codec_g729.so and format_g729.so exist. Unload any conflicting modules.
G.729 Annex B issues (silence suppression)Mismatch in Annex B support between endpointsSet g729_annexb=no in sip.conf [general] section. Most implementations work best with Annex B disabled.
Fax calls failing over G.729G.729 cannot carry fax signalsUse G.711 (ulaw/alaw) for fax or enable T.38 passthrough. Never route fax over G.729.

10. Performance & Transcoding Tips

Minimize Transcoding

Transcoding (converting between codecs in real-time) is CPU-intensive. Each G.729 ↔ G.711 transcode uses approximately ~2–3 MIPS per channel. For a server handling 500 concurrent calls, transcoding can consume significant CPU resources.

  • End-to-end same codec: Configure phones AND trunks to use G.729 to avoid transcoding entirely
  • Codec ordering matters: List G.729 first in the allow= directive on all peers
  • Avoid mixed codec conferences: When mixing G.729 and G.711 participants in a conference, Asterisk must transcode each stream

Capacity Planning

ScenarioCPU ImpactRecommendation
G.729 end-to-end (no transcoding)MinimalBest case — just passthrough
G.729 ↔ G.711 transcodingModerate (~2 MIPS/channel)Acceptable for <200 channels
G.729 ↔ Opus transcodingHighAvoid if possible; use same codec
Conference with mixed codecsHigh (N transcodes)Force one codec per conference profile

Monitoring Commands

# Check current transcoding paths and costs (in microseconds)
asterisk -rx "core show translation"

# Monitor active channels and their codecs
asterisk -rx "core show channels verbose"

# Check system resource usage
asterisk -rx "core show sysinfo"

# Monitor CPU usage from Linux
top -p $(pidof asterisk)

# Check for transcoding in active calls
asterisk -rx "core show channels verbose" | grep -v "g729.*g729"
# Any lines shown indicate transcoding is happening
G.729 is a standard defined by the ITU-T. Asterisk is a registered trademark of Sangoma Technologies. Vicidial is a trademark of the Vicidial Group. This guide is for educational and reference purposes.