Вы находитесь на странице: 1из 12

SERVIDOR DE STRAMING El repositurios con el quese configurar streaming ser icast Introduccin Icecast2 Es un servidor media streaming que

soporta los formatos ogg y mp3. Es accesible desde un navegador web por lo que cualquier usuario se puede conectar a nuestro PC y escuchar los contenidos que emitamos en tiempo real, es decir que podemos tener nuestra propia radio por internet. Icecast2 necesita lo que se denomina un cliente streaming que le entregue contenidos para que funcione. Estos contenidos pueden ser archivos ubicados en una carpeta en el PC, un reproductor de CD, un micrfono conectado a la tarjeta de sonido. El cliente oficial de Icecast2 es Ices2, aunque existen otros como por ejemplo Muse. Existen dos versiones, una le suministra archivos en formato mp3, la otra versin le suministra archivos en formato ogg.

PASOS A SEGUIR 1.- INSTALACIN DE icecast2 , ices2 2.- CONFIGURACIN DE icecast2 3.- HABILITAR EL SERVICIO 4.- CONFIGURACIN DEL CLIENTE ices2 PARA icecast2 5.- CONFIGURACIN DEL ARCHIVO DE CANCIONES A REPRODUCIR 6.- ARRANCAR EL CLIENTE ices2 7.- DETENER icecast2 , ices2 8.- INICIAR icecast2 , ices2 AL INICIAR UBUNTU

1.- INSTALACIN DE icecast2 Instalamos icecast2, ices2 y herramientas vorbis para manejo de formatos de audio libres (ogg). Nos vamos a una terminal y tecleamos apt-get install icecast2 ices2 vorbis-tools

2.- CONFIGURACIN DE icecast2 Icecast2 viene con los archivos de configuracin ubicados en /etc/icecast2. Debemos configurar los password para las fuentes y para el administrador, as como el nombre del servidor, editando el archivo /etc/icecast2/icecast.xml sudo gedit /etc/icecast2/icecast.xml

Buscamos la seccin <authentication> y configuramos los siguientes parmetros PASSWORD_FUENTES , PASSWORD_RELAY , ADMINISTRADOR, PASSWORD_ADMINISTRADOR <authentication> <source-password>PASSWORD_FUENTES</source-password> <relay-password>PASSWORD_RELAY</relay-password> <admin-user>ADMINISTRADOR</admin-user> <admin-password>PASSWORD_ADMINISTRADOR</admin-password> </authentication>

Buscamos la seccin <hostname> Indicamos el nombre del servidor que vamos a utilizar. Si emitimos desde nuestro equipo en local ponemos localhost <hostname>www.miservidor.com</hostname>

Buscamos la seccin <listen-socket> Indicamos el puerto desde el que emitimos. Si emitimos desde nuestro equipo en local podemos dejar el 8000 <listen-socket> <port>8000</port>

3.- HABILITAR EL SERVICIO. Nos vamos a una terminal y editamos el archivo /etc/default/icecast2 poniendo la variable ENABLE a true que por defecto viene inhabilitada. sudo gedit /etc/default/icecast2 # Edit /etc/icecast2/icecast.xml and change at least the passwords. # Change this to true when done to enable the init.d script ENABLE=true

icecast2 viene con un servicio montado en /etc/init.d/icecast2 (el cual acabamos de habilitar), ahora lo activamos sudo /etc/init.d/icecast2 start

En consola nos mostrar Starting icecast2:

Si ahora nos vamos a la barra de direcciones del navegador web y tecleamos http://localhost:8000 , si todo fue correcto veremos la pgina de icecast , desde la cual tenemos acceso a administracin, listas de reproduccin, conexiones clientes

Como vemos an no tenemos ningn Active Mountpoints, lo cual conseguiremos tras instalar el cliente ices2 y establezcamos las "lista de canciones"

4.- CONFIGURACIN DEL CLIENTE ices2 PARA icecast2 Ices2 no viene con archivos de configuracin por defecto. Lo que si trae en /usr/share/doc/ices2/examples son archivos de ejemplo para configuraciones de alsa (icesalsa.xml), oss (ices-oss.xml) y playlist (ices-playlist.xml). Vamos a utilizar esta ltima: creamos una carpeta en /etc llamada ices2 ,copiamos all el archivo y le otorgamos permisos sudo mkdir /etc/ices2 sudo cp /usr/share/doc/ices2/examples/ices-playlist.xml /etc/ices2/ sudo chmod +x /etc/ices2/ices-playlist.xml

A continuacin editamos el archivo y lo configuramos sudo gedit /etc/ices2/ices-playlist.xml

Es muy sencillo, vamos a ir vindolo por secciones:

En la seccin <background> cambiamos el 0 por 1, de esta forma evitaremos que se mantenga la terminal abierta hasta que lo cerremos. <background>1</background>

En la seccin <metadata> configuramos: <metadata> <name>NOMBRE ESTACION</name> <genre>GENERO ESTACION</genre> <description>DESCRIPCION ESTACION</description> </metadata>

En la seccin <input> configuramos: <param name="file">/miruta/playlist.txt</param> <param name="random">1</param> <param name="once">0</param> Establecemos la ruta al archivo que contiene la lista de canciones: /miruta/playlist.txt Random: indicamos si queremos que la reproduccin de los archivos sea secuencial (0) o aleatoria (1). Once: Indicamos si queremos que la emisora deje de emitir al terminar la lista de reproduccin (1) o que contine emitiendo sin interrupcin (0).

En la seccin <instance> configuramos: <hostname>localhost</hostname> <port>8000</port> <password>PASSWORD_FUENTES</password> <mount>/lista_de_reproduccion.ogg</mount> La direccin del servidor: localhost (porque lo tengo en local, si lo instalsemos en un hosting pondramos la direccin) El puerto: por defecto trae 8000 (lo dejamos tal cual) El password de las fuentes: PASSWORD_FUENTES (es el mismo password que hemos puesto en /etc/icecast2/icecast.xml)

En <mount></mount> debemos escojer el mount point que queramos para emitir. Podemos poner algo descriptivo (sin espacios y acabado en .ogg), por ejemplo lista_de_reproduccion.ogg

Y aqu est el archivo completo: <?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>Radio La Vida es TUX</name> <genre>Linux Ubuntu Radio</genre> <description>Msica para relajarse</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">/home/greiscool/musicaradio/playlist.txt</param> <!-- random play --> <param name="random">1</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>PASSWORD_FUENTES</password> <mount>/lista_de_reproduccion.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> Creamos la carpeta para el archivo log para ices sudo mkdir /var/log/ices

y le damos permisos, si no lo hacemos al arrancar ices2 nos lanzar un ERROR sudo chmod 777 /var/log/ices

5.- CONFIGURACIN DEL ARCHIVO DE CANCIONES A REPRODUCIR Para ello tenemos dos opciones: Opcin a) Creamos la ruta hacia un archivo con la lista de canciones con el comando siguiente sudo find /RUTA_DONDE_ESTAN_LAS_CANCIONES -iname "*.ogg" > /RUTA_DONDE_TENGO_EL_ARCHIVO_LISTA/LISTA.TXT

Opcin b) Editamos el archivo y tecleamos la ruta completa para cada cancin sudo gedit /RUTA_DONDE_TENGO_EL_ARCHIVO_LISTA/LISTA.TXT /RUTA_DONDE_ESTAN_LAS_CANCIONES/nombre_cancion1.ogg /RUTA_DONDE_ESTAN_LAS_CANCIONES/nombre_cancion2.ogg ..

6.- ARRANCAR ices2 Tecleando en consola

sudo ices2 /etc/ices2/ices-playlist.xml &

Si ahora nos vamos a la pgina (en este caso http://localhost:8000 veremos que aparece el enlace http://localhost:8000/lista_de_reproduccion.ogg , con el que podemos conectarnos a la radio.

7.- DETENER icecast2 , ices2 Si deseamos detener icecast2 tecleamos en una terminal sudo /etc/init.d/icecast2 stop

nos responder

Stopping icecast2: icecast2.

Si deseamos detener ices2 tecleamos en una terminal ps ax | grep ices2

nos responder dandonos el pid del proceso, algo como lo siguiente 23242 pts/0 S+ 0:00 grep color=auto ices2

(23242 es el pid que me ha dado, debemos comprobarlo en el momento que deseemos)

Este nmero nos permitir detener el ices2 (la emisin) cuando deseemos, tecleando en consola sudo kill -9 23242

8.- INICIAR icecast2 , ices2 al iniciar Ubuntu Creamos un archivo icecast2 y lo colocamos en /etc/init.d , tecleando en consola sudo gedit /etc/init.d/icecast2

con las siguientes lneas de cdigo (aunque tiene una cabecera que identifica al autor original, ha sido modificado posteriormente en varias ocasiones, incluso yo mismo lo he modificado) es funcional si se han seguido los pasos anteriores. #!/bin/sh ###BEGIN INIT INFO # Provides: icecast2 # Required-Start: $remote_fs $network # Required-Stop: $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Starts the icecast audio streaming server daemon ### END INIT INFO # # 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 Una vez creado el archivo hacemos que se agregue como servicio y as ser iniciado durante el arranque de Ubuntu. sudo update-rc.d icecast2 defaults

Listo cada vez que arranquemos Ubuntu ya tendremos el icecast2 y su cliente ices2 operativos.

Вам также может понравиться