Tabla de Contenidos

Ezstream

Cliente de medios para streaming a servidores Icecast. Permite la creación de streams multimedia a partir de ficheros o de la salida estándar. Soporta streams en Ogg, MP3, WebM y Matroska.

Instalación

Docker

El fichero Dockerfile:

FROM alpine:edge
 
LABEL maintainer="TempWin <tempwin@ejemplo.com>"
 
ARG UID=1000
ARG GID=1000
 
RUN apk -q update \
    && apk -q --no-progress add ezstream \
    && rm -rf /var/cache/apk/*
 
VOLUME ["/ezstream", "/music"]
 
USER $UID:$GID
 
ENTRYPOINT ["/usr/bin/ezstream", "-c", "/ezstream/ezstream.xml"]

El fichero docker-compose.yml:

version: '2.1'
services:
  ezstream:
    build: .
    container_name: ezstream
    volumes:
      - ./config:/ezstream
      - ./music:/music

Configuración

Creamos un fichero XML con la configuración necesaria.

Para este ejemplo, se ha creado previamente un fichero llamado lista.m3u con la ruta a ficheros de audio .mp3. Esta lista de reproducción la emitirá aleatoriamente y sin parar.

También está cubierta la información del servidor Icecast al que enviaremos el stream para que cualquier persona pueda conectarse y recibirlo.

<?xml version="1.0" encoding="UTF-8"?>
 
<ezstream>
 
  <servers>
    <server>
      <!-- Identifying name (default: "default") -->
      <name>Test Server</name>
 
      <!--
        Transport protocol:
        HTTP (default), HTTPS (implies <tls>required</tls>), ICY, RoarAudio
        -->
      <protocol>HTTP</protocol>
      <!-- Server address -->
      <hostname>tempwin.net</hostname>
      <!-- Server port (default: 8000) -->
      <port>8000</port>
 
      <!-- Login user (default: "source") -->
      <user>source</user>
      <!-- Login password (check file permissions, or everyone can see this) -->
      <password>topsecret</password>
 
      <!--
        Configure TLS requirement: none, may, required (default: "may")
 
        For compatibility reasons, the default configuration and this example
        is "may". THIS IS INSECURE. It allows a MitM to intercept the
        password and tamper with the stream. It is recommended to set this to
        "required" when configuring TLS to secure streaming over untrusted
        networks.
        -->
      <tls>May</tls>
 
      <!--
        Configure allowed cipher suites for TLS other than the libshout
        default.
        See openssl(1)/ciphers(1) for details.
        -->
      <tls_cipher_suite>HIGH:!RSA:!SHA:!DH:!aNULL:!eNULL:!TLSv1</tls_cipher_suite>
 
      <!-- Number of reconnection attempts, before giving up (default: 0) -->
      <reconnect_attempts>20</reconnect_attempts>
    </server>
  </servers>
 
  <!--
    Stream configuration
    -->
  <streams>
    <stream>
      <!--
        Identifying name (default: "default")
 
        NB: Only the "default" stream is supported at this point.
        -->
      <!-- <name>default</name> -->
 
      <!-- Mount point on server -->
      <mountpoint>/foo</mountpoint>
 
      <!-- Name of the intake entry to use (default: "default") -->
      <intake>Test Input</intake>
 
      <!-- Name of the server entry to use (default: "default") -->
      <server>Test Server</server>
 
      <!--
        Setting to allow stream to be listed in public YP directory
        (default: no)
        -->
      <public>No</public>
 
      <!-- Stream format: Ogg, MP3, WebM, Matroska -->
      <format>MP3</format>
 
      <!-- Various other informational settings -->
      <stream_name>Foo Stream</stream_name>
      <stream_url>http://tempwin.net:8000/</stream_url>
      <stream_genre>Beeps</stream_genre>
      <stream_description>Foo description</stream_description>
      <stream_quality>1.5</stream_quality>
      <stream_bitrate>16</stream_bitrate>
      <stream_samplerate>44100</stream_samplerate>
      <stream_channels>2</stream_channels>
    </stream>
  </streams>
 
  <!--
    Intake configuration
    -->
  <intakes>
    <intake>
      <!-- Identifying name (default: "default") -->
      <name>Test Input</name>
 
      <!--
        Media type: autodetect, file, playlist, program, stdin
       (default: autodetect)
        -->
      <type>playlist</type>
 
      <!-- Input file, program name, or "stdin" keyword (deprecated) -->
      <filename>/home/tempwin/music/lista.m3u</filename>
 
      <!-- Setting to shuffle playlists -->
      <shuffle>Yes</shuffle>
 
      <!-- Setting whether to stream intake indefinitely or only once -->
      <stream_once>No</stream_once>
    </intake>
  </intakes>
 
  <!--
    Metadata configuration
    -->
  <metadata>
    <!-- Program to query for metadata instead of from media files -->
    <!-- <program>meta.sh</program> -->
 
    <!-- Metadata format -->
    <format_str>@a@ - @t@</format_str>
 
    <!-- Interval for additional metadata refreshes (default: -1 (none)) -->
    <refresh_interval>-1</refresh_interval>
 
    <!-- Setting to clean up extraneous whitespace (default: no) -->
    <normalize_strings>Yes</normalize_strings>
 
    <!-- Setting to suppress all metadata udpates (default: no) -->
    <no_updates>Yes</no_updates>
  </metadata>
 
  <decoders>
    <decoder>
      <name>MadPlay</name>
      <program>madplay -b 16 -R 44100 -S -o raw:- @T@</program>
      <file_ext>.mp3</file_ext>
    </decoder>
  </decoders>
</ezstream>

Ejecución

Para lanzar Ezstream utilizan un fichero de configuración previamente creado, por ejemplo, config-ezstream.xml tendríamos que ejecutar:

ezstream -c config-ezstream.xml