I’ve got asterisk 13.14 running with opus loaded. I’m able to register xlite and place calls with opus 48k without an [opus] entry in codecs.conf and with allow=opus.
I have [opus48] through [opus8] in codecs.confg, but when I put these in allow= (ie, allow=opus48) I can’t place a call, says "chan_sip.c: No compatible codecs, not accepting this offer!"
I can only put ‘opus’ in allow…
This basically means I’m stuck with opus 48k at up to 384kbps.
I really need to get down to opus8,12, or 16 with fec=true and packet_loss=50.
Here is my codecs.conf. I added the last line for [opus] to test setting the max bitrate, didn’t work.:
[opus48]
type=opus
samprate=48000 ; Sample rate of this opus format in hz.
; 8000, 12000, 16000, 24000, 48000 are acceptable values.
fec=true ; turn on or off encoding with forward error correction.
; On recommended, off by default.
;maxbitrate=10000 ; Use the table below to make sure a useful bitrate is chosen
; for maxbitrate. If not set or value is not within the bounds
; of the encoder, a default value is chosen.
;
; sample rate | bitrate range
; 8khz | 6000 - 20000 bps
; 12khz | 7000 - 25000 bps
; 16khz | 8000 - 30000 bps
; 24khz | 18000- 28000 bps
; 48khz | 24000- 32000 bps
;dtx=true ; Encode using discontinuous transmission mode or not. Turning this
; on will save bandwidth during periods of silence at the cost of
; increased computational complexity. Off by default.
;cbr=true ; Whether or not to encode with constant or variable bit rate. Constant
; bit rate is disabled by default.
[opus24]
type=opus
samprate=24000 ; Sample rate of this opus format in hz.
; 8000, 12000, 16000, 24000, 48000 are acceptable values.
fec=true ; turn on or off encoding with forward error correction.
; On recommended, off by default.
;maxbitrate=10000 ; Use the table below to make sure a useful bitrate is chosen
; for maxbitrate. If not set or value is not within the bounds
; of the encoder, a default value is chosen.
;
; sample rate | bitrate range
; 8khz | 6000 - 20000 bps
; 12khz | 7000 - 25000 bps
; 16khz | 8000 - 30000 bps
; 24khz | 18000- 28000 bps
; 48khz | 24000- 32000 bps
;dtx=true ; Encode using discontinuous transmission mode or not. Turning this
; on will save bandwidth during periods of silence at the cost of
; increased computational complexity. Off by default.
;cbr=true ; Whether or not to encode with constant or variable bit rate. Constant
; bit rate is disabled by default.
[opus16]
type=opus
samprate=16000 ; Sample rate of this opus format in hz.
; 8000, 12000, 16000, 24000, 48000 are acceptable values.
fec=true ; turn on or off encoding with forward error correction.
; On recommended, off by default.
;maxbitrate=10000 ; Use the table below to make sure a useful bitrate is chosen
; for maxbitrate. If not set or value is not within the bounds
; of the encoder, a default value is chosen.
;
; sample rate | bitrate range
; 8khz | 6000 - 20000 bps
; 12khz | 7000 - 25000 bps
; 16khz | 8000 - 30000 bps
; 24khz | 18000- 28000 bps
; 48khz | 24000- 32000 bps
;dtx=true ; Encode using discontinuous transmission mode or not. Turning this
; on will save bandwidth during periods of silence at the cost of
; increased computational complexity. Off by default.
;cbr=true ; Whether or not to encode with constant or variable bit rate. Constant
; bit rate is disabled by default.
[opus12]
type=opus
samprate=12000 ; Sample rate of this opus format in hz.
; 8000, 12000, 16000, 24000, 48000 are acceptable values.
fec=true ; turn on or off encoding with forward error correction.
; On recommended, off by default.
;maxbitrate=10000 ; Use the table below to make sure a useful bitrate is chosen
; for maxbitrate. If not set or value is not within the bounds
; of the encoder, a default value is chosen.
;
; sample rate | bitrate range
; 8khz | 6000 - 20000 bps
; 12khz | 7000 - 25000 bps
; 16khz | 8000 - 30000 bps
; 24khz | 18000- 28000 bps
; 48khz | 24000- 32000 bps
;dtx=true ; Encode using discontinuous transmission mode or not. Turning this
; on will save bandwidth during periods of silence at the cost of
; increased computational complexity. Off by default.
;cbr=true ; Whether or not to encode with constant or variable bit rate. Constant
; bit rate is disabled by default.
[opus8]
type=opus
samprate=8000 ; Sample rate of this opus format in hz.
; 8000, 12000, 16000, 24000, 48000 are acceptable values.
fec=true ; turn on or off encoding with forward error correction.
; On recommended, off by default.
;maxbitrate=10000 ; Use the table below to make sure a useful bitrate is chosen
; for maxbitrate. If not set or value is not within the bounds
; of the encoder, a default value is chosen.
;
; sample rate | bitrate range
; 8khz | 6000 - 20000 bps
; 12khz | 7000 - 25000 bps
; 16khz | 8000 - 30000 bps
; 24khz | 18000- 28000 bps
; 48khz | 24000- 32000 bps
;dtx=true ; Encode using discontinuous transmission mode or not. Turning this
; on will save bandwidth during periods of silence at the cost of
; increased computational complexity. Off by default.
;cbr=true ; Whether or not to encode with constant or variable bit rate. Constant
; bit rate is disabled by default.
Opus always appears at 48kHz in SDP and in RTP. The ability to set the sample rate was used for early implementations that did not do this properly. This has been fixed and the option has been removed. You’ll want to use the “max_bandwidth”, “max_playback_rate”, and “bitrate” options to control things further. I’d also suggest looking at the console log at Asterisk startup as it can tell you if things aren’t right when creating the format.
You can create custom entries in codecs.conf with those set, or override the opus one. If valid then a format of the given name is created with those options. Example:
I put your example in codecs.conf and set my allow=opus24, restarted via ‘core restart’
asterisk says
chan_sip.c:10798 process_sdp: No compatible codecs, not accepting this offer!
format_cap.c:401 ast_format_cap_update_by_allow_disallow: Cannot allow unknown format ‘opus24’
chan_sip.c:31427 build_peer: Codec configuration errors found in line 0 : allow = opus24
@dananderson I have the same problem, followed this talk but couldn’t succeed. As soon as I put a custom configuration as [opus] entry, or enable additional entries such as [opus8] (and of course make the allow=opus8 in the peer) I get:
NOTICE[1925][C-00000001] chan_sip.c: No compatible codecs, not accepting this offer!
I’m on asterisk 16, compiled from sources. How did you succeed, and which is your mistake? The missing [opus24] entry?
As a sidenote, the first core reload complains about a missing format opus24, but a second one goes well. Still not accepting the offer. Otherwise, opus is going smoothly with default config (at a gross of 70 kbit/s).
Ok I solved, it was a grammar error in the parameters in codec.conf. In the meanwhile I also switched to pjsip and enabled WebRTC support with my Opus specific config (in particular narrowband). Only issue I have left is that the max ptime is always seto to 20 ms and cannot be increased. Do you have any suggestions in this regard? Thanks!!