Streaming moh from VLC

Hi all,
I’m trying to stream mp3 files for music on hold from an VLC player, so that I can control (play, pause, next song…) it.
In order to get that, I’ve configured the musiconhold.conf file to run the VLC application listening at UDP port 1234.
However, I can see that music is captured but nothing is played at the SIP devices (they support mp3 codecs).

This is the musiconhold.conf file:


[default]
mode=custom
application=/usr/bin/vlc-wrapper -vvv udp://@:1234

Should I do anything else to adapt VLC to asterisk? Which could be the mistake?
Any suggestion?
Thank you!

The application needs to write audio to stdout. Not sure how to do that with vlc.
I was able to stream from vlc to asterisk using mg123 version 1.13.4.
Configure VLC to stream using HTTP and put this in your musiconhold.conf:

[vlc] mode=custom application=/usr/bin/mpg123 -q -s -m -r 8000 --ignore-mime http://IP:PORT

The ignore-mime parameter is required as VLC does not set the mime type properly (VLC 1.1.12 on Mac OSX)

thank you thor!
But in that case, the quality wouldn’t be very high, right? In my case, I’d like to stream directly at a mp3 quality. Is it compulsory to set a 8000 kHz samplerate?
Thanx a lot!

Nearly all phone codecs are 8kHz. The PSTN is 8kHz, 8 bit, mu- or A-law. One or two phone codecs for local use are 16kHz. There is no way you will get MP3 quality over a phone system, in real time.

Many codecs are designed for speech use only, e.g. GSM, because they are based on a vocal tract model.

Is this a licensed use of the internet streams?

Thanks for such a fast response David,

Let’s see if I get it right: So even if I had a device (not an IPphone) which is able to decode mp3 files and do all the SIP stuff (Register, receive calls…), Asterisk doesn’t support it and can’t send that kind of traffic.

As for the license, it’s just me who’s using this for the moment so don’t worry. I will look that up in the future… :wink:

Thanks and sorry if i’m being too stupid… :blush:

Asterisk doesn’t have MP3 pass through support, because no VoIP phones support MP3, or 44kHz audio. You could write an MP3 format module for Asterisk, which would allow it to do so, but you would still have the problem of finding SIP or H.232 devices that supported MP3.

I am not sure if the Asterisk architecture can handle variable bit rate coding, and it might not like sample rates that are not divisible by 8000.

You can get better quality when using 16kHz codec. More details in this thread:
viewtopic.php?t=74366

You could potentially use siren14 @32 kHz or g719 @48kHz

the full list of supported codecs in 1.8 branch is in main/frame.c :

code.asterisk.org/code/browse/a … =true#to95

alright, thank you!!
this looks like i’ll have to get deeper so it’ll take some time…
By the way, can the streaming be made with UDP? I’ve tried but mpg123 doesn’t work properly…
Thanks again, bye!

After some little investigation…
Would it work if I changed res_musiconhold.c as explained in the link thor suggested (viewtopic.php?t=74366) for 48kHz samplerate? or is it just for 16kHz? And as for musiconhold.conf, would it be enough to add:

mode=custom
application=/usr/bin/mpg123 -q -s -m -r 48000 -b 512 -@ http://IP:PORT
format=g719

Sorry for being so tiring but i’m new to this… :confused:

Thank you!

the format= specification must match the output from the program specified in application=
mpg123 can only do slin and g711(ulaw/alaw) so you can not use it to produce a g719 audio stream.

Note that asterisk10 adds support for higher bitrate slin codecs up to 192kHz:

wiki.asterisk.org/wiki/display/ … io+Formats

It could be used to play higher bitrate music on hold after patching res_musiconhold.c as it still assumes
"8 samples per millisecond":

code.asterisk.org/code/browse/a … true#to703

Keep in mind using higher bitrates is pointless when your end devices do not support it.
What is that you planning on listening to those streams on ?

Thank you thor!
So, coming back to the first situation, does anybody know which format VLC outputs the audio captured from streaming? or just how to configure it?

At the moment I’m using asterisk 1.8.8.4, and of course, if my end devices (some specific modules) don’t support the codecs it makes no sense turning the bitrate up… :wink:

Thank you!

I posted a howto in the documentation forum:

viewtopic.php?t=81088

I get permission problems with that…
even if I chmod the vlc.sh file, it says permission denied at the asterisk CLI…