Passer au contenu principal

Blog de Guillaume Seznec

Icecast2 sur Debian

Comment installer un serveur de streaming audio/vidéo avec Icecast

Exemple avec un VPS chez OVH fraichement installé avec Debian 10

Se connecter en root :

apt-get install icecast2

éditer /etc/icecast2/icecast.xml

<icecast>
    <location>Paris</location>
    <admin>webmaster@example.com</admin>
    <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>
        <burst-on-connect>1</burst-on-connect>
        <burst-size>65535</burst-size>
    </limits>

    <authentication>
        <source-password>sourcePwd</source-password>
        <relay-password>replayPwd</relay-password>
        <admin-user>admin</admin-user>
        <admin-password>adminPwd</admin-password>
    </authentication>

    <hostname>live.adhocmusic.com</hostname>

    <listen-socket>
        <port>80</port>
    </listen-socket>

    <http-headers>
        <header name="Access-Control-Allow-Origin" value="*" />
    </http-headers>

    <fileserve>1</fileserve>

    <paths>
        <basedir>/usr/share/icecast2</basedir>
        <logdir>/var/log/icecast2</logdir>
        <webroot>/usr/share/icecast2/web</webroot>
        <adminroot>/usr/share/icecast2/admin</adminroot>
        <alias source="/" destination="/status.xsl"/>
    </paths>

    <logging>
        <accesslog>access.log</accesslog>
        <errorlog>error.log</errorlog>
        <loglevel>4</loglevel>
        <logsize>10000</logsize>
    </logging>

    <security>
        <chroot>0</chroot>
        <changeowner>
            <user>icecast2</user>
            <group>icecast</group>
	    </changeowner>
    </security>
</icecast>

/etc/defaults/icecast2

# Defaults for icecast2 initscript
# sourced by /etc/init.d/icecast2
# installed at /etc/default/icecast2 by the maintainer scripts

#
# This is a POSIX shell fragment
#

# Full path to the server configuration file
CONFIGFILE="/etc/icecast2/icecast.xml"

# Name or ID of the user and group the daemon should run under
#USERID=icecast2
#GROUPID=icecast

# pour autoriser icecast sur le port 80
USERID=root
GROUPIP=root

Il n’est pas conseillé de mettre Icecast derrière un reverse proxy comme NGInx

Alimenter le serveur avec un flux issu de ffmpeg Sous MacOS, périphérique audio “1”, conversion mp3 stereo

ffmpeg -f avfoundation -i ":1" -re
  -c:a libmp3lame -ab 128k -ac 2 -ar 44100 
  -content_type audio/mpeg
   -f mp3 icecast://source:sourcePwd@live.adhocmusic.com:80/live

Et pour le lire

mpv ou vlc http://live.adhocmusic.com/live