Skip to content

icecast streaming with ezstream

MegaXLR edited this page Oct 8, 2016 · 3 revisions

For all you Internet radio fans, here's a fun one: broadcasting the album.

First, you'll need a server running icecast2. I won't go into the details of configuring it, as there is such nice documentation online.

Let's assume for the time being:

  • you're running it on port 8000 of 192.168.1.100 on your local network
  • you have your router properly configured to allow external traffic in to that port on that machine (e.g. with port forwarding)
  • you have some pointer on the web to it, say a dynamic dns like freedns or a page of the netcat website like netcat.co/radio
  • the name of your stream will be netcat
  • you are pointing to 192.168.1.100/netcat
  • you have the netcat kernel module compiled and inserted

Given that you can handle the server setup and netcat install, you need to install ezstream which, at least on Debian-based OSes is:

$ sudo apt-get update && sudo apt-get -y install ezstream

Next, you'll need a config file, let's say ~/netcat.xml:

<ezstream>
    <url>http://192.168.1.110:8000/netcat</url>
    <sourcepassword>yourpassword</sourcepassword>
    <format>VORBIS</format>
    <filename>stdin</filename>
    <stream_once>1</stream_once> <!-- must do for stdin -->
<!-- the rest are optional -->
    <svrinfoname>netcat</svrinfoname>
    <svrinfourl>http://netcat.co</svrinfourl>
    <svrinfogenre>geek</svrinfogenre>
    <svrinfodescription>nevermind the CD/DVDs, here's kernel modules!</svrinfodescription>
    <!-- the following taken from mplayer. not sure if it's right -->
    <svrinfobitrate>104.8</svrinfobitrate>
    <svrinfochannels>2</svrinfochannels>
    <svrinfosamplerate>22050</svrinfosamplerate>
    <svrinfopublic>1</svrinfopublic>
</ezstream>

Next, broadcast:

$ ezstream -c ~/netcat.xml < /dev/netcat

Now the whole world can hear you, e.g.:

$ mplayer -cache 2000 -playlist http://netcat.co/radio/netcat.m3u

NOTE: This isn't complete if you like to mix up the ogg and the mp3 (officially not supported by xiph, but listeners often don't do well with ogg, especially if running Windoze). To deal with that:

You'll need to add some software:

$ sudo apt-get update && sudo apt-get -y install madplay lame

Add this to your to your ~/netcat.xml:

<reencode>
    <enable>1</enable>
    <encdec>
        <format>MP3</format>
        <match>.mp3</match>
        <decode>madplay -b 16 -R 44100 -S -o raw:- "@T@"</decode>
        <encode>lame --preset cbr 128 -r -s 44.1 --bitwidth 16 - -</encode>
    </encdec>
    <encdec>
        <format>VORBIS</format>
        <match>.ogg</match>
        <decode>oggdec -R -b 16 -e 0 -s 1 -o - "@T@"</decode>
        <encode>oggenc -r -B 16 -C 2 -R 44100 --raw-endianness 0 -q 1.5 -t "@M@" -</encode>
    </encdec>
</reencode>
Clone this wiki locally