Differenze tra le versioni di "Streaming Audio e Terminale"
Da MontelLUG WIKI.
Riga 30: | Riga 30: | ||
</pre> | </pre> | ||
+ | == Icecast2 == | ||
Abilito il server icecast2 | Abilito il server icecast2 | ||
Riga 59: | Riga 60: | ||
/etc/init.d/icecast2 start | /etc/init.d/icecast2 start | ||
</pre> | </pre> | ||
− | + | ||
+ | == Ices2 == | ||
ices2: client per invio stream in ogg | ices2: client per invio stream in ogg | ||
Riga 325: | Riga 327: | ||
update-rc.d -f ices2 remove | update-rc.d -f ices2 remove | ||
</pre> | </pre> | ||
− | + | ||
+ | == TTYcast== | ||
Installazione sul server web di TTYCAST | Installazione sul server web di TTYCAST | ||
Riga 346: | Riga 349: | ||
Avvio ttycast | Avvio ttycast | ||
− | Soluzione 1 | + | = Soluzione 1 = |
<pre> | <pre> | ||
ssh root@serverweb | ssh root@serverweb | ||
Riga 367: | Riga 370: | ||
contro: bisogna lavorare in remoto | contro: bisogna lavorare in remoto | ||
− | Soluzione 2 | + | = Soluzione 2 = |
<pre> | <pre> | ||
mkfifo /tmp/ttycast && ttyplay -n /tmp/ttycast | ssh root@serverweb PORT=8081 ttycast | mkfifo /tmp/ttycast && ttyplay -n /tmp/ttycast | ssh root@serverweb PORT=8081 ttycast |
Versione delle 22:10, 8 lug 2013
Appunti su come configurare uno streaming audio tramite server esterno con accesso SSH - Distribuzione Debian 6.0.4
Impostare le variabili:
USER_SSH=nomeutente PASS_SSH=secret IP_SERVER=123.123.123.123 SERVER_NAME=my.radio.com PASS_ICECAST=icecast_password PASS_ADMIN_ICECAST=icecast2_password NOME_STREAM=miostream.ogg FILE_ATTESA=attesa.ogg #(da mettere nella dir /usr/share/icecast2/web ) ssh USER_SSH@IP_SERVER apt-get install debian-keyring debian-archive-keyring apt-get update apt-get upgrade apt-get install icecast2 ######### IP_SERVER=123.123.123.123 SERVER_NAME=deb2.carinato.net PASS_ICECAST=icecast_password! PASS_ADMIN_ICECAST=icecast2_password1! NOME_STREAM=miostream.ogg FILE_ATTESA=attesa.ogg #(da mettere nella dir /usr/share/icecast2/web ) #########
Icecast2
Abilito il server icecast2
sed -i "s/\(ENABLE *= *\).*/\1true/" /etc/default/icecast2
Modifico il file di configurazione di icecast2
sed -i "s|\(<source-password>\).*\(</source-password>\)|\1$PASS_ICECAST\2|" /etc/icecast2/icecast.xml sed -i "s|\(<relay-password>\).*\(</relay-password>\)|\1$PASS_ICECAST\2|" /etc/icecast2/icecast.xml sed -i "s|\(<admin-password>\).*\(</admin-password>\)|\1$PASS_ICECAST\2|" /etc/icecast2/icecast.xml sed -i "s|\(<hostname>\).*\(</hostname>\)|\1$SERVER_NAME\2|" /etc/icecast2/icecast.xml
Opzionale per file di intro
sed "/fileserve/i \\ <mount>\\ <mount-name>/${NOME_STREAM}</mount-name>\\ <username>source</username>\\ <password>${PASS_ICECAST}</password>\\ <fallback-mount>/${FILE_ATTESA}</fallback-mount>\\ <fallback-override>1</fallback-override>\\ </mount>" /etc/icecast2/icecast.xml /etc/init.d/icecast2 start
Ices2
ices2: client per invio stream in ogg
apt-get install ices2 alsa-utils
Verificare se servono altri pacchetti....
mkdir /var/log/ices mkdir /etc/ices2 mkdir -p /var/log/ices/audio cp /usr/share/doc/ices2/examples/ices-alsa.xml /etc/ices2/
imposto a 1 l'esecuzione in background
sed -i "s|\(<background>\).*\(</background>\)|\11\2|" /etc/ices2/ices-alsa.xml
Opzionale: metto a 1 il loglevel
sed -i "s|\(<loglevel>\).*\(</loglevel>\)|\11\2|" /etc/ices2/ices-alsa.xml
Modifico /etc/ices2/ices-alsa.xml
<pidfile>/var/run/ices2.pid</pidfile>
Modifico la parte stream del file /etc/ices2/ices-alsa.xml in questo modo
<stream> <!-- metadata used for stream listing --> <metadata> <name>$NOME_DELLO_STREAM</name> <genre>$NOME_DEL_GENERE</genre> <description>$DESCRPTION</description> <url>$URL_DELLA_PAGINA_WEB_DI_RIFERIMENTO</url> </metadata> <input> <module>alsa</module> <param name="rate">44100</param> <param name="channels">2</param> <param name="device">hw:1,0</param> <!-- 1,0 indica la seconda scheda audio, per noi quella esterna --> <!-- Read metadata (from stdin by default, or --> <!-- filename defined below (if the latter, only on SIGUSR1) --> <param name="metadata">1</param> <param name="metadatafilename">commandline</param> </input> <instance> <!-- Server details. You define hostname and port for the server here, along with the source password and mountpoint. --> <hostname>$SERVER_NAME</hostname> <port>8000</port> <username>source</username> <password>$PASS_ICECAST</password> <mount>/mountpoint.ogg</mount> <yp>0</yp> <!-- allow stream to be advertised on YP, default 0 --> <encode> <quality>0</quality> <samplerate>22050</samplerate> <channels>1</channels> </encode> <!-- stereo->mono downmixing, enabled by setting this to 1 --> <downmix>1</downmix> <!-- Salvo una copia dello stream --> <savefile>/var/log/ices/dump/lezione.ogg</savefile> <resample> <in-rate>44100</in-rate> <out-rate>22050</out-rate> </resample> </instance> </stream>
Creo un file per l'avvio di ices2 in automatico (utile per la raspberry quando non gestita)
vi /etc/init.d/ices2 Se e' montata una memoria usb in /media/usb con una cartella audio (/media/usb/audio) uso questa cartella per il salvataggio Altrimenti salvo lo stream in /var/log/ices/audio
########### #! /bin/sh ### BEGIN INIT INFO # Provides: ices2 # Required-Start: $local_fs $remote_fs # Required-Stop: $local_fs $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Ices2 initscript # Description: ### END INIT INFO # # Author: Leonardo Serra Maciel de Campos <linuxbh@brfree.com.br>. # # Version: @(#)ices2 2.0.1-5 16-Aug-2006 linuxbh@brfree.com.br # Do NOT "set -e" # PATH should only include /usr/* if it runs after the mountnfs.sh script PATH=/usr/sbin:/usr/bin:/sbin:/bin DESC="streaming source for Icecast 2" NAME=ices2 DAEMON=/usr/bin/$NAME PIDFILE=/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME #CONFIGFILE="/etc/ices2.xml" CONFIGFILE="/etc/ices2/ices-alsa.xml" # Exit if the package is not installed [ -x "$DAEMON" ] || exit 0 # Load the VERBOSE setting and other rcS variables [ -f /etc/default/rcS ] && . /etc/default/rcS # Define LSB log_* functions. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions # # Function that starts the daemon/service # do_start() { [ -d /media/usb/audio ] && AUDIO_DEST="/media/usb/audio" || AUDIO_DEST="/var/log/ices/audio" [ ! -d ${AUDIO_DEST}/archive ] && mkdir -p ${AUDIO_DEST}/archive [ -h /var/log/ices/dump ] && rm /var/log/ices/dump ln -s ${AUDIO_DEST} /var/log/ices/dump [ -f /var/log/ices/dump/lezione.ogg ] && mv /var/log/ices/dump/lezione.ogg ${AUDIO_DEST}/archive/$(printf "lezione_%02d.ogg" $(ls -1 ${AUDIO_DEST}/archive/ | wc -l)) echo "\nSalvataggio su ${AUDIO_DEST}" # Return # 0 if daemon has been started # 1 if daemon was already running # 2 if daemon could not be started start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ || return 1 start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- $CONFIGFILE\ $DAEMON_ARGS \ || return 2 # Add code here, if necessary, that waits for the process to be ready # to handle requests from services started subsequently which depend # on this one. As a last resort, sleep for some time. } # # Function that stops the daemon/service # do_stop() { # Return # 0 if daemon has been stopped # 1 if daemon was already stopped # 2 if daemon could not be stopped # other if a failure occurred start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME RETVAL="$?" [ "$RETVAL" = 2 ] && return 2 # Wait for children to finish too if this is a daemon that forks # and if the daemon is only ever run from this initscript. # If the above conditions are not satisfied then add some other code # that waits for the process to drop all resources that could be # needed by services started subsequently. A last resort is to # sleep for some time. start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON [ "$?" = 2 ] && return 2 # Many daemons don't delete their pidfiles when they exit. rm -f $PIDFILE return "$RETVAL" } # # Function that sends a SIGHUP to the daemon/service # do_reload() { # # If the daemon can reload its configuration without # restarting (for example, when it is sent a SIGHUP), # then implement that here. # start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME return 0 } case "$1" in start) [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" do_start case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; stop) [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" do_stop case "$?" in 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;; 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;; esac ;; #reload|force-reload) # # If do_reload() is not implemented then leave this commented out # and leave 'force-reload' as an alias for 'restart'. # #log_daemon_msg "Reloading $DESC" "$NAME" #do_reload #log_end_msg $? #;; restart|force-reload) # # If the "reload" option is implemented then remove the # 'force-reload' alias # log_daemon_msg "Restarting $DESC" "$NAME" do_stop case "$?" in 0|1) do_start case "$?" in 0) log_end_msg 0 ;; 1) log_end_msg 1 ;; # Old process is still running *) log_end_msg 1 ;; # Failed to start esac ;; *) # Failed to stop log_end_msg 1 ;; esac ;; *) #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 exit 3 ;; esac : #################
abilito l'avvio automatico di ices2
update-rc.d ices2 default
per disabilitare l'avvio automatico di ices2:
update-rc.d -f ices2 remove
TTYcast
Installazione sul server web di TTYCAST
Per Debian Wheezy, installo node.js
apt-get install python g++ make checkinstall build-essential mkdir ~/src && cd $_ wget -N http://nodejs.org/dist/node-latest.tar.gz tar xzvf node-latest.tar.gz && cd node-v* ./configure checkinstall #(remove the "v" in front of the version number in the dialog) dpkg -i node_* apt-get install ttyrec npm install -g ttycast
eventualmente modificare la pagina index.html presente in /usr/local/lib/node_modules/ttycast/static
Avvio ttycast
Soluzione 1
ssh root@serverweb export PORT=8081 ttyreccast myterminal.tty
su altro terminale locale:
ssh root@serverweb reset && ttyrec /tmp/ttycast
..e la pagina http://serverweb:8081 funziona
a fine lezione copiare il file myterminal.tty e cancellare /tmp/ttycast
pro: si ha la registrazione della lezione, non serve installare nulla in locale contro: bisogna lavorare in remoto
Soluzione 2
mkfifo /tmp/ttycast && ttyplay -n /tmp/ttycast | ssh root@serverweb PORT=8081 ttycast
su altro terminale locale:
ttyrec /tmp/ttycast
..e la pagina http://serverweb:8081 funziona
Io ho usato la porta 8081 perche' la predefinita di ttycast (13337) non era aperta nel mio server