📜 ⬆️ ⬇️

Local Internet radio station using icecast + ices

I rummaged through my old recordings and decided to share with you instructions on how to quickly and easily raise a normal server for broadcasting your radio online (mp3 files) and for retransmitting external radio stations.
Who cares please under the cat.

I used a server running FreeBSD. We believe that we have a fresh tree of ports. Let's start the installation of icecast :

#cd /usr/ports/audio/icecast2 #make install clean 


Next, create a user for radio Internet radio and a group of radio and create a directory where all this will lie.
')
 #mkdir /var/icecast #pw group add radio # adduser Username:radio Full name: Radio user Uid (Leave empty for default): Login group [radio]: Login group is radio. Invite jru into other groups? []: Login class [default]: Shell (sh csh tcsh zsh nologin) [sh]: nologin Home directory [/home/radio]: Home directory permissions (Leave empty for default): Use password-based authentication? [yes]: Use an empty password? (yes/no) [no]: Use a random password? (yes/no) [no]: Enter password: Enter password again: Lock out the account after creation? [no]: Username : radio Password : **** Full Name : Radio user Uid : 1001 Class : Groups : radio Home : /home/radio Locked : no OK? (yes/no): yes adduser: INFO: Successfully added (radio) to the user database. Add another user? (yes/no): no Goodbye! 


After we copy all the files for the web interface:

cp /usr/local/share/icecast /var/icecast

Create a directory for the log:

mkdir /var/icecast/log

Create files for logs:

 cd /var/icecast/log touch access.log touch error.log 


Change the rights:

chown -R radio:radio /var/icecast

Next we go to see the config file:

 cd /usr/local/etc cp icecast.xml.sample icecast.xml 


Configure the file. I will describe only the important parameters
Authentication. The first is the connection password for broadcasting through your icecast server. The second is the login password for the web interface at icecast_ip : 8000

 <authentication> <!-- Sources log in with username 'source' --> <source-password>123</source-password> <!-- Relays log in username 'relay' --> <relay-password>123</relay-password> <!-- Admin logs in with the username given below --> <admin-user>admin</admin-user> <admin-password>12345678</admin-password> </authentication> 


Next, select the server IP and the port as well as the monitoring point of the stream with ices, but this later:

 <listen-socket> <port>8000</port> <bind-address>192.168.1.7</bind-address>. <shoutcast-mount>/ices</shoutcast-mount>. </listen-socket> 


I am also going to re-broadcast the radio stations of Ukraine Kissfm (+ Kissfm in ESS), our radio, luxury FM, and hit FM:

 <relay> <server>91.201.37.42</server> <port>8000</port> <mount>/kiss</mount> <local-mount>/kiss</local-mount> <on-demand>1</on-demand> <relay-shoutcast-metadata>0</relay-shoutcast-metadata> </relay> <relay> <server>91.201.37.42</server> <port>8000</port> <mount>/kissACC</mount> <local-mount>/kissACC</local-mount> <on-demand>1</on-demand> <relay-shoutcast-metadata>0</relay-shoutcast-metadata> </relay> .... <relay>........ <server>195.95.206.12</server> <port>8000</port> <mount>/HitFM</mount> <local-mount>/hitfm</local-mount> <on-demand>1</on-demand> <relay-shoutcast-metadata>0</relay-shoutcast-metadata> </relay> <relay> <server>77.120.104.251</server> <port>8000</port> <mount>/</mount> <local-mount>/luxfm</local-mount> <on-demand>1</on-demand> <relay-shoutcast-metadata>0</relay-shoutcast-metadata> </relay> <relay> <server>212.26.129.222</server> <port>8001</port> <mount>/</mount> <local-mount>/nashe</local-mount> <on-demand>1</on-demand> <relay-shoutcast-metadata>0</relay-shoutcast-metadata> </relay> 


Next, we change the parameters for finding directories in the section
  <basedir>/var/icecast</basedir> <logdir>/log</logdir> <webroot>/web</webroot> <adminroot>/admin</adminroot> <pidfile>/var/run/icecast.pid</pidfile> 


Last but not least. Icecast does not work as root here and we change the permissions for the previously created user and group

 <security> <chroot>1</chroot> <changeowner> <user>radio</user> <group>radio</group> </changeowner> </security> 


Next, we try to take off, we see that he swears:

#/usr/local/bin/icecast -c /usr/local/etc/icecast.xml

If everything is well interrupted via Ctrl + c and go further:

I used ies0 because I needed to play mp3 and for ogg I had to use ices2, it seemed to play mp3 too, but I didn’t check:

 #cd /usr/ports/audio/ices #make install clean 


Here that would not suffer with the rights we make it easier (you can create the directory where you want):

mkdir /tmp/radio

We add mp3 files here and create a playlist:

find /tmp/radio -name *.mp3 > /tmp/radio/playlist.txt

You should get a playlist.txt file with the following contents:

 /tmp/radio/Far East Movement ft. The Cataracs & Dev - Like A G6.mp3 /tmp/radio/The_Prodigy_-_Voodoo_People_(Pendulum_Remix).mp3 /tmp/radio/1.mp3 


Change the rights #chmod -R 777 /tmp/radio and go to break the file ices.conf

 cd /usr/local/etc/ cp ices.conf.dist ices.conf 


Editing. I got this look (comments from Aftora):

 <?xml version="1.0"?> <ices:Configuration xmlns:ices="http://www.icecast.org/projects/ices"> <Playlist> <!--     --> <File>/tmp/radio/playlist.txt</File> <!--       1. . --> <Randomize>0</Randomize> <!--   ,    --> <Type>builtin</Type> <!--      Perl  pyton,     --> <Module>ices0</Module> <!--              .    .. 0 <Crossfade>5</Crossfade> --> </Playlist> <Execution> <!--    1 --> <Background>1</Background> <!--        1 --> <Verbose>1</Verbose> <!--       pid  --> <BaseDirectory>/tmp</BaseDirectory> </Execution> <Stream> <Server> <!-- ip icecast     --> <Hostname>192.168.1.7</Hostname> <!--  --> <Port>8000</Port> <!--       icecast server --> <Password>123</Password> <!--   Shoutcast  "icy", icecast 1.x  "xaudiocast",   icecast 2.x  "http". --> <Protocol>http</Protocol> </Server> <!--       --> <Mountpoint>/ices</Mountpoint> <!-- The name of the dumpfile on the server for your stream. DO NOT set this unless you know what you're doing.       <Dumpfile>ices.dump</Dumpfile> --> <!--   ,     --> <Name>mp3 stream</Name> <!-- ,     --> <Genre>it</Genre> <!--     --> <Description>Local streaming</Description> <!--    --> <URL>http://gate.mydomain.com/</URL> <!--0         1   --> <Public>0</Public> <!-- ,  --> <Bitrate>128</Bitrate> <!--   1  ices        liblame     --> <Reencode>0</Reencode> <!-- Number of channels to reencode to, 1 for mono or 2 for stereo --> <!-- Sampe rate to reencode to in Hz. Leave out for LAME's best choice <Samplerate>44100</Samplerate> --> <Channels>2</Channels> </Stream> </ices:Configuration> 


Next, add the following lines to /etc/rc.conf:

 icecast_enable="YES" icecast_flags="-c /usr/local/etc/icecast.xml" ices0_enable="YES" ices0_flags="/usr/local/etc/ices.conf" 


And try to take off:

 cd /usr/local/etc/rc.d #./icecast2 start #./ices0 start 


Open the link in the browser:
192.168.1.7 : 8000 / status.xsl

We download m3u of the necessary stream and forward.
Internet radio is set "on demand", so the first connection is slow. Who does not mind the traffic inet - change the value
<on-demand> 1 </ on-demand> on <on-demand> 0 </ on-demand> .

Just ices how the entire playlist loses is turned off. How to make a circle have not found yet. But, if you run ices through random, then its games never end:).
In the file ices.conf we change the parameter 0 to 1 and that's it.

Source: https://habr.com/ru/post/267351/


All Articles