Wie Du Deine eigene Webradio Station mit Icecast2 und Ices2 betreibst

vi /etc/ices2/ices-playlist.xml

<?xml version="1.0"?>
<ices>
    <!-- run in background -->
    <background>1</background>
    <!-- where logs, etc go. -->
    <logpath>/var/log/ices</logpath>
    <logfile>ices.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>Example stream name</name>
            <genre>Example genre</genre>
            <description>A short description of your stream</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">/etc/ices2/playlist.txt</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>password1</password>
            <mount>/example1.ogg</mount>

            <!-- 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.
            -->
            <encode>
                <nominal-bitrate>64000</nominal-bitrate> <!-- bps. e.g. 64000 for 64 kbps -->
                <samplerate>44100</samplerate>
                <channels>2</channels>
            </encode>
        </instance>

        </stream>
</ices>

Setze danach Deine .ogg Dateien in das /etc/ices2/music Verzeichnis (pass aber bitte auf die Lizenzen Deiner Audio-Dateien, die Du übertragen möchtest, auf – es kann sein, dass Du Geld zahlen musst, um sie übertragen zu dürfen), z.B. mit einem Tool wie WinSCP.

Erstelle danach die Datei /etc/ices2/playlist.txt und setze die vollständigen Pfade Deiner .ogg Dateien ein, eine Zeile pro .ogg Datei:

vi /etc/ices2/playlist.txt

[...]
/etc/ices2/music/1vs0_JuniorGroove.ogg
/etc/ices2/music/1vs0_TheWavechangerSuperhero.ogg
[...]

Starte dann Ices2:

ices2 /etc/ices2/ices-playlist.xml

Im Icecast2 Web Interface solltest Du nun einen Link zu Deinem neuen Audio Stream sehen (Click to Listen -> http://192.168.0.100:8000/example1.ogg.m3u aber http://192.168.0.100:8000/example1.ogg funktioniert auch):

Öffne den Link mit einem Audio Player Deiner Wahl, zum Beispiel WinAMP:

Wenn Du beenden möchtest Ices2, führe dies aus

kill -9 `pidof ices2`

4 Das Icecast2 Init Skript modifizieren

Ices2 hat kein Init Skript, was bedeutet, dass wir es unabhängig von Icecast2 starten/stoppen müssen. Icecast2 hat ein Init Skript, was bedeutet, dass es automatisch beim Hochfahren startet, jedoch Ices2 nicht, was ziemlich nervig werden kann. Daher modifizieren wir das Icecast2 Init Skript und fügen ihm Bereiche für Ices2 hinzu.

Das ursprüngliche Icecast2 Init Skript sieht wie folgt aus:

vi /etc/init.d/icecast2

#! /bin/sh
#
# icecast2
#
#                Written by Miquel van Smoorenburg <miquels@cistron.nl>.
#                Modified for Debian
#                by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
#                Further modified by Keegan Quinn <ice@thebasement.org>
#                for use with Icecast 2
#

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/icecast2
NAME=icecast2
DESC=icecast2

test -x $DAEMON || exit 0

# Defaults
CONFIGFILE="/etc/icecast2/icecast.xml"
CONFIGDEFAULTFILE="/etc/default/icecast2"
USERID=icecast2
GROUPID=icecast
ENABLE="false"

# Reads config file (will override defaults above)
[ -r "$CONFIGDEFAULTFILE" ] && . $CONFIGDEFAULTFILE

if [ "$ENABLE" != "true" ]; then
        echo "$NAME daemon disabled - read $CONFIGDEFAULTFILE."
        exit 0
fi

set -e

case "$1" in
  start)
        echo -n "Starting $DESC: "
        start-stop-daemon --start --quiet --chuid $USERID:$GROUPID
                --exec $DAEMON -- -b -c $CONFIGFILE
        echo "$NAME."
        ;;
  stop)
        echo -n "Stopping $DESC: "
        start-stop-daemon --stop --oknodo --quiet --exec $DAEMON
        echo "$NAME."
        ;;
  reload|force-reload)
        echo "Reloading $DESC configuration files."
        start-stop-daemon --stop --signal 1 --quiet --exec $DAEMON
        ;;
  restart)
        echo -n "Restarting $DESC: "
        start-stop-daemon --stop --oknodo --quiet --exec $DAEMON
        sleep 1
        start-stop-daemon --start --quiet --chuid $USERID:$GROUPID
                --exec $DAEMON -- -b -c $CONFIGFILE
        echo "$NAME."
        ;;
  *)
        echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
        exit 1
        ;;
esac

exit 0

Wir modifizieren es, so dass es wie folgt aussieht (ich habe die Teile in Rot hinzugefügt oder modifiziert):

vi /etc/init.d/icecast2

#! /bin/sh
#
# icecast2
#
#                Written by Miquel van Smoorenburg <miquels@cistron.nl>.
#                Modified for Debian
#                by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
#                Further modified by Keegan Quinn <ice@thebasement.org>
#                for use with Icecast 2
#

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/icecast2
NAME=icecast2
DESC=icecast2
ICES=/usr/bin/ices2
ICES_CONFIGFILE=/etc/ices2/ices-playlist.xml

test -x $DAEMON || exit 0

# Defaults
CONFIGFILE="/etc/icecast2/icecast.xml"
CONFIGDEFAULTFILE="/etc/default/icecast2"
USERID=icecast2
GROUPID=icecast
ENABLE="false"

# Reads config file (will override defaults above)
[ -r "$CONFIGDEFAULTFILE" ] && . $CONFIGDEFAULTFILE

if [ "$ENABLE" != "true" ]; then
        echo "$NAME daemon disabled - read $CONFIGDEFAULTFILE."
        exit 0
fi

set -e

case "$1" in
  start)
        echo -n "Starting $DESC: "
        start-stop-daemon --start --quiet --chuid $USERID:$GROUPID
                --exec $DAEMON -- -b -c $CONFIGFILE
        sleep 3
        start-stop-daemon --start --quiet --exec $ICES $ICES_CONFIGFILE
        echo "$NAME."
        ;;
  stop)
        echo -n "Stopping $DESC: "
        start-stop-daemon --stop --oknodo --quiet --exec $ICES

        start-stop-daemon --stop --oknodo --quiet --exec $DAEMON
        echo "$NAME."
        ;;
  reload|force-reload)
        echo "Reloading $DESC configuration files."
        start-stop-daemon --stop --oknodo --quiet --exec $ICES
        start-stop-daemon --stop --signal 1 --quiet --exec $DAEMON
        sleep 3
        start-stop-daemon --start --quiet --exec $ICES $ICES_CONFIGFILE
        ;;
  restart)
        echo -n "Restarting $DESC: "
        start-stop-daemon --stop --oknodo --quiet --exec $ICES

        start-stop-daemon --stop --oknodo --quiet --exec $DAEMON
        sleep 3
        start-stop-daemon --start --quiet --chuid $USERID:$GROUPID
                --exec $DAEMON -- -b -c $CONFIGFILE
        sleep 3
        start-stop-daemon --start --quiet --exec $ICES $ICES_CONFIGFILE
        echo "$NAME."
        ;;
  *)
        echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2
        exit 1
        ;;
esac

exit 0

Nun startet/stoppt Ices2 zusammen mit Icecast2 und startet auch beim Hochfahren.

5 Links

Das könnte dich auch interessieren …