Shoutcast Streaming MOH for Trixbox 2.0 Instructions
I have written a document that outlines how to setup Shoutcast Streaming MOH for Trixbox 2.0. Please test and let me know what you think. I want to think many people here for coming up with bits and pieces.
If you have mpg123 installed, you can check which version you have my typing the below from the command line. If it is not installed it will not return anything.
mpg123 –v
If the player is not installed, or you have an older version download and install version 0.59r by typing the following in command prompt, one line at the time.
cd /usr/bin
wget http://www.mpg123.de/mpg123/mpg123-0.59r.tar.gz
tar –zxvf mpg123-0.59r.tar.gz
cd mpg123-0.59r
make linux
make install
ln -s /usr/local/bin/mpg123 /usr/bin/mpg123
Now you need to make a directory for the streaming music, do the following:
cd /var/lib/asterisk/mohmp3/
mkdir stream
Make a zero length dummy mp3 file inside of the stream directory, do:
cd stream
touch stream.mp3
Edit the musiconhold_additional.conf file and comment out the following lines:
;[default]
;mode=files
;directory=/var/lib/asterisk/mohmp3/
;random=yes
Next we will need to create a new conf file that will hold our settings so that Freepbx does not wipe them out:
cd /etc/asterisk
touch musiconhold_custom.conf
chown asterisk musiconhold_custom.conf
chmod 664 musiconhold_custom.conf
Once the file is created, you will copy and paste the following into musiconhond_custom.conf using Config Edit from Freepbx:
[default]
mode=custom
directory=/var/lib/asterisk/mohmp3/stream
[default]
mode=custom
directory=/var/lib/asterisk/mohmp3/stream
;24k SKY.FM 80's
;application=/usr/local/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://212.71.8.6:8766/
;24k SKY.FM Top 40's
application=/usr/local/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://212.23.5.99:8006/
;24k SKY.FM Soft Smooth Jazz
;application=/usr/local/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://38.101.216.30:8000/
;56k Hard Rockin 80's Hair Bands
;application=/usr/local/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://204.9.117.202:8112/
;24k SKY.FM Hit Country
;application=/usr/local/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://128.177.3.80:4064/
When pasting the above lines, make sure that the application is on one continuous line.
After completing this, just uncomment out which stream you want to use. Currently the stream that will work will be the Top 40’s. These are all 24k streams except for one, so they use very little bandwidth plus you don’t need anymore than that for a moh.
You can then add the following to extensions_trixbox.conf using Config Edit in Freepbx to test:
exten => 68742,1,Answer
exten => 68742,2,MusicOnHold
exten => 68742,3,Hangup
You will need to reload asterisk after this is complete:
amportal restart
After Asterisk restarts, pick up the phone and dial 68742 (MUSIC).
Enjoy!
works awesome! this is the first time i got streaming to work!
for those interested in "up to date" music, put thisi into musiconhold_custom.conf
;977 Hits
application=/usr/local/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://scfire-dll0l-2.stream.aol.com:80/stream/1074
This is great!
Now to find some local radio station streams...
Thanks!
Dave
for anyone living in NYC, does anyone know how to stream z100 (100.3 FM)? they have a streaming feature on their website but it plays through their website.
thanks
Looks like they are streaming via MMS:// - so you'll have to transcode it, not going to be easy to do on Asterisk. If you REALLY want to do this, you can use VideoLan (VLC), and cut and paste the MMS:\\ below into the stream, click on the wizard, and transcode and stream it youself to your asterisk box. Good luck, and I hope it works.
EDIT: Okay I'm not sure why the screenshots are not coming through, you'll have to click on them below. Sorry something messed up between preview and submit here.
http://i18.tinypic.com/2h7p2fm.jpg"
Here is the PHP code I extracted from z100.com:
mms://a1998.l1997243784.c19972.g.lm.akamaistream.net/D/1998/19972/v0001/reflector:43784&CPROG=SIMULCAST&MARKET=NEWYORK-NY&NG_FORMAT=chr&NG_ID=whtz100fm&OR_NEWSFORMAT=&RVN_TZ=-5&SERVER_NAME=www.z100.com&SITE_ID=1793&STATION_ID=WHTZ-FM&STATION_ID=WHTZ-FM""
mms://a158.l1997243785.c19972.g.lm.akamaistream.net/D/158/19972/v0001/reflector:43785&CPROG=SIMULCAST&MARKET=NEWYORK-NY&NG_FORMAT=chr&NG_ID=whtz100fm&OR_NEWSFORMAT=&RVN_TZ=-5&SERVER_NAME=www.z100.com&SITE_ID=1793&STATION_ID=WHTZ-FM&STATION_ID=WHTZ-FM"" target="_blank">" target="_blank">mms://a158.l1997243785.c19972.g.lm.akamaistream.net/D/158/19972/v0001/reflector:43785&CPROG=SIMULCAST&MARKET=NEWYORK-NY&NG_FORMAT=chr&NG_ID=whtz100fm&OR_NEWSFORMAT=&RVN_TZ=-5&SERVER_NAME=www.z100.com&SITE_ID=1793&STATION_ID=WHTZ-FM&STATION_ID=WHTZ-FM" />
http://mfile.akamai.com/19972/live/reflector:43784.asx?bkup=43785&CPROG=SIMULCAST&MARKET=NEWYORK-NY&NG_FORMAT=chr&NG_ID=whtz100fm&OR_NEWSFORMAT=&RVN_TZ=-5&SERVER_NAME=www.z1" target="_blank">http://mfile.akamai.com/19972/live/reflector:43784.asx?bkup=43785&CPROG=SIMULCAST&MARKET=NEWYORK-NY&NG_FORMAT=chr&NG_ID=whtz100fm&OR_NEWSFORMAT=&RVN_TZ=-5&SERVER_NAME=www.z1
sometimes the music stops playing out of nowhere for a few minutes. anyone know what to do in such a case?
thanks
Sounds like you are having problems buffering. Pick a different stream! :lol: Make sure to pick a low bitrate stream, they are less popular and consume much less bandwidth.
Dave
i tried that!
still same issue
i did realize that as long as i keep a phone listening to the music on hold, i would hear the streaming. i realized that when no phones are listening to mmusic on hold, nothing is streamed.
so is there a way that i can just tell asterisk to continuously stream the music? right now i have a domain controller so i put x-lite on it and thats how im keeping the music "alive"- but i dont want to do this.
thanks
I don't think there is a way to have it stream all the time. Music on Hold starts when you request it.
alright i see
so if i leave x-lite on 24/7, streaming the music, would i "kill" the network card of the asterisk server for continuous bandwidth processing?-i currently do not have failover so that's why im concerned.
thanks
Mine creates a buffer from the previous song, then it just starts into the new stream after a few seconds. Not a big deal for me, but I also don't want the bandwidth to stream all the time.
mine does that too but after the previous buffer the music would just cut off
i dont care about my bandwidth because i have 30Mpbs. so am i killing my card by continuously streaming?
For the stopped stream, I have noticed that it is stopping even when listening to it direct (click the mms link I posted above) - it does say on the z100 web site their streaming will go down a few times due to them upgrading.. maybe that is the problem.
im not using z100
but im trying to find a way to stream it
im using .977 Hits from shoutcast
Thanks for this post, I've at least got the music playing.. however, it's like blaring through the headset.. has anyone else experienced this?? I've stopped and started asterisk a few times.. same result.. any clue why, or how to tone down mpg123 so that it's not so loud??
[FIXED!]
Ok, I was using the latest version of mpg123. Reverting to an earlier version and restarting the system solved my volume problem.
Pretty exciting that this works! Thanks for the clear prcedure.. I am still having the blaring that 'goingup' mentioned. I am not so lucky I tried three versions of mpg123 from q thru pre-s and no change. I see a gain option in mpg123 but the man page says not to change it. Bottom line how do I adjust the volume to ear tolerance levels?
This really works. I am having good results except for the volume blaring. Is there anyway to attenuate the volume with this setup? I need to tone it down a little. It is so loud it startles some callers.
I had to reboot before I could paste the Streams in but still only hearing my default MOH!
Disregard, with all the patches I installed I tightened my firewall and dis-trusted Trixbox from internet access. My bad.
The guide is great, if I dial the extension I make for musiconhold it plays down the line. But this may be a dumb question, how do I configure this stream in FreePBX -> MusicOnHold. I thought it obvious saw it made a queue called stream with the stream.mp3 file inside. However when I select this as hold music I get dead air, if i switch back to the generic hold music that plays fine.
Also when I amportal restart I get this :
Junk at the beginning ed6c52f9
mpg123: Can't rewind stream by 607 bits!
The number of bits is always different & mostly lists 2 or 3 times. It will also re-occur every 10 minutes in the console. Its from the musiconhold_custom.conf as when I rm this file the problem goes away but then that doesnt really narrow it down :)
If I let this go after about 10 repeats of this I get "File is too big" stream down the console then my hold music extension becomes a dead line...
Stick with mp3 or wav files on the server. I messed around with mpg123 and some shoutcast radio stations, I ended up just using the included mp3 moh files. The music doesn't drop out and will always play, the same can't be said for streaming mp3.
I still use the streaming mp3 but just to play music over the phones to listen to, and even then it's not reliable.
You could setup a shoutcast server just to relay the music which would, itself, buffer the stream and, since the shoutcast would be on your trixbox, the stream would not need any buffering in between!
Its been a while since i fooled with shoutcast but I'll give it a go and, if it fixes the problem, i'll come back and post instructions on how to setup the config for both. Currently, I'm looking for a way to use multiple streams, which is going to be a hassle if I have to relay them all through individual shoutcasts's.
Right now, I have a radio station playing (and stopping) that I don't even know where is coming from. The musiconhold config files don't show the stream as they have hip-hop and gopsel streams listed; a rock station is playing on the phone!?!?! I'm still searching through config files :-)
Hi,
I have tried de instruction on my 2.4 server but it isnt working.
As far as I can see ther is no mpg123 player? tried installing but i'm getting an error?
Hopefulle somebody can help.
Same story here : (
Ok I searched around and I got it working!!
Install mpg123 like this:
1. wget ftp://rpmfind.net/linux/dag/fedora/2/en/i386/dag/RPMS/mpg123-0.61...
2. rpm -ivh mpg*.rpm
3. mpg123 -v ;(if you see some help imformaiton, it mean mpg123 installed)
This is my musiconhold_custom file:
[default]
mode=custom
directory=/var/lib/asterisk/mohmp3/stream
application=/usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://64.72.127.74:8002/
Replace http://64.72.127.74:8002/ with the proper stream link. Notice the difference- in tb2.2 it is application=/usr/LOCAL/bin/mpg123
there's no "local" directory in trixbox 2.4 that leads to mpg123
Enjoy!
Now, if anyone knows how to lower the volume- that would be great!
I'm pretty sure this is a stupid question but, is TB streaming ONLY when a call is placed on hold or whenever "mpg" is being invoked?
It's not running in the background at any time is it?
It only runs when the caller is placed on hold and it continues for about a minute or two afterwards
why the old rpm though? there are much newer version than that.
I guess that's the one I found at the time.
I'm not too knowledgable with Linux commands so this was the only successful source I got out of all the other websites I look at
I found the latest rpms....I used this and it's actually working now...holy crap!!
wget ftp://194.199.20.114/linux/redhat/9/en/os/i386/RedHat/RPMS/esound...
wget ftp://194.199.20.114/linux/dag/redhat/9/en/i386/dag/RPMS/mpg123-1...
rpm -ivh es*.rpm
rpm -ivh mpg*.rpm
If you are running this on 2.6 you can install esound via yum to get the latest version.
My only problem is that if the internet drops the music doesn't come back right away?
Correct
I also dont like that occasionally the music just stops working completely and will work again after 5 minutes of calls not placed on hold
I haven't had that problem running the latest version of mpg123 its just if the net drops it doesnt recover very fast.
Yes that too
But think about it, how often does the net actually drop on you?
I never had an unplanned internet outage in 6 years, starting from my home and moving on to my office
Is there a way to assign a different stream to each separate queue? or do they have to use the default stream?
Same here like Atilio, how can I assign different streams to different queues or extensions?
Also having issues with the volume... If someone has a way to adjust it, that'd be great. :)
I didn't like the idea of using a 3rd party streaming audio source, so I set up my own shoutcast server on the trixbox machine and pulling in the audio through that works like a champ. If I can't solve the volume problem any other way, I'll probably just do some processing on the source MP3s to cut it down.
Tried messing around with sox, and local and remote shoutcast streams, wrapper scripts for sox/mpg123.... got tired of it all and went back to using the line-in port on the sound card - I had stopped using it because it would just "go away" for no apparent reason, but I'd rather have occasional silence than my customers getting their eardrums blown out... :)
freepbx 2.5 now has a volume adjuster
Hello,
I am trying using the guidelines above to play a radio station while an extension is on ringing or on hold. I managed to setup the radio playback for many Internet radio stations but i cannot make it work with a specific radio station. The station that it does not work with mpg123 is http://stream.greekradios.gr:2046/ and from radio's web page i see that is using coding audio/aac (advanced audio coding) instead the audio/mpg.
So question, how to setup the musiconhold.conf to play that radio station?
(keep in mind that i tried to play the station using vlc, doing first of all installation of vlc on my trixbox and then replacing on the guidelines you have written above the line "application=/usr/bin/mpg123 ..." with "application=usr/bin/vlc -vvv http://stream.greekradios.gr:2046/")
Regards,
John
Excerpt from http://pbxinaflash.com/forum/showthread.php?t=2666&highlight=stre... ....
Here's my etc/asterisk/musiconhold.conf:
[80s]
mode=custom
application=/usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://scfire-mtc-aa04.stream.aol.com:80/stream/1040
[Hitz]
mode=custom
application=/usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://scfire-dtc-aa02.stream.aol.com:80/stream/1074
[Jazz]
mode=custom
application=/usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://scfire-ntc-aa10.stream.aol.com:80/stream/1074
[KickinCountry]
mode=custom
application=/usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://scfire-ntc-aa09.stream.aol.com:80/stream/1075
[MaxHits]
mode=custom
application=/usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://91.121.201.60:80
[SwissGroove]
mode=custom
application=/usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://82.197.167.134:80
[TheEagle-ClassicRock]
mode=custom
application=/usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://64.72.118.64:8030
[Top40-Christmas]
mode=custom
application=/usr/bin/mpg123 -q -s --mono -r 8000 -f 8192 -b 0 http://64.62.194.49:2792
[default]
mode=files
directory=/var/lib/asterisk/mohmp3/
random=yes
[none]
mode=files
directory=/dev/null
Then I modified my /etc/asterisk/extensions_custom.conf
In the [from-internal-custom] section I added:
exten => 68742,1,Answer
exten => 68742,2,Flite("After the beep press the number of the music channel you wish to listen to. Or 9 for a list of channels.")
exten => 68742,3,Read(MusicCode,beep,1)
exten => 68742,4,GoTo(QueueMusic,s,${MusicCode})
exten => 68742,5,Hangup
Then I scrolled to the bottom of the file and added a new section:
[QueueMusic]
exten => s,1,MusicOnHold(80s)
exten => s,2,MusicOnHold(Jazz)
exten => s,3,MusicOnHold(KickinCountry)
exten => s,4,MusicOnHold(Hitz)
exten => s,5,MusicOnHold(MaxHits)
exten => s,6,MusicOnHold(SwissGroove)
exten => s,7,MusicOnHold(TheEagle-ClassicRock)
exten => s,8,MusicOnHold(Top40-Christmas)
exten => s,9,Flite("Press 1 for eighties. 2 for Jazz. 3 for Kickin Country. 4 for Hitz. 5 for Max Hitz. 6 for Swiss Groove. 7 for The Eagle Clasic Rock. 8 for Top 40 Christmas. 9 to hear this list again.")
exten => s,10,goto(from-internal-custom,68742,2)
exten => s,11,Hangup
Then I saved all my files and did an "amportal restart" for the changes to take effect. Now you can dial MUSIC or 68742 and it will ask you which channel you wish to listen to and play that stream.
This is what we use. Supports unlimited channels, interruptable menus.
http://pbxinaflash.com/forum/showpost.php?p=16146&postcount=35
Hi, it's working but some times it goes down, I mean, some seconds after you are listening the moh, it goes down and there is just a big silence and then when I try it again it is not working just silence... after some minutes it comes back but again goes down and again and again...
I have mpg123 1.3.1, it came with the trixbox... I see in www.mpg123.org the last version is 1.6.2... I'm gonna try updating it...
Hi, I had some issues updating, I was doing:
cd /usr/bin
wget http://mpg123.orgis.org/download/mpg123-1.6.2.tar.gz
tar –zxvf mpg123-1.6.2.tar.gz
cd mpg123-1.6.2
make linux
make install
ln -s /usr/local/bin/mpg123 /usr/bin/mpg123
but when I do
"make linux"
I got a error message
"make: *** No rule to make target `linux'. Stop."
I double checked the folder and I don't know why it happens... but any way, looking another radio station I found it's illegal.. is not legal to put radio stations in commercial phone systems.. then I found royalty free music and now I don't need the radio station option... any way if some body knows the solution maybe for another people I thing it's welcome!!!
iv gotten this working but it is pulsing (on off on off)
the higher the bit rate the quicker it pulses, which suggests its a buffering issue but not sure to do to fix it.
any suggestions

Member Since:
2006-06-26