Ezstream on linux

From The RadioReference Wiki

Some notes on using ezstream under Linux to feed a live stream to


Newbies, please note: Ezstream, LAME, etc., have prerequisites of their own. If in doubt, unpack the archives you downloaded and read the README or INSTALL files. You'll also need to make sure you have a compiler installed. Easy way to do that under CentOS: yum groupinstall 'Development Tools'

I initially used CentOS 4.8 (minimal install), LAME 3.98.4, Sox 12.17.5, Ezstream 0.5.6. I ended up moving to CentOS 5.6, installing Sox from yum, and compiled LAME and Ezstream manually.

  1. Ezstream needs to be fed an encoded stream, which can be accomplished with LAME.
  2. I used sox to take in a feed from /dev/dsp. There might be better ways to do this, but this one worked, and doesn't seem to waste significant cycles (<=1% CPU on a 800MHz C3 CPU).
  3. You might need to use something like alsamixer (yum users, it's part of alsa-utils) to make sure the hardware mixer is set to the appropriate input.
  4. I use screen to run the encoding operation in the background, yet give me the ability to resume that terminal and check out the (albeit minimal) stats from ezstream.
  5. Below are the config files and hastily written scripts I use to get the show going and keep it going. Edit the ezstream.xml file to include your mount point and password.


    <svrinfoname>INSERT OFFICIAL STREAM NAME HERE</svrinfoname>
    <svrinfodescription>SHORT DESCRIPTION</svrinfodescription>


/usr/bin/sox -t ossdsp -w -s -r 44100 -c 2 /dev/dsp -t raw - | \
/usr/local/bin/lame -r -a -m mono -b 16 --cbr --resample 22.050 --lowpass 4 - - 2> /tmp/startstream.status | \
/usr/local/bin/ezstream -qvc /etc/ezstream.xml


screen -d -m /usr/local/bin/startstream
echo "Screenstream started startstream at `date`" > /tmp/status.screenstream



if ([ "$(/sbin/pidof ezstream)" = "" ]) || \
([ "$(/sbin/pidof lame)" = "" ]) || \
([ "$(/sbin/pidof sox)" = "" ]); then
        killall ezstream > /dev/null 2>&1
        killall lame > /dev/null 2>&1
        killall sox > /dev/null 2>&1
        /usr/local/bin/screenstream > /dev/null 2>&1
        mail -s "[ezstream] Something fishy, restarting..." \
        ALERT@YOUREMAIL.COM < /dev/null > /dev/null
        echo "Checked ezstream at `date`" > /tmp/status.checkstream

Use "crontab -e" to add the checkstream script to your crontab. I don't start anything in rc.local or another startup location, but with cron running checkstream once a minute, the script will run within a minute of crond starting up at boot.

*/1 * * * * /usr/local/bin/checkstream

Notes on using EZStream with Ubuntu 20.04 server (no GUI):

This *mostly* works, with a few tweaks. First, you can "apt install ezstream lame sox" and get everything you need. Versions: Ezstream 1.0.1, LAME 3.100-3, SOX 14.4.2. I then created folder /etc/scanner for my configuration and status files.

EZStream v1 uses a different XML configuration format than v0.5.6 above, so to fix this:

~/> cd /etc/scanner
/etc/scanner> mv ezstream.xml ezstream.xml0
/etc/scanner> ezstream-cfgmigrate -0 ezstream.xml0 > ezstream.xml

/usr/local/bin/startstream - updated:

/usr/bin/sox -t alsa plughw:0,0 -r 44100 -c 2 -t raw - | \
/usr/bin/lame -r -a -m mono -b 16 --cbr --resample 22.050 --lowpass 5 - - 2> /etc/scanner/startstream.status | \
/usr/bin/ezstream -qvc /etc/scanner/ezstream.xml

(-w and -s aren't valid options for sox on ubuntu 20.04, and ALSA uses different devices - check aplay -l for your device. LAME - I changed the lowpass to 5 to filter above 5k instead of 4k. LAME and EZStream live in /usr/bin on Ubuntu - paths need to be changed.)

Screenstream is working as-is from above, while checkstream needs the path /sbin/pidof changed to /bin/pidof. Add your email as well, and I altered the check line to save it's status in /etc/scanner/status.checkstream instead of /tmp/status.checkstream.

Be sure to make startstream, screenstream and checkstream executable with "chmod +x startstream screenstream checkstream". Once everything started working I changed the crontab entry to check every 15 minutes. You could also change it to run at boot - your choice. That would look something like this:

@reboot sleep 60 && /usr/local/bin/startstream
*/15 * * * * /usr/local/bin/checkstream wait 1 minute after reboot and start the stream, then to check every 15 minutes afterwards.

Note that this is NOT a "robust streaming solution" in any sense - even brief network interruptions aren't handled well. If you are using this and hoping for reliability you may need to restart the stream regularly via another crontab entry. I seem to average 2-3 disconnects per week.