# Codec selection

**URL:** <https://community.asterisk.org/t/codec-selection/9708>\
**Category:** Asterisk Support\
**Created:** [October 5, 2006, 7:31pm UTC](https://community.asterisk.org/t/codec-selection/9708 "2006-10-05T19:31:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Flash05](https://avatars.discourse-cdn.com/v4/letter/f/54ee81/32.png) [@Flash05](https://community.asterisk.org/u/Flash05)\
**Post date:** [October 5, 2006, 7:31pm UTC](https://community.asterisk.org/t/codec-selection/9708/1 "2006-10-05T19:31:41Z")

</div>

What if sip.conf doesnt have codec set? what will be the default codec that will be used?

example

[test]  
type=friend  
username=test  
secret=test  
host=dynamic  
context=test  
nat=yes  
;disallow=all

---

<div class="post-metadata">

**Author:** ![dmikusa](https://avatars.discourse-cdn.com/v4/letter/d/e47c2d/32.png) [@dmikusa](https://community.asterisk.org/u/dmikusa)\
**Post date:** [October 5, 2006, 7:47pm UTC](https://community.asterisk.org/t/codec-selection/9708/2 "2006-10-05T19:47:40Z")

</div>

If you do not specify what codecs to use in sip.conf, either in the global settings or on a per user basis, then I believe that the choice is left up to the client. So any format that Asterisk supports and the Client supports that the client would like to use.

Dan

---

<div class="post-metadata">

**Author:** ![Flash05](https://avatars.discourse-cdn.com/v4/letter/f/54ee81/32.png) [@Flash05](https://community.asterisk.org/u/Flash05)\
**Post date:** [October 5, 2006, 9:24pm UTC](https://community.asterisk.org/t/codec-selection/9708/3 "2006-10-05T21:24:17Z")

</div>

tnx.

But what about the preference if not specified in sip.conf per extension? random?

---

<div class="post-metadata">

**Author:** ![dmikusa](https://avatars.discourse-cdn.com/v4/letter/d/e47c2d/32.png) [@dmikusa](https://community.asterisk.org/u/dmikusa)\
**Post date:** [October 6, 2006, 2:45pm UTC](https://community.asterisk.org/t/codec-selection/9708/4 "2006-10-06T14:45:13Z")

</div>

Asterisk won’t prefer anything. The client will choose which codec it wants to use and tell Asterisk to use that codec. The only preference that Asterisk has is what you specify in sip.conf. If you choose not to put anything in sip.conf, then the decision will be left up to the client.

Example:

I start a call to my Asterisk machine from my SIP phone. My SIP phone supports ulaw, alaw, and gsm. Asterisk supports all of those codecs, and since we are not specifying any settings about which codec to use in sip.conf it leaves the choice up to the client. My SIP phone will then make the choice, depending on your sip phone and how you have configured it, as to which codec to use. The SIP phone I use, will choose ulaw by default because of the best sound quality.

Dan

---

<div class="post-metadata">

**Author:** ![Flash05](https://avatars.discourse-cdn.com/v4/letter/f/54ee81/32.png) [@Flash05](https://community.asterisk.org/u/Flash05)\
**Post date:** [October 6, 2006, 3:44pm UTC](https://community.asterisk.org/t/codec-selection/9708/5 "2006-10-06T15:44:37Z")

</div>

Tnx!

What is the recommended/preferred codec order?

---

<div class="post-metadata">

**Author:** ![dmikusa](https://avatars.discourse-cdn.com/v4/letter/d/e47c2d/32.png) [@dmikusa](https://community.asterisk.org/u/dmikusa)\
**Post date:** [October 6, 2006, 4:21pm UTC](https://community.asterisk.org/t/codec-selection/9708/6 "2006-10-06T16:21:32Z")

</div>

It depends on what you are trying to do. Each codec is good for different things.

The most common are ulaw and gsm. ulaw sounds the best, but takes the most bandwidth. Most voip providers use this. gsm is great for linking offices together as it takes much less bandwidth per call (1/3 - 1/4 the size) than ulaw, but still sounds ok.

There are many other codecs you just have to find one that works good for your goals.

Dan

---

<div class="post-metadata">

**Author:** ![Flash05](https://avatars.discourse-cdn.com/v4/letter/f/54ee81/32.png) [@Flash05](https://community.asterisk.org/u/Flash05)\
**Post date:** [October 6, 2006, 4:43pm UTC](https://community.asterisk.org/t/codec-selection/9708/7 "2006-10-06T16:43:22Z")

</div>

balance for bandwidth and quality.
