Icecast and Ezstream Configuration

Plugging a 64 GB USB stick with directories full of MP3 / OGG files into an always-on Raspberry Pi running Pi-Hole, one can use Icecast to stream them for clients on the LAN, so as to avoid over-the-Intertubes streaming issues.

The only changes in the /etc/icecast2/icecast.xml file cover passwords, the number of source streams, and the hostname. It’s that simple, really.

Given a directory of files, generate a file-per-line playlist:

find /mnt/music/goodmusic/ -name \*mp3 | sort > /mnt/music/goodmusic/playlist.m3u

Then set up a corresponding Ezstream XML file, perhaps imaginatively named goodmusic.xml:

<ezstream>
    <url>http://localhost:8000/goodmusic</url>
    <sourcepassword>make-up-your-own</sourcepassword>
    <format>MP3</format>
    <filename>/mnt/music/goodmusic/playlist.m3u</filename>
    <shuffle>1</shuffle>
    <stream_once>0</stream_once>
    <svrinfoname>Good Music</svrinfoname>
    <svrinfourl>pihole.local</svrinfourl>
    <svrinfogenre>Good Music Streaming 24x7</svrinfogenre>
    <svrinfodescription>Techno Dub</svrinfodescription>
    <svrinfobitrate>128</svrinfobitrate>
    <svrinfochannels>2</svrinfochannels>
    <svrinfosamplerate>44100</svrinfosamplerate>
    <svrinfopublic>1</svrinfopublic>
</ezstream>

Fire off the source stream in /etc/rc.local:

ezstream -c /home/pi/Icecast/goodmusic.xml &

The ampersand tells Bash to fire-and-forget the process, so it runs all the time. One could, I suppose, put it in crontab to start after each boot or puzzle out the corresponding systemd incantation, but …

Add the station to your streaming media player:

         'KEY_KP5'   : ['Good Music',False,['mplayer','-playlist','http://192.168.1.2:8000/goodmusic.m3u']],

And then It Just Works™.