login | register
Tue 07 of Oct, 2008 [17:53 UTC]

voip-info.org

Discuss [1] History

Asterisk config codecs.conf

Created by: stevekstevek,Last modification on Mon 24 of Jul, 2006 [09:05 UTC] by JustRumours
Configuration file for asterisk codecs.

Example for Asterisk 1.2:

See also bug/patch 2536

  [speex]
  ;0-10
  quality => 3
  ;0-10
  complexity => 4
  ; true / false
  enhancement => true
  ; true / false
  vad => false
  ; true / false
  vbr => false
  ; 0 = off, otherwise, target bitrate in bps
  abr => 0
  ;0-10
  vbr_quality => 5
  ; true / false
  dtx => false

  [plc]
  ; for all codecs which do not support native PLC
  ; this determines whether to perform generic PLC
  ; there is a minor performance penalty for this
  genericplc => true

Configuring speex bitrates

For CBR, there is a 1:1 correlation between "quality" and bitrate. The speex documentation has a table which describes this here:
http://speex.org/manual2/node9.html

Table 4: Quality versus bit-rate
Mode  Bit-rate (bps)  mflops  Quality/description
0  250  N/A  No transmission (DTX)
1  2,150  6  Vocoder (mostly for comfort noise)
2  5,950  9  Very noticeable artifacts/noise, good intelligibility
3  8,000  10  Artifacts/noise sometimes noticeable
4  11,000  14  Artifacts usually noticeable only with headphones
5  15,000  11  Need good headphones to tell the difference
6  18,200  17.5  Hard to tell the difference even with good headphones
7  24,600  14.5  Completely transparent for voice, good quality music
8  3,950  10.5  Very noticeable artifacts/noise, good intelligibility 

Of course, this table isn't helpful unless you also know this:mapping between "quality" setting, and modes:
modes_noglobals.c: int quality_map[11] = {1, 8, 2, 3, 3, 4, 4, 5, 5, 6, 7};

so:
 quality 0 = mode 1 = 2,150kbps.
 quality 1 = mode 8 = 3.950kbps
 quality 2 = mode 2 = 5.950kbps
 quality 3 = mode 3 = 8.000kbps
 quality 4 = mode 3 = 8.000kbps
 quality 5 = mode 4 = 11.000kbps
 quality 6 = mode 4 = 11.000kbps
 quality 7 = mode 5 = 15.000kbps
 quality 8 = mode 5 = 15.000kbps
 quality 9 = mode 6 = 18.200kbps
 quality 10 = mode 7 = 24.600kbps

Maybe that should go into the docs somewhere. (it might have been easier if the "bitrate" parameter was specified, so you could just choose a bitrate, but that's not the way it was done.

I just contributed the fix to CVS for ABR mode, however. ABR mode will use a variable bitrate in order to meet an "average" bitrate target. It's easy to specify, and works really well.

To use this, just choose set the bitrate, in bps, you want in the abr => parameter. For example, use abr => 8000. This will in general, sound significantly better than the CBR mode at the same bitrate, since it will use more bits for more complex parts of speech, and less bitrates for less complex parts. It does use more CPU, of course, in this mode.. Which brings me to the next point:

The "complexity" parameter basically tells the codec how much CPU to use. If it's using too much CPU, set the complexity down a bit. 2 or 3 are usually good choices, although 1 works fine if you're short of CPU. This only affects encoding, and doesn't affect the bitrate, but basically tells the codec how hard to search for the "best" bits to represent the speech.

So, the settings I'd recommend for 8kbps speex would then be:

[speex]
;0-10
quality => 4
;0-10
complexity => 3
; true / false
enhancement => true
; true / false
vad => false
; true / false
vbr => false
; 0 = off, otherwise, target bitrate in bps
abr => 8000
;0-10
vbr_quality => 5
; true / false
dtx => false

And if you are CPU bound, lower the complexity..

Other notes

Enhancement is a perceptual enhancer for decoding. Other than this, all settings apply to the encoder only.

Question: But what will it negotiate to (with different speex settings on two Asterisk boxes)?"

  1. The speex settings are set on the encode side: speex decoders can decode any valid speex bit-stream: This is just like mp3 encoders: You can encode with whatever encoder and settings you want, and any decoder can decode them.
  2. These settings, in particular, will tell asterisk how to encode speex. So, if you set these settings on server (A), it will affect all outgoing speex streams. It will _not_ affect how other servers using speex send things to you. They'll use either the default settings, or whatever they're configured to send.

See also



Go back to Asterisk


Comments

Comments Filter
222

333Codecs Config for g.729

by phillpiratz, Sunday 18 of September, 2005 [15:30:00 UTC]
Hi guys

I'd like to set up the codecs.conf file to g.729 codec. Where could I set up 3 frames per TX in Asterisk PBX?