FreeSWITCH is a transcoding media server. When two endpoints negotiate different codecs during SDP offer/answer, FreeSWITCH decodes the audio from one codec and re-encodes it in the other, allowing incompatible devices to communicate seamlessly. Codec support is provided by loadable modules: audio codec modules register specific encoders and decoders, and video codec modules handle compressed video streams. Two foundational codecs — G.711 (PCMU/PCMA) and G.722 — are compiled directly into the FreeSWITCH core and are always available, requiring no additional module.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/signalwire/freeswitch/llms.txt
Use this file to discover all available pages before exploring further.
Built-in Codecs
These codecs are part of the FreeSWITCH core and are available without loading any module:| Codec | Description | Sample Rate |
|---|---|---|
| PCMU (G.711 µ-law) | Uncompressed 8-bit µ-law PCM. North American PSTN standard. | 8 kHz |
| PCMA (G.711 A-law) | Uncompressed 8-bit A-law PCM. European PSTN standard. | 8 kHz |
| G.722 | ITU-T wideband codec using ADPCM sub-band coding. | 16 kHz |
Audio Codecs
| Module | Codec | Sample Rate | Bitrate | Notes |
|---|---|---|---|---|
mod_opus | Opus | 8–48 kHz | 6–510 kbps | Royalty-free; adaptive bitrate; DTX; FEC |
mod_g729 | G.729 | 8 kHz | 8 kbps | Commercial license required for encoding |
mod_com_g729 | G.729 | 8 kHz | 8 kbps | Commercial G.729 module from SignalWire |
mod_g723_1 | G.723.1 | 8 kHz | 5.3 / 6.3 kbps | Legacy; low bandwidth |
mod_amr | AMR-NB | 8 kHz | 4.75–12.2 kbps | GSM mobile narrowband |
mod_amrwb | AMR-WB (G.722.2) | 16 kHz | 6.6–23.85 kbps | GSM mobile wideband |
mod_ilbc | iLBC | 8 kHz | 13.3 / 15.2 kbps | Good quality at very low bitrates |
mod_silk | SILK | 8–24 kHz | Variable | Skype codec; predecessor to Opus |
mod_bv | BroadVoice (BV16/BV32) | 8 / 16 kHz | 16 / 32 kbps | Broadcom wideband codec |
mod_codec2 | Codec2 | 8 kHz | 700–3200 bps | Extremely low bitrate; amateur radio / IoT |
mod_siren | G.722.1 / Siren | 16 / 32 kHz | 16–32 kbps | Polycom-developed wideband codec |
mod_b64 | Base64 audio | — | — | Encodes raw audio as base64; not for production voice |
mod_opus
mod_opus wraps the libopus reference implementation and is the recommended codec for all WebRTC (mod_verto) and modern SIP deployments. It supports adaptive bitrate, in-band FEC (forward error correction) for packet loss resilience, and discontinuous transmission (DTX) to save bandwidth during silence.
Default codec settings in mod_opus:
mod_g729
mod_g729 implements G.729 in passthrough mode — it can relay G.729-encoded RTP streams between two endpoints without transcoding. Full transcoding (encoding and decoding G.729 audio) requires either a commercial G.729 license or the mod_com_g729 module.
G.729 licensing: The G.729 codec is covered by patents held by multiple companies. Using G.729 for encoding in production requires a commercial per-channel or per-server license. Passthrough (no decoding or re-encoding) generally does not require a license. Opus is a patent-free alternative with superior quality at comparable bitrates.
Video Codecs
| Module | Codec | Notes |
|---|---|---|
mod_openh264 | H.264 | Via Cisco’s OpenH264 library; baseline profile |
Core (switch_vpx.c) | VP8 and VP9 | Built into the FreeSWITCH core; no separate loadable module |
mod_av | H.264, VP8, VP9, others | Via libavcodec (FFmpeg); broader codec support |
VP8 and VP9
VP8 and VP9 support is compiled directly into FreeSWITCH’s core (src/switch_vpx.c). There is no separate loadable mod_vpx module — the VP8 and VP9 codecs are registered by the core itself. VP8 is the standard WebRTC video codec and is required for mod_verto video calls. VP9 provides significantly better compression than VP8 at similar quality levels.
mod_openh264
mod_openh264 provides H.264 encoding and decoding using Cisco’s OpenH264 library, which Cisco licenses royalty-free for certain use cases. H.264 (MPEG-4 AVC) is the dominant video codec for SIP video calls and is widely supported across hardware endpoints, browsers, and conferencing systems. The module source is in src/mod/codecs/mod_openh264/mod_openh264.cpp.
mod_av
mod_av (in src/mod/applications/mod_av/) uses libavcodec from FFmpeg to provide a broader set of video codecs beyond H.264 and VP8. It also supports audio/video file recording in standard container formats (MP4, MKV, WebM).
Configuring Codec Preferences
FreeSWITCH uses a priority-ordered list of codec names to negotiate codecs with remote endpoints. This list is consulted during SDP offer/answer: FreeSWITCH offers codecs in the specified order and selects the highest-priority mutually supported codec.Global Codec Preferences
The primary codec preference list is set inconf/vars.xml and applies system-wide:
Per-Profile Codec Preferences
SIP profiles can override the global list for all calls through that profile:Per-User / Per-Gateway Codec Override
Individual users in the directory or outbound gateways can specify their own codec list. For a user entry:Transcoding
FreeSWITCH performs transcoding automatically when the codec on the A-leg differs from the codec on the B-leg. For example, if a WebRTC caller using Opus calls a SIP phone that only supports G.711, FreeSWITCH decodes the Opus RTP from the browser, converts the PCM audio, and re-encodes it as G.711 RTP for the phone — and vice versa for audio flowing in the other direction.Performance Considerations
Codec matching reduces CPU load
When both legs negotiate the same codec, FreeSWITCH can operate in bypass media mode — RTP packets are forwarded directly between endpoints without being decoded. This eliminates transcoding CPU cost entirely.
Narrowband↔Wideband conversion is expensive
Transcoding between narrowband (8 kHz) and wideband (16 kHz) codecs requires resampling in addition to codec conversion. Minimize these paths in high-concurrency environments.
Prefer Opus for WebRTC legs
Opus natively supports both narrowband and wideband sample rates in a single stream. If the far end supports Opus, FreeSWITCH can avoid resampling entirely by selecting the appropriate Opus mode.
Codec Negotiation
FreeSWITCH follows the SIP SDP offer/answer model (RFC 3264) for codec negotiation:-
Inbound call (UAS mode): FreeSWITCH receives an INVITE with an SDP offer from the remote party. It selects codecs from the offer that appear in its own
inbound-codec-prefslist, in preference order, and sends them back in the 200 OK SDP answer. -
Outbound call (UAC mode): FreeSWITCH sends an INVITE with an SDP offer listing its
outbound-codec-prefs. The remote party responds with the subset it accepts.
Forcing a Specific Codec
Use theabsolute_codec_string channel variable to override all codec preference lists and force a specific codec for a call leg. This is evaluated before the SDP offer is generated:
export application (rather than set) ensures the variable is copied to the B-leg session, affecting the codec negotiation for that leg’s SDP.