Clear Across Kansas

Broadcastify Your Allstar Node

Streaming Your Allstar Node to Broadcastify

Prerequisites:

  • A working Allstar node running the latest HamVoIP release on a Raspberry Pi 2 or 3.
  • You have applied and have been granted a feed at Broadcastify.com.

Note: This method is only for streaming your node’s audio (transmit and receive) to Broadcastify. This is NOT for using the Pi to broadcast another audio source.

Before beginning be sure to backup your Allstar installation (or clone the entire SD card) so you can easily restore your node if you screw it up.

Software Requirements

You will need the following packages installed to proceed:

  • libshout
  • libxml2
  • taglib
  • lame ( should already be installed, but do it again anyway)
  • pkg-config

At the linux shell prompt type (one at a time):
pacman -Sy libshout
pacman -Sy libxml2
pacman -Sy taglib
pacman -Sy lame
pacman -Sy pkg-config

Once these packages are installed you will need to download the ‘ezstream’ package.

wget http://downloads.xiph.org/releases/ezstream/ezstream-0.6.0.tar.gz
then:
tar xvzf ezstream-0.6.0.tar.gz
Then change to the directory created and follow the install instructions.

cd /root/ezstream-0.6.0
./configure
make
make install

Software Setup

Create (preferably using WinSCP) the file /etc/ezstream.xml and copy and paste the following text:

<ezstream>
<url>http://audio#.broadcastify.com:80/#######</url>
<sourcepassword>######</sourcepassword>
<format>MP3</format>
<filename>stdin</filename>
<svrinfoname>#########</svrinfoname>
<svrinfourl>http://www.radioreference.com/</svrinfourl>
<svrinfogenre>Amateur Radio</svrinfogenre>
<svrinfodescription>#############</svrinfodescription>
<svrinfobitrate>16</svrinfobitrate>
<svrinfochannels>1</svrinfochannels>
<svrinfosamplerate>22050</svrinfosamplerate>
<svrinfopublic>1</svrinfopublic>
</ezstream>

Then edit the ####### entries above with your audio server URL, mountpoint, password, feed name and description as defined by the Technicals tab in your Broadcastify account. Make sure there is a line feed after the </ezstream> at the end.

Next, edit your /etc/asterisk/rpt.conf file and add the following line within the node stanza of the node you wish to broadcast. Note: This must be all on a single line:

outstreamcmd=/bin/sh,-c,/usr/bin/lame --preset cbr 16 -r -m m -s 8 - - 2> /tmp/stream.status | /usr/local/bin/ezstream -qvc /etc/ezstream.xml

Restart Asterisk and the feed should go live. At the shell prompt you can run ps ax to check the running processes.

Sometimes the Ezstream process dies and causes the CPU usage to skyrocket. To restart Ezstream do kill -9 `pidof ezstream`

Here is the script which looks at ezstream cpu time and kills the process as a background job –
# !/bin/bash
# Check CPU usage of ezstream - normally should be 0
# If it fails kill the process
#
# WA3DSP - 10/2015
ezstreampid=`pidof ezstream`
if [ -z "$ezstreampid" ]
then
echo "EZstream not running"
exit
fi
#ezstreamcpu=`ps -p $ezstreampid -o %cpu | sed -n '2p'`
ezstreamcpu=`ps -p $ezstreampid -o time= | awk -F: '{ print ($1 * 3600) + ($2 * 60) + $3 }'`
ezstreamstat=`echo "60>$ezstreamcpu" | bc`
if [ "$ezstreamstat" -eq "1" ]
then
echo "Ezstream OK"
else
echo "Ezstream fail"
kill -9 $ezstreampid
echo "`date` - Ezstream restarted" >> /tmp/ezstream.status
fi
# End of script

Because ezstream is tied into Allstar and running as a child program to it through lame you need to shut things down in a proper way when you restart Asterisk. What you are seeing is exactly what happens when you don’t shut things down properly when running ezstream.  I run ezstream here on a separate Pi by itself for that reason. That is a little overkill but I run heavily used hubs here and I don’t want ezstream interfering with their operation. Running it on a separate server also allows you to connect it very easily to whichever audio you want to broadcast. Here is a script – you can call it  asterisk-restart.sh to restart asterisk. So instead of doing an Asterisk restart – astres.sh – you would run this script to restart Asterisk.
#!/bin/bash
/usr/local/sbin/astdn.sh
sleep 3
killall -9 lame
killall -9 ezstream
sleep 3
/usr/local/sbin/astup.sh

The last line restarts Asterisk and that in turn reloads ezstream. If you are running ezstream and you do updates I would create another script that omits the last line. In other words it stops Asterisk then before you do the update and when asterisk restarts it will not cause an error. If it doesn’t restart after the update just do a reboot.
 I will be adding this note to the howto on the hamvoip.org web page as well as the pacman package install info after you check it out.
Original writeup by WA3DSP, updated by Justin Reed, NV8Q on 2/24/2017.

Recent Posts