Using VLC to stream MoH

Here is a quick guide on how to use VLC to stream music on hold. The typical tool used for streaming - mpg123 - allows only mp3 streams over http. Using VLC allows streaming a larger variety of streams including streaming audio from udp or video streams.

  1. Create an executable script vlc.sh somewhere and put the following:

[code]#!/bin/sh

change to yes enable debugging output

DEBUG=no

VLC=/usr/bin/vlc

if [ “$DEBUG” = “yes” ] ; then
VLC="$VLC -vvv --file-logging --logfile /tmp/vlc.log"
else
exec 2>/dev/null
fi

exec $VLC
-I dummy --aout file --audiofile-format s16 --audiofile-file -
–audiofile-channels 1 --no-audiofile-wav --aout-rate=8000
–no-disable-screensaver --no-inhibit --no-media-library
–no-interact --no-stats --no-color --no-video “$1”
[/code]

  1. Put the following in musiconhold.conf:

[vlc] mode=custom application=/path/to/vlc.sh stream_to_play format=slin

Hi thor,
where it says “stream_to_play”, “udp://@:1234” would be correct?
I get connection refused messages at the stream server…

thanks!

I have been looking for this solution for months and months.
Maybe good to mention: if you are trying to run vlc as root you will encounter problems. However there are workarounds.

I found the volume much higher than my mpg123 streams. You can add --volume to the arguments --volume 80 worked good with the mms stream I was testing.

Audio format s16 works for me, but does anyone know if there are other options that would use less bandwidth/cpu? Or does it not make a difference?

Hi,

I am trying this on Asterisk 1.8 and it does not work. I have:

#!/bin/sh

change to yes enable debugging output

DEBUG=yes

VLC=/usr/bin/vlc

if [ “$DEBUG” = “yes” ] ; then
VLC="$VLC -vvv --file-logging --logfile /tmp/vlc.log"
else
exec 2>/dev/null
fi

and:

[a]
mode=custom
application=/opt/dovid/radio/vlc.sh 'mms://108.58.12.250/radio_hidabroot_online’
format=slin

Any reason it would not be working and how to debug? Also there is nothing going in to the log.

This is what i have on my musiconhold.conf file and it works like a charm.


musiconhold.conf

[radio]
mode=custom
;application=/usr/bin/mpg123 -q -r 8000 -f 8192 -s --mono radio2.domint.net:8022
;application=/usr/bin/mpg123 -q -r 8000 -f 8192 -s --mono radio3.domint.net:8062
application=/usr/bin/mpg123 -q -r 8000 -f 8192 -s --mono radio.domint.net:8096


extensions.conf

[radio]
exten=>1701,1,Answer
same=>n,NoCDR()
exten=>1701,n,Set(CHANNEL(MUSICCLASS)=radio)
exten=>1701,n,MusicOnHold()
exten=>1701,n,Hangup

Some times for any reason there is no media and is necessary to restart asterisk for it work

core restart now