How to make opus -narrowband in asterisk 13?

I am using asterisk 13 . How to add opus -narrowband in it? How would I able to do it ? Also I have added sample_rate in opus.c from 48000 to 8000 . sometimes opus gives one way audio .please give me standard way to achieve it …::slight_smile:

See -

and the max_bandwidth option

Thank you , malcolmd.I have tried this option but it’s not giving me results. regards.

Well, I don’t know what to tell you. That’s the operation that controls what’s fed into the encoder. It’s possible that it’s not working properly, or it’s possible there’s something amiss in the endpoint being connected. There’s not really anything in this thread that’d allow for progression to your query.

What I am asking is , Is it sufficient to make opus narrowband by making changes only in codec.conf ? Are there any other changes requires ? Regards.

After creating a specific opus with parameters in codecs.conf, you’d have to then apply that custom codec to an endpoint with the allow option for that endpoint. Are you doing that and seeing that the audio going across the wire isn’t limited to narrowband frequency ranges?

yes , I have allowed that custom opus to endpoint. Audio is not going through wire , it’s wireless.

“across the wire” was being used in a sense that covers any means of communicating outside of Asterisk, so includes “over the air”.

I’m not sure what your issue is, there isn’t enough to diagnose what the problem might be.

I’ve taken Asterisk 14, a Digium D65 running firmware (current), codec_opus 1.0.1 from the Digium download server, and I’ve created two custom opus types in codecs.conf:



I can then selectively apply opus8 or opus16 to the endpoint, e.g.:




I can call into the Echo() application and I can hear audio, which means it’s bidirectional. I’ve not plugged the resultant audio into an analyzer to verify the frequency range, but I can hear a stark difference between my opus8 and my opus16 configured calls. So, it’s definitely sending narrowband (I’ve listened to a lot of phone audio in my days) when it’s configured for opus8 and it’s definitely sending wideband when it’s configured for opus16. FWIW, I’ve also done playback of music files, because it’s easier to tell the frequency response w/ them than it is with your own voice.

I can also verify that Asterisk is using the opus8 and opus16 formats by looking at the output of “core show channel PJSIP/xyz” where xyz is my channel and unique channel identifier, e.g.:

NativeFormats: (opus8)
WriteFormat: opus8
ReadFormat: opus8


NativeFormats: (opus16)
WriteFormat: opus16
ReadFormat: opus16

So I’m pretty sure that forcing the opus encoder to narrowband mode is working and that it’s going across the wire.

The Digium phone is on the same LAN as the Asterisk server, so I don’t have any NAT, routers, or ALG at play that could cause the works to be fouled.



Thanks for your reply , but what happen in my case is : whenever I add custom [opus8] and allow at endpoint , it ignore completely and select next allow codec. can you please lead on the way so that I can allow it?

Are you sure the codec has been properly loaded? How did you install it? What’s the output of the following commands:

module show like
module show like

What channel driver are you using chan_sip or chan_pjsip?

Can you post the relevant sections from your codecs.conf and pjsip.conf (or sip.conf if using chan_sip).

What’s the invite look like? (can obtain this through a packet capture or by turning on sip debug in Asterisk - e.g. ‘pjsip set logger on’) Are you sure it is sending opus in the SDP?

Also, iirc, codec.conf entries can’t be dynamically loaded; adding/removing/changing entries in codecs.conf in a running Asterisk requires an Asterisk restart.

@kharwell thank you for your reply.Here is my output.

user-asterisk*CLI> module show like
Module Description UseCount Status Support Level Opus Coder/Decoder 0 Running unknown
1 modules loaded

user-asterisk*CLI> module show like
Module Description Use Count Status Support Level
0 modules loaded

Channel driver : chan_sip


[opus8] (As @malcolmd suggested )


@malcolmd thank you for your reply . I have restarted asterisk after changing codecs.conf . Can you please provide your invite signal with SDP in your opus case implementation . i.e. opus8 . Can you please post your INVITE of using opus8 with SDP? That will help to diagnose problem more precisely. Regards.

How do you plan to use an example of my working INVITE to troubleshoot?

The SDP won’t include “opus8,” it’ll only include opus. “opus8” is just an internal-to-Asterisk identifier for a special-case Opus codec with the parameters you define in codecs.conf.

What is your calling scenario that you experience one-way and/or non-narrowband Opus? Do you have the SIP logging to show the call setup between the endpoints?

This is a little odd to me that module is not loaded. Is it set to “no load”? Does it exist under the asterisk/modules directory (if default installed it should be under /usr/lib/asterisk/modules).

Where/How did you obtain the codec_opus module?

From the Asterisk CLI what is the output of the following command:

config show help codec_opus opus max_bandwidth

Also what is the output of the following executed from your OS’s command line (substitute your path if different):

nm -D /usr/lib/asterisk/modules/

hi @malcolmd . thank you for your reply.I want to compare your invite with mine , because I feel that I must missing something that makes me one step away from opus narrowband. I

—> case 1:

asterisk 13 gives proper audio on both side without narrowband.Installed opus from digium for asterisk 13.

----> case 2:
asterisk 14 gives one way audio without narrowband .even I am getting one way voice in every codecs in asterisk 14 . can you also suggest some points why one way audio is there ? PC is behind firewall .

===> Also can you suggest me : Does version of ubuntu affects in narrowband ? I am using ubuntu 14.04 .

===> Can you tell me how much bandwidth consumption of one minute in narroband ? so that can come to know precisely about opus narrowband.

===> And yes , we do not need to download opus externally in asterisk 14. In installation , after ./configure —> make menuselect ----> select opus in (codec translators) . It is going to automatically download opus in make and make install. So I have that opus .

===> also the version of asterisk affects opus nb . I want to ask does opus narrowband supported by which version of asterisk ?


hi @kharwell . Thank you for your reply. I have reinstall everything.

Have installed asterisk-14.2.1 instead of asterisk 13. but asterisk 14 gives one way audio in every codecs .
Now ,

user-asterisk*CLI> module show like
Module Description Use Count Status Support Level OGG/Opus audio 0 Running core
1 modules loaded

–> In asterisk 14 , opus is downloaded automatically , If we have select it after ./configure in make menuselect under codec translator . I have downloaded opus that way.

----> Here is o/p of : config show help codec_opus opus max_bandwidth

user-asterisk*CLI> config show help codec_opus opus max_bandwidth
max_bandwidth = [Custom] (Default: full) (Regex: false)

Encoder’s maximum bandwidth allowed.

Sets an upper bandwidth bound on the encoder. Can be any of the following:

—> o/p of nm -D /usr/lib/asterisk/modules/ :

root@user-asterisk:/usr/src/asterisk-14.2.1# nm -D /usr/lib/asterisk/modules/
U __ao2_cleanup_debug
U __ao2_global_obj_ref
U __ao2_global_obj_release
U __ao2_global_obj_replace_unref
U __ao2_ref
U ast_codec_get
U __ast_codec_register
U ast_format_attribute_get
U ast_format_attribute_set
U ast_format_cache_set
U ast_format_clone
U ast_format_create_named
U ast_format_get_sample_rate
U ast_format_parse_sdp_fmtp
U ast_frisolate
U ast_log
U ast_module_name
U ast_module_register
U ast_module_unregister
U ast_pbx_uuid_get
U ast_pthread_create_detached_stack
U __ast_pthread_mutex_trylock
U __ast_pthread_mutex_unlock
U __ast_register_file
U __ast_register_translator
U ast_rtp_engine_load_format
U ast_sorcery_alloc
U __ast_sorcery_apply_default
U ast_sorcery_generic_alloc
U ast_sorcery_instance_observer_add
U ast_sorcery_instance_observer_remove
U ast_sorcery_load
U __ast_sorcery_object_field_register
U ast_sorcery_object_get_id
U __ast_sorcery_object_register
U ast_sorcery_object_unregister
U __ast_sorcery_open
U ast_sorcery_unref
U ast_str_set
U ast_true
U __ast_unregister_file
U ast_unregister_translator
U atan2
U calloc
U cosf
U curl_easy_cleanup
U curl_easy_init
U curl_easy_perform
U curl_easy_setopt
U curl_slist_append
U curl_slist_free_all
w __cxa_finalize
U exp
U floor
U floorf
U free
w gmon_start
w _Jv_RegisterClasses
U log
U log10
U log10f
U logf
U lrintf
U malloc
U memcpy
U memmove
U memset
U pow
U snprintf
U sprintf
U sqrt
U sqrtf
U sscanf
U time

Regards .

As this seems to no longer be a question of narrowband, where you seem primarily worried about one-way audio instead, and as I’ve given a lovely example in an earlier posting about setting Opus to narrowband encoding, and where you’ve posted another thread that seems much more germane to your current problem than the rat-hole this thread is becoming, I’m shutting this one down.

1 Like