Icecast2 (streaming server) en Ices0 (source client, deze geeft een stram aan Icecast die het vervolgens streamed) heb je nodig om mp3’s te streamen.Er is ook een Ices2, die is wat nieuwer met meer toeters en bellen maar kan niet omgaan met mp3. Meer weten: https:/icecast.org/ices
Zorg eerst dat je ices0 (staat hier: Ices0) en ices2 (staat hier: Ices2) aan de praat hebt voordat je doorgaat.
Icecast2
Update /etc/icecast2/icecast.xml. We gaan als voorbeeld een mountpunt maken “betonuur”.
Een mount punt defineer je als volgt in icecast.xml
<mount> <mount-name>/betonuur</mount-name> <max-listeners>4</max-listeners> </mount>
Zorgervoor dat de mount-name gelijk is aan het Mountpoint zoals je die bij de xml van de ices instantie hebt/gaat gedefineerd/definieren!!!
Hier een voorbeeld van een icecast.xml bestand:
<icecast> <!-- location and admin are two arbitrary strings that are e.g. visible on the server info page of the icecast web interface (server_version.xsl). --> <location>Almere</location> <admin>arjan.ten.hoopen@gmail.com</admin> <!-- IMPORTANT! Especially for inexperienced users: Start out by ONLY changing all passwords and restarting Icecast. For detailed setup instructions please refer to the documentation. It's also available here: http://icecast.org/docs/ --> <limits> <clients>10</clients> <sources>2</sources> <queue-size>524288</queue-size> <client-timeout>30</client-timeout> <header-timeout>15</header-timeout> <source-timeout>10</source-timeout> <!-- If enabled, this will provide a burst of data when a client first connects, thereby significantly reducing the startup time for listeners that do substantial buffering. However, it also significantly increases latency between the source client and listening client. For low-latency setups, you might want to disable this. --> <burst-on-connect>1</burst-on-connect> <!-- same as burst-on-connect, but this allows for being more specific on how much to burst. Most people won't need to change from the default 64k. Applies to all mountpoints --> <burst-size>65535</burst-size> </limits> <authentication> <!-- Sources log in with username 'source' --> <source-password>hackme</source-password> <!-- Relays log in with username 'relay' --> <relay-password>hackme</relay-password> <!-- Admin logs in with the username given below --> <admin-user>admin</admin-user> <admin-password>hackme</admin-password> </authentication> <!-- set the mountpoint for a shoutcast source to use, the default if not specified is /stream but you can change it here if an alternative is wanted or an extension is required <shoutcast-mount>/live.nsv</shoutcast-mount> --> <!-- Uncomment this if you want directory listings --> <!-- <directory> <yp-url-timeout>15</yp-url-timeout> <yp-url>http://dir.xiph.org/cgi-bin/yp-cgi</yp-url> </directory> --> <!-- This is the hostname other people will use to connect to your server. It affects mainly the urls generated by Icecast for playlists and yp listings. You MUST configure it properly for YP listings to work! --> <hostname>volumio.thuis.net</hostname> <!-- You may have multiple <listen-socket> elements --> <listen-socket> <port>8000</port> <!-- <bind-address>127.0.0.1</bind-address> --> <!-- <shoutcast-mount>/stream</shoutcast-mount> --> </listen-socket> <!-- <listen-socket> <port>8080</port> </listen-socket> --> <!-- <listen-socket> <port>8443</port> <ssl>1</ssl> </listen-socket> --> <!-- Global header settings Headers defined here will be returned for every HTTP request to Icecast. The ACAO header makes Icecast public content/API by default This will make streams easier embeddable (some HTML5 functionality needs it). Also it allows direct access to e.g. /status-json.xsl from other sites. If you don't want this, comment out the following line or read up on CORS. --> <http-headers> <header name="Access-Control-Allow-Origin" value="*" /> </http-headers> <!-- Relaying You don't need this if you only have one server. Please refer to the documentation for a detailed explanation. --> <!--<master-server>127.0.0.1</master-server>--> <!--<master-server-port>8001</master-server-port>--> <!--<master-update-interval>120</master-update-interval>--> <!--<master-password>hackme</master-password>--> <!-- setting this makes all relays on-demand unless overridden, this is useful for master relays which do not have <relay> definitions here. The default is 0 --> <!--<relays-on-demand>1</relays-on-demand>--> <!-- <relay> <server>127.0.0.1</server> <port>8080</port> <mount>/example.ogg</mount> <local-mount>/different.ogg</local-mount> <on-demand>0</on-demand> <relay-shoutcast-metadata>0</relay-shoutcast-metadata> </relay> --> <!-- Mountpoints Only define <mount> sections if you want to use advanced options, like alternative usernames or passwords --> <!-- Default settings for all mounts that don't have a specific <mount type="normal">. --> <!-- <mount type="default"> <public>0</public> <intro>/server-wide-intro.ogg</intro> <max-listener-duration>3600</max-listener-duration> <authentication type="url"> <option name="mount_add" value="http://auth.example.org/stream_start.php"/> </authentication> <http-headers> <header name="foo" value="bar" /> </http-headers> </mount> --> <!-- Normal mounts --> <!-- <mount type="normal"> <mount-name>/example-complex.ogg</mount-name> <username>othersource</username> <password>hackmemore</password> <max-listeners>1</max-listeners> <dump-file>/tmp/dump-example1.ogg</dump-file> <burst-size>65536</burst-size> <fallback-mount>/example2.ogg</fallback-mount> <fallback-override>1</fallback-override> <fallback-when-full>1</fallback-when-full> <intro>/example_intro.ogg</intro> <hidden>1</hidden> <public>1</public> <authentication type="htpasswd"> <option name="filename" value="myauth"/> <option name="allow_duplicate_users" value="0"/> </authentication> <http-headers> <header name="Access-Control-Allow-Origin" value="http://webplayer.example.org" /> <header name="baz" value="quux" /> </http-headers> <on-connect>/home/icecast/bin/stream-start</on-connect> <on-disconnect>/home/icecast/bin/stream-stop</on-disconnect> </mount> --> <!-- <mount type="normal"> <mount-name>/auth_example.ogg</mount-name> <authentication type="url"> <option name="mount_add" value="http://myauthserver.net/notify_mount.php"/> <option name="mount_remove" value="http://myauthserver.net/notify_mount.php"/> <option name="listener_add" value="http://myauthserver.net/notify_listener.php"/> <option name="listener_remove" value="http://myauthserver.net/notify_listener.php"/> <option name="headers" value="x-pragma,x-token"/> <option name="header_prefix" value="ClientHeader."/> </authentication> </mount> --> <!-- Start: Alle mountpoints die ik gebruik voor mijn icecast2 server op volumio --> <mount> <!-- TestStreamOGG mountpoint --> <mount-name>/TestStreamOGG</mount-name> <password>hackme</password> <!-- <type>application/ogg</type> --> </mount> <!-- Einde: Alle mountpoints die ik gebruik voor mijn icecast2 server op volumio --> <fileserve>1</fileserve> <paths> <!-- basedir is only used if chroot is enabled --> <basedir>/usr/share/icecast2</basedir> <!-- Note that if <chroot> is turned on below, these paths must both be relative to the new root, not the original root --> <logdir>/var/log/icecast2</logdir> <webroot>/usr/share/icecast2/web</webroot> <adminroot>/usr/share/icecast2/admin</adminroot> <!-- <pidfile>/usr/share/icecast2/icecast.pid</pidfile> --> <!-- Aliases: treat requests for 'source' path as being for 'dest' path May be made specific to a port or bound address using the "port" and "bind-address" attributes. --> <!-- <alias source="/foo" destination="/bar"/> --> <!-- Aliases: can also be used for simple redirections as well, this example will redirect all requests for http://server:port/ to the status page --> <alias source="/" destination="/status.xsl"/> <!-- The certificate file needs to contain both public and private part. Both should be PEM encoded. <ssl-certificate>/usr/share/icecast2/icecast.pem</ssl-certificate> --> </paths> <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 --> <!-- If logarchive is enabled (1), then when logsize is reached the logfile will be moved to [error|access|playlist].log.DATESTAMP, otherwise it will be moved to [error|access|playlist].log.old. Default is non-archive mode (i.e. overwrite) --> <!-- <logarchive>0</logarchive> --> </logging> <security> <chroot>0</chroot> <!-- <changeowner> <user>nobody</user> <group>nogroup</group> </changeowner> --> </security> </icecast>
Aangezien moderne systemen onder controle staan van systemd is er vaak ook al een service bestand meegeleverd of wordt deze zelf door systemd gegenereerd, zo niet, hier een voorbeeld:
Plaats deze in /usr/lib/systemd/system/icecast2.service) :
# # Copyright (c) 2013 Pascal Bleser <pascal.bleser@opensuse.org> # Authors: # * Pascal Bleser # * http://pyn00b.blogspot.be/2012/11/life-with-systemd-part-2.html # * Werner Fink for the postfix.service file # # Description: # # Used to start the Icecast server. # [Unit] Description=Icecast2 Server Requires=var-run.mount network.target remote-fs.target time-sync.target After=var-run.mount network.target remote-fs.target time-sync.target [Service] ExecStart=/usr/bin/icecast2 -b -c /etc/icecast2/icecast.xml ExecReload=/bin/kill -HUP $MAINPID ExecStop=/bin/kill -TERM $MAINPID Type=forking PIDFile=/var/run/icecast.pid [Install] WantedBy=multi-user.target
In /etc/icecast2/icecast.xml staat een waarde voor de PIDFile. Deze moet gedefineerd staan in de icecast.service file en in /etc/icecast.xml. Alleen definiëren is niet genoeg, de waarde moet ook gelijk zijn anders start icecast niet op (dat heeft me heel wat tijd gekost om daar achter te komen….).
Doe een deamon reload van systemd zodat systemd ook kennis heeft van deze nieuwe service file:
systemctl deamon-reload
Om te zorgen dat icecast altijd start bij het booten van het systeem:
systemctl enable icecast2
Nu even met de hand starten:
systemctl start icecast2
Ices2
De ices2 instanties moet je met systemd opstarten, voor elke source (elke ices2) maak je een service file, hier een voorbeeld:
# # Copyright (c) 2013 Pascal Bleser <pascal.bleser@opensuse.org> # Authors: # * Pascal Bleser # * http://pyn00b.blogspot.be/2012/11/life-with-systemd-part-2.html # * Werner Fink for the postfix.service file # * Arjan ten Hoopen for modifications for ices # # Description: # # Start the Ices source betonuur for IceCast. # [Unit] Description=Ices source for Playsist TestStreamOGG Requires=icecast2.service After=icecast2.service [Service] ExecStart=/usr/bin/ices2 /etc/ices2/TestStreamOGG.xml Type=forking User=icecast2 [Install] WantedBy=multi-user.target
Sla deze file op als /usr/lib/systemd/system/ices2-betonuur.service
Opstarten via
sudo systemctl start ices2-betonuur sudo systemctl enable ices2-betonuur
Voorbeeld configuratie voor een ices2.xml config file:
<?xml version="1.0"?> <ices> <!-- run in background --> <background>1</background> <!-- where logs, etc go. --> <logpath>/var/log/ices</logpath> <logfile>ices-TestStreamOGG.log</logfile> <!-- 1=error,2=warn,3=info,4=debug --> <loglevel>4</loglevel> <!-- set this to 1 to log to the console instead of to the file above --> <consolelog>0</consolelog> <!-- optional filename to write process id to --> <!-- <pidfile>/home/ices/ices.pid</pidfile> --> <stream> <!-- metadata used for stream listing (not currently used) --> <metadata> <name>Test Stream ogg in .m3u</name> <genre>Diversen</genre> <description>Testsream met van alles wat</description> </metadata> <!-- input module The module used here is the playlist module - it has 'submodules' for different types of playlist. There are two currently implemented, 'basic', which is a simple file-based playlist, and 'script' which invokes a command to returns a filename to start playing. --> <input> <module>playlist</module> <param name="type">basic</param> <param name="file">/Media/audio/Playlists/arjan/TestStreamOGG.m3u</param> <!-- random play --> <param name="random">0</param> <!-- if the playlist get updated that start at the beginning --> <param name="restart-after-reread">0</param> <!-- if set to 1 , plays once through, then exits. --> <param name="once">0</param> </input> <!-- Stream instance You may have one or more instances here. This allows you to send the same input data to one or more servers (or to different mountpoints on the same server). Each of them can have different parameters. This is primarily useful for a) relaying to multiple independent servers, and b) encoding/reencoding to multiple bitrates. If one instance fails (for example, the associated server goes down, etc), the others will continue to function correctly. This example defines two instances as two mountpoints on the same server. --> <instance> <!-- Server details: You define hostname and port for the server here, along with the source password and mountpoint. --> <hostname>localhost</hostname> <port>8000</port> <password>hackme</password> <mount>/TestStreamOGG</mount> <yp>0</yp> <!-- allow stream to be advertised on YP, default 0 --> <type>basic</type> <!-- Reconnect parameters: When something goes wrong (e.g. the server crashes, or the network drops) and ices disconnects from the server, these control how often it tries to reconnect, and how many times it tries to reconnect. Delay is in seconds. If you set reconnectattempts to -1, it will continue indefinately. Suggest setting reconnectdelay to a large value if you do this. --> <reconnectdelay>2</reconnectdelay> <reconnectattempts>5</reconnectattempts> <!-- maxqueuelength: This describes how long the internal data queues may be. This basically lets you control how much data gets buffered before ices decides it can't send to the server fast enough, and either shuts down or flushes the queue (dropping the data) and continues. For advanced users only. --> <maxqueuelength>80</maxqueuelength> <!-- Live encoding/reencoding: Currrently, the parameters given here for encoding MUST match the input data for channels and sample rate. That restriction will be relaxed in the future. Remove this section if you don't want your files getting reencoded. --> </instance> </stream> </ices>
Ices0 (mp3)
Moet je zelf bouwen. Gedaan op Pi en OpenSUSE
Raspberry Pi
Download libshout vanaf: https://icecast.org/download/
Download ices.04 vanaf: https://icecast.org/ices/
Install additonle packages:
sudo apt install libogg-dev libogg0 libflac-dev # flac krijg ik nog niet aan de praat :)
Eerst libshout bouwen
cd $HOME/libshout-2.4.6 ./configure make sudo make install
Daarna Ices0
cd $HOME/ices-0.4 ./configure make sudo make install
Executable staat in /usr/local/bin/ices. Deze ices geeft bij sucesvol opstarten de return code 1 ipv 0. Daarom maak je in /usr/bin een bestand ices0 aan met de volgende inhout:
#!/bin/bash # fake exit 0 since exit 1 of ices means succes # echo /usr/local/bin/ices $1 $2 $3 $4 $5 $6 $7 $8 $9 /usr/local/bin/ices $1 $2 $3 $4 $5 $6 $7 $8 $9 RC=$? if [ ${RC} -eq 1 ] ; then exit 0 else exit 1 fi
Om ices (voor mp3) te gebruiken gebruik je het commando /usr/bin/ices0
*** NOG UITZOEKEN HOE JE DIT OP EEN PI VOOR ELKAAR KRIJGT ****
OpenSuse
Zoek op het internet naar ices0.4 deze support mp3, mogelijk een goede plek: http://icecast.org/ices/
Deze compileren, zorg van te voren dat je het volgende via de package manager geinstalleerd hebt:
-
libshout-devel
-
libxml2 (?)
-
libxml2-develop
-
lame (?)
-
libmp3lame-devel
-
libvorbis-devel
-
flac-devel
-
python-devel (http://download.opensuse.org/repositories/devel:/languages:/python/openSUSE_13.2/)
De volgende gaven bij mij een error, maar een iets begaafdere developer kan daar vast wel omheen komen 🙂
-
libfaad-devel <<<< — error during compile better not install
-
libmp4v2-devel <<<<— error during compile better not install
Ices heeft een vervelende eigenschap. Het geeft return code 1. systemd denkt derhalve dat er wat fout is gegaan. Dit moeten we aanpassen!!!!!!!
Ga op zoek naar “/* Down and down we go… */” in setup.c (ongeveer bij regel 135). Verander de daarop volgende regel “exit (1);” in “exit (0);”. Save setup.c
Compileren:
./configure make all
De executable (ices) staan in ./src en deze copieren naar /tenhoopen/bin
Een voorbeeld systemd service file voor een ices instantie (betonuur) ziet er als volgt uit;
# # Copyright (c) 2013 Pascal Bleser <pascal.bleser@opensuse.org> # Authors: # * Pascal Bleser # * http://pyn00b.blogspot.be/2012/11/life-with-systemd-part-2.html # * Werner Fink for the postfix.service file # * Arjan ten Hoopen for modifications for ices # # Description: # # Sart the Ices source betonuur for IceCast. # [Unit] Description=Ices source for BetonUur Requires= After= [Service] ExecStart=/tenhoopen/bin/ices -B -c /etc/ices/betonuur/betonuur.xml ExecReload=/bin/kill -HUP $MAINPID ExecStop=/bin/kill -TERM $MAINPID Type=forking PIDFile=/var/log/ices/betonuur/ices.pid [Install] WantedBy=multi-user.target
Sla deze file op als /usr/lib/systemd/system/ices-betonuur.service
Maak een directory waar alle ices files voor het betonuur in komen te staan:
mkdir /etc/ices/betonuur
In /etc/ices/betonuur moet je een file maken (betonuur.txt) met op elke regel het volledige path naar een mp3 file.
Tevens maak je hier een bestand betonuur.xml die er ongeveer als volgt uit ziet:
<?xml version="1.0"?> <ices:Configuration xmlns:ices="http://www.icecast.org/projects/ices"> <Playlist> <!-- This is the filename used as a playlist when using the builtin playlist handler. --> <File>/etc/ices/betonuur/betonuur.txt</File> <!-- Set this to 0 if you don't want to randomize your playlist, and to 1 if you do. --> <Randomize>1</Randomize> <!-- One of builtin, perl, or python. --> <Type>builtin</Type> <!-- Module name to pass to the playlist handler if using perl or python. If you use the builtin playlist handler then this is ignored --> <Module>ices</Module> <!-- Set this to the number of seconds to crossfade between tracks. Leave out or set to zero to disable crossfading (the default). --> <!-- <Crossfade>5</Crossfade> --> </Playlist> <Execution> <!-- Set this to 1 if you want ices to launch in the background as a daemon --> <Background>1</Background> <!-- Set this to 1 if you want to see more verbose output from ices --> <Verbose>1</Verbose> <!-- This directory specifies where ices should put the logfile, cue file and pid file (if daemonizing). --> <!-- Don't use /tmp if you have l33t h4x0rz on your server. --> <BaseDirectory>/var/log/ices/betonuur</BaseDirectory> </Execution> <Stream> <Server> <!-- Hostname or ip of the icecast server you want to connect to --> <Hostname>localhost</Hostname> <!-- Port of the same --> <Port>8000</Port> <!-- Encoder password on the icecast server --> <Password>letmein</Password> <!-- Header protocol to use when communicating with the server. --> <!-- Shoutcast servers need "icy", icecast 1.x needs "xaudiocast", and icecast 2.x needs "http". --> <Protocol>http</Protocol> </Server> <!-- The name of the mountpoint on the icecast server --> <Mountpoint>/betonuur</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> --> <!-- The name of you stream, not the name of the song! --> <Name>BetonUur</Name> <!-- Genre of your stream, be it rock or pop or whatever --> <Genre>Beton</Genre> <!-- Longer description of your stream --> <Description>Beton Uur - Alfred Lagarde...</Description> <!-- URL to a page describing your stream --> <URL>http://radio.famtenhoopen.nl:8000/</URL> <!-- 0 if you don't want the icecast server to publish your stream on the yp server, 1 if you do --> <Public>0</Public> <!-- Stream bitrate, used to specify bitrate if reencoding, otherwise just used for display on YP and on the server. --> <!-- Try to keep it accurate --> <Bitrate>128</Bitrate> <!-- If this is set to 1, and ices is compiled with liblame support, ices will reencode the stream on the fly to the stream bitrate. --> <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>
De logfiles komen in de directory /var/log/ices/betonuur, zorg dat deze bestaat!
Doe een deamon reload van systemd zodat systemd ook kennis heeft van deze nieuwe service file van ices-betonuur:
systemctl deamon-reload
Om te zorgen dat ices-betonuur altijd start bij het booten van het systeem:
systemctl enable ices-betonuur
Nu even met de hand starten:
systemctl start ices-betonuur
 Controleer of alles geactiveerd is:
$ systemctl status icecast ices-betonuur icecast.service - Icecast Server Loaded: loaded (/usr/lib/systemd/system/icecast.service; enabled) Active: active (running) since do 2017-05-25 20:06:21 CEST; 51s ago Process: 15941 ExecStop=/bin/kill -TERM $MAINPID (code=exited, status=0/SUCCESS) Process: 15951 ExecStart=/usr/bin/icecast -b -c /etc/icecast.xml (code=exited, status=0/SUCCESS) Main PID: 15953 (icecast) CGroup: /system.slice/icecast.service └─15953 /usr/bin/icecast -b -c /etc/icecast.xml mei 25 20:06:21 schuurpc icecast[15951]: Starting icecast2 mei 25 20:06:21 schuurpc icecast[15951]: Detaching from the console mei 25 20:06:21 schuurpc systemd[1]: PID file /var/run/icecast.pid not readable (yet?) after start. mei 25 20:06:21 schuurpc icecast[15951]: [2017-05-25  20:06:21] WARN CONFIG/_parse_root Warning, server version string override detected. This may lead to unexpected client software behavior. mei 25 20:06:21 schuurpc systemd[1]: Started Icecast Server. mei 25 20:06:21 schuurpc icecast[15951]: Starting icecast2 mei 25 20:06:21 schuurpc icecast[15951]: Detaching from the console mei 25 20:06:21 schuurpc icecast[15951]: Changed groupid to 473. mei 25 20:06:21 schuurpc icecast[15951]: Changed supplementary groups based on user: icecast. mei 25 20:06:21 schuurpc icecast[15951]: Changed userid to 471. ices-betonuur.service - Ices Server for BetonUur Loaded: loaded (/usr/lib/systemd/system/ices-betonuur.service; disabled) Active: active (running) since do 2017-05-25 20:06:21 CEST; 51s ago Process: 15952 ExecStart=/tenhoopen/bin/ices -B -c /etc/ices/betonuur/betonuur.xml (code=exited, status=0/SUCCESS) Main PID: 15954 (ices) CGroup: /system.slice/ices-betonuur.service └─15954 /tenhoopen/bin/ices -B -c /etc/ices/betonuur/betonuur.xml mei 25 20:06:21 schuurpc systemd[1]: Started Ices Server for BetonUur. mei 25 20:06:21 schuurpc ices[15952]: Into the land of the dreaded daemons we go... (pid: 15954) $
 Via de browser naar de IceCast server http://10.0.0.150:8000
De stream is nu te vinden via http://10.0.0.150:800/betonuur
Op een Pi
Nog wel ff uitzoeken
sudo apt update -y && sudo apt upgrade -y #sudo apt remove icecast2 # remove icecast 2 for a clean install sudo apt install icecast2
Je krijgt nu een interactief deel voor de installatie, noteer je gegevens!
hostname: volumio.thuis.net
Icecast2 source password: hackme
Icecast2 relay password: hackme
Icecast2 administration password: hackme (access via http://localhost:8000
sudo systemctl restart icecast2.service
sudo systemctl status icecast2.service