Streaming de audio con Gnump3d

Estándar

Despues de varios intentos fallidos por montar un servidor de streaming de audio con icecast2 + ices2 he topado con Gnump3d y me ha encantado. Quizás no tenga la seguridad y potencia de icecast pero a mi me ha ido de perlas.

Instalación en Ubuntu y Debian:

neil@Engendro:/$ apt-get install gnump3d

Dificil eh?!! XD

Configuración:

neil@Engendro:/$sudo gedit /etc/gnump3d/gnump3d.conf

El archivo de configuración se explica solito aún asi voy a comentar las lineas que yo he cambiado:

Básicamente por pura conveniencia he cambiado el puerto.

# You may use a low port, for example 80, if you are running
# as root – but that is only recommended if you make use of
# the `user’ option, which occurs later in this file.
#
port = 1111

También he especificado la dirección desde la que es accesible el servidor

# Set the hostname that is used in all the generated links.
#
# (This defaults to the name of the server machine, with no
# domain suffix).
#
# You won’t need this unless the machine which is serving on
# MUST be accessed via its fully qualified domain name – for
# example if you’re running it on a machine which is accessible
# to the world.
#
# NOTE
######
#
# See `binding_host’ if you have a machine which has multiple
# IP addresses and you’re trying to bind to one in particular.
#
hostname = neil.apalankada.net
#

El directorio donde estan las canciones a servir:

# The root directory where we serve content from, this should be
# the directory containing the MP3, OGG, or other media files that
# you wish to share.
#
# Obviously the files which you wish to serve should be accessible
# to the user who this server is running as – which is set via the
# ‘user’ setting below.
#
# If you’re on a multi-user system its probably a good idea to
# make the audio files readable to other users anyway, share the
# musical goodness!
#
root = /home/neil/musi

He especificado el usuario (neil) con el que quiero que se ejecute el programa, aunque lo mejor hubiera sido crear un usuario y darle los permisos de solo lectura en el directorio de las canciones.

##
# SECURITY OPTIONS.
####

#
# If there is a user value setup below then the server will become that
# user, after creating the listening socket and after opening the logfiles
# for writing.
#
# If you want to run this server via init.d, (which has the effect of
# starting the daemon as root), you should make sure you have this set
# to an appropriate value.
# Otherwise you will have the server running as root, which is clearly
# not a good idea – even in the unlikely event that this application is
# 100% bug free.
#
# You may comment the line out if you are running the daemon from your home
# directory, and you are the only user with read access to the server root.
# Although this is not recommended way of running the server.
#
# For the benefit of fellow computer users is recommended that you run the
# server as a user such as ‘nobody’, and allow people read-only access to
# your audio files.
#
user = neil

He especificado a quien debe escuchar el servidor, en mi caso a todas las peticiones vengan de donde vengan.

allowed_clients = all

Con esta opcion me aseguro de que nadie me enlaza desde otro servidor:

##
#
# Referrer check
#
##
#
# The last security option is the ability to block clients that don’t
# contain a specific ‘Referrer:’ header.
#
# Note that referrer protection isn’t terribly reliable, as many clients
# will not send a referrer header when making a connection. This is
# especially likely when clients are connecting via a ‘privacy enhancing’
# proxy server; such as Internet Junkbuster, etc.
#
# Similarly malicious clients may deliberately stop sending referrers
# if they realise what is going on.
#
#
#
###
# If you wish to only allow a particular referring URL then specify it
# here.
valid_referrers = https://blog.menoscuatro.com/

Activo el recodificado «downsampling» para no dejarme el ancho de banda con el invento:

##
# DOWNSAMPLING / BIT RATE CHANGE
##
#
# This support allows the music to be down-sampled before it is streamed
# to clients. This will slow down the serving, and may be a little
# processor intensive – I guess it will depend upon the speed of your
# server, and the number of users you have.
#
##
#
# Is downsampling support enabled?
#
# If this is disabled then none of the further downsampling options will
# apply, even if they are set.
#
# Also note that if the downsampling support is disabled the preferences
# page will not allow the clients to select their own bitrate.
#
# (I think this makes sense, if it’s disabled it’s misleading to present
# configuration options to the clients).
#
downsample_enabled = 1
#

Establezco que se debe recodificar el sonido para las peticiones externas (internet) pero no para las de mi propia red local:

downsample_clients = ALL
no_downsample_clients = 192.168.1.0/24

Especifico los bitrates de recodificado para los distintos tipos de calidad:

downsample_high_mp3 = /usr/bin/lame –mp3input -b 56 $FILENAME –
downsample_medium_mp3 = /usr/bin/lame –mp3input -b 32 $FILENAME –
downsample_low_mp3 = /usr/bin/lame –mp3input -b 16 $FILENAME –

Como no quiero que me fastidien demasiado establezco que por defecto la calidad sea la mas baja:

# If you always want to force a particular bitrate upon clients who’ve
# not chosen something different then specify it here:
#
default_quality = low

Y ahora solo queda guardar el archivo e iniciar el daemon:

neil@Engendro:/$sudo /etc/init.d/gnump3d start

Y para probar el tema solo hay que ir a la dirección que hemos especificado junto con el puerto, en mi caso https://blog.menoscuatro.com:1111

Una curiosidad más, si quereis que vuestro servidor pida password tan solo tendreis que crear un archivo de nombre .password en el directorio donde tengais las canciones. El contenido deberá ser en formato usuario:password , un usuario y password por lí­nea. Aunque este método no es demasiado seguro según la propia documentación de Gnump3d.

He dicho que hace streams de mp3 y ogg? No? Pues ya lo sabeis 😉
Si leeis la documentación encontrareis un montón de features más.

NeiL

10 comentarios en “Streaming de audio con Gnump3d

  1. Gerard

    http://www.jinzora.org/pages.php?pn=products&sub=cost
    ——————–

    How much does Jinzora cost?

    Nothing. Nada. Zip, Zlich, Zero.

    Jinzora is released under the GNU GPL and is completely free and open source. This means that you can use Jinzora in almost any way you would like completely free.

    However we do hope you’ll consider donating to Jinzora. We spend countless hours of work on Jinzora, and if you are enjoying what we are doing please consider donating to Jinzora. Donating to Jinzora keeps us working hard on Jinzora so that we can continue to bring you the most powerful web-based media management solution anywhere.

  2. Bueno, mi gran sorpresa ha sido al abrir el INSTALL.TXT :

    Requirements

    * php 4.2.0 or later (4.3.0 or later HIGHLY recommended)
    * MySQL 3.23.32 or later (not required but HIGHLY recommended)
    * Apache or IIS (other webserver may work but are not supported)

    No tengo Apache, ni mysql ni php instalado y la verdad es que me da pereza instalarlo solo para esto. Gnump3d lleva un servidor web ligero incorporado con lo cual me soluciona la papeleta de una forma mucho mas rapida y sencilla. De todas formas Jinzora pinta muy muy bien, tiene muchas features 🙂
    Gracias de nuevo por el enlace.

  3. rc4nob0

    lo que no me gusto es que puedes bajarte el mp3 a tu pc, imposibilitando de configurarlo para solo servir el streaming, con un simple wget pude bajarme a mi pc todo el repositorio, no encontre la manera de evitar esto.

  4. rc4nob0, eso es un fallo conocido del gnump3d, si sabes la url exacta del archivo podras bajarlo. Hay una forma de que pida contraseña pero me temo que si tienes la url exacta no te la pide. Solo la pide para acceder al listado del repositorio. Todo esto esta en la documentacion del gnump3d.
    Saludos!

Responder a NeiL Cancelar la respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Este sitio usa Akismet para reducir el spam. Aprende cómo se procesan los datos de tus comentarios.