Icecast
Icecast is a modular free media audio software, written in C++.
Icecast itself is unable to manage audio formats and requires addons called "sources
" to do.
in this guide, we use ices as our source.
Install
$ doas pkg_add ices-0.4p12 icecast
edit /var/icecast/icecast.xml
<icecast> <location>Earth</location> <admin>username</admin> <limits> <clients>100</clients> <sources>2</sources> <queue-size>524288</queue-size> <client-timeout>30</client-timeout> <header-timeout>15</header-timeout> <source-timeout>10</source-timeout> <burst-on-connect>1</burst-on-connect> <burst-size>65535</burst-size> </limits>
replace username and Earth with your values.
<authentication> <source-password>hackme</source-password> <admin-user>username</admin-user> <admin-password>hackmemore</admin-password> </authentication> <shoutcast-mount>/shoutcast</shoutcast-mount>
replace source-passowrd
and admin-password
with a secure passoword and chanage username to your prefered value.
<hostname>example.com</hostname> <listen-socket> <port>8000</port> <bind-address>0.0.0.0</bind-address> </listen-socket> <listen-socket> <port>8080</port> </listen-socket> <listen-socket> <port>8443</port> <ssl>1</ssl> </listen-socket>
replace example.com
with your domain.
note that icecast can only listen to IPv4 or IPv6 (and not both)
<mount type="normal"> <mount-name>/radio</mount-name> <public>0</public> </mount> <fileserve>1</fileserve>
each stream on icecast is called a mount, we will connect to mounts using our sources
<paths> <basedir>/var/icecast</basedir> <logdir>/log</logdir> <webroot>/web</webroot> <adminroot>/admin</adminroot> <pidfile>/var/run/icecast.pid</pidfile> <alias source="/" destination="/status.xsl"/> <!-- <ssl-certificate>/var/icecast/etc/icecast.pem</ssl-certificate> --> </paths>
here we configure paths, and ssl for port 8443. note that ssl certificate should have both private and public cert on same file. you can do that using
# cat /path/to/public/cert.pem /path/to/private/key.key > /var/icecast/etc/icecast.pem
and that will create it on /var/icecast/etc/icecast.pem
<logging> <accesslog>access.log</accesslog> <errorlog>error.log</errorlog> <!-- <playlistlog>playlist.log</playlistlog> --> <loglevel>3</loglevel> <!-- 4 Debug, 3 Info, 2 Warn, 1 Error --> <logsize>10000</logsize> <!-- Max size of a logfile --> </logging> <security> <chroot>1</chroot> <changeowner> <user>_icecast</user> <group>_icecast</group> </changeowner> </security> </icecast>
now, run and enable icecast
$ doas rcctl enable icecast $ doas rcctl start icecast
Ices
now we configure our source. currently there are two versions of Ices on OpenBSD repos, one is 0.4 and another one is 2.0 version 2.0 only supports ogg files and version 0.4 only supports mp3 files, in this guide, we will use version 0.4 take a backup of /etc/ices.conf
$ doas cp /etc/ices.conf /etc/ices.conf.bk
open /etc/ices.conf
<?xml version="1.0"?> <ices:Configuration xmlns:ices="http://www.icecast.org/projects/ices"> <Playlist> <File>/etc/radio.playlist</File> <Randomize>1</Randomize> <Type>builtin</Type> <Module>ices</Module> <Crossfade>4</Crossfade> </Playlist> <Execution> <Background>0</Background> <Verbose>0</Verbose> <BaseDirectory>/tmp/</BaseDirectory> </Execution> <Stream> <Server> <Hostname>localhost</Hostname> <Port>8000</Port> <Password>hackme/Password> <Protocol>http</Protocol> </Server> <Mountpoint>/radio</Mountpoint> <Name>My radio</Name> <Genre>Music</Genre> <Description>This is my radio</Description> <Bitrate>128</Bitrate> <Channels>2</Channels> </Stream> </ices:Configuration>
add your songs on /etc/radio.plist in following format
/path/to/mp3/file.mp3 /path/to/another/mp3 file.mp3
note that they can include spaces as well. afterwards, run ices
$ doas ices -c /etc/ices.conf
then you can point your media player or browser to http://example.com:8000/radio and enjoy.