Configurando o servidor de streaming de audio MP3 com IceCast no Debian

  • Post author:
  • Post category:Sem categoria

Servidor

* Instale icecast e darkice:

apt-get install icecast2 darkice

* Coloque o usu?rio do icecast2 no grupo audio.

Edite o arquivo /etc/group e troque a linha:

audio:x:29:

Pela linha:

audio:x:29:icecast2

* Copie configura??o do icecast:

cd /etc/icecast2
cp icecast.xml icecast.xml.old

* Copie configura??o do darkice:

cd /etc
cp /usr/share/doc/darkice/examples/darkice.cfg darkice.cfg

* Edite o arquivo /etc/icecast2/icecast.xml e alter?-lo com as configura??es desejadas.

Neste caso, apenas escolha uma senha para ser usada, esta senha s? ? importante quando se deseja utilizar op??es avan?adas, mas deve ser configurada corretamente para o servidor funcionar.

Alterar as linhas a seguir, trocando a palavra hackme pela senha desejada:

linha 14:hackme
linha 16:hackme
linha 20:hackme

A primeira senha tamb?m ser? usada no darkice, a segunda ? usada para fazer relay e a terceira e a senha de administrador do icecast (acesso via p?gina http).

* Edite o arquivo /etc/darkice.cfg.

Ele dever? ter a configura??o a seguir, voc? apenas dever? modificar os trechos marcados em MAI?SCULO

# sample DarkIce configuration file, edit for your needs before using
# see the darkice.cfg man page for details
# this section describes general aspects of the live streaming session

[general]
duration = 0 # duration of encoding, in seconds. 0 means forever
bufferSecs = 5 # size of internal slip buffer, in seconds

# this section describes the audio input that will be streamed

[input]
device = /dev/dsp # OSS DSP soundcard device for the audio input
sampleRate = 22050 # sample rate in Hz. try 11025, 22050 or 44100
bitsPerSample = 16 # bits per sample. try 16
channel = 2 # channels. 1 = mono, 2 = stereo
# this section describes a streaming connection to an IceCast server
# there may be up to 8 of these sections, named [icecast-0]…[icecast-7]
# these can be mixed with [icecast2-x] and [shoutcast-x] sections
# this section describes a streaming connection to an IceCast2 server
# there may be up to 8 of these sections, named [icecast2-0]…[icecast2-7]
# these can be mixed with [icecast-x] and [shoutcast-x] sections

[icecast2-0]
bitrateMode= abr # average bit rate
format = vorbis # format of the stream: ogg vorbis
bitrate = 96 # bitrate of the stream sent to the server
server = localhost
# host name of the server
port = 8000 # port of the IceCast2 server, usually 8000
password = SUA SENHA # primeira senha que foi selecionada no arquivo icecast.xml
mountPoint = radio.ogg # mount point of this stream on the IceCast2 server
name = NOME DA RADIO
# Nome da r?dio
description= DESCRICAO DA RADIO
# Descri??o da r?dio
url = http://www.yourserver.com
# URL related to the stream
genre = GENERO # G?nero da transmiss?o
public = yes # advertise this stream?

* Edite o arquivo /etc/default/icecast2 e mude a linha:
ENABLE=false
para:
ENABLE=true

* Crie o arquivo de inicializa??o do darkice. O arquivo dever? ser o /etc/init.d/darkice.

Seu conte?do dever? ser o seguinte:

#! /bin/sh
#
# darkice
#
# Written by Miquel van Smoorenburg .
# Modified for Debian
# by Ian Murdock .
#
# Further modified by Keegan Quinn
# for use with Icecast 2
#
# Modified for libertasbr (libertasbr.gov.br)
# for use with darkice
# by Leonardo L. P. da Mata

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11
DAEMON=/usr/bin/darkice
NAME=darkice
DESC=darkice

test -x $DAEMON || exit 0

# Defaults
CONFIGFILE=”/etc/darkice.cfg”
USERID=icecast2
GROUPID=icecast

# Reads config file (will override defaults above)
set -e

case “$1” in
start)
echo -n “Starting $DESC: “
start-stop-daemon –start –quiet –chuid $USERID:$GROUPID \
–background –exec $DAEMON — -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 \
–background –exec $DAEMON — -c $CONFIGFILE
echo “$NAME.”
;;
*)
echo “Usage: $0 {start|stop|restart|reload|force-reload}” >&2
exit 1
;;
esac

exit

* ? necess?rio tornar o arquivo execut?vel e fazer o darkice iniciar no boot do servidor:

chmod 755 /etc/init.d/darkice
ln -s /etc/init.d/darkice /etc/rc2.d/S21darkice

Note que estamos usando o run level 2(default)

* Para iniciar o servidor:

/etc/init.d/icecast2 start
/etc/init.d/darkice start

Com isso, o servidor est? corretamente configurado para servir a r?dio.