User Tools

Site Tools


pages:nomades:clients_stream

Captations numériques ou de procéssus

Clients pour le streaming

ICES

L'application cliente ices permet d'envoyer un flux sur un serveur de streaming icecast2 dans une sortie jack.

Les sources sont la, regardez si il à d'autre version sur le site de karl

prérequis:

Sur la distribution Mandrake cela donne pour urpmi libshout3-devel libxml2-devel libogg0-devel libvorbis0-devel ou regardez la page sur icecast2 pour les sources de ogg vorbis et speex

cd /usr/src
wget http://mediacast1.com/~karl/ices-2.0-kh60.tar.bz2
bunzip2 ices-2.0-kh60.tar.bz2
tar xvf ice-2*
cd ices-2*
./configure --prefix=/usr;make;make install
cp conf/ices-jack.xml /etc

Faites les modifications dans le fichier /etc/ices-jack.xml selon l'utilisateur qui lance jackd :

<user>ices</user>
en 
<user>root</user>

selon le serveur ou vous pointer

<shout>
<hostname>localhost</hostname>
<port>8000</port>
<password>hackme</password>
<mount>/example1.ogg</mount>
</shout>

le lancement de la chose

#jackd -d alsa -r 44100
ices /etc/ices-jack.xml

notez que jackd est en commentaire, dans mon cas, j'utilise qjackctl pour le superviser, Une sortie ices apparait, sur laquelle on peut se connecter ;-)

Script de lancement

Voila le script ices_cream

#!/bin/bash
# ices_cream host port passwd mount channels stream_name stream_genre stream_descrpt path_archiv
#
 
###on test quelque entrees
 
if [ -z "$1" ] ;then echo "no host" ; exit 1;fi
host=$1
if [ -z "$2" ] ;then echo "no port" ; exit 2 ;fi
port=$2
if [ -z "$3" ] ;then echo "no password" ; exit 3 ;fi
password=$3
if [ "$4" ] ;then mount=$4;else mount="exemple_ogg"    ;fi
if [ "$5" ] ;then
                if [ $5 -gt 10 ] ;then
                                echo "bad number of channel"
                                exit 4
                fi
                channels=$5
else
                channels=2
fi
if [ "$6" ] ;then stream_name=$6;else stream_name="exemple stream"    ;fi
if [ "$7" ] ;then stream_genre=$7;else stream_genre="genre stream"   ;fi
if [ "$8" ] ;then stream_descrpt=$8;else stream_descrpt="stream description" ;fi
 
###on fabrique le fichier xml
 
echo '<?xml version="1.0"?>
<ices>
    <background>0</background>
   <mount>'$mount'</mount>
    <realtime>0</realtime>
   <user>root</user>
    <logpath>/tmp</logpath>
    <logsize>2048</logsize>
    <logfile>ices.log</logfile>
    <loglevel>4</loglevel>
    <consolelog>0</consolelog>
    <pidfile>/var/ices/ices.pid'$$'</pidfile>
        <stream>
        <name>'$stream_name'</name>
        <genre>'$stream_genre'</genre>
        <description>'$stream_descrpt'</description>
                <input>
                        <module>jack</module>
                        <param name="channels">'$channels'</param>
                        <param name="clientname">ices</param>
          <!---         <param name="connect">alsa_pcm:capture_1,alsa_pcm:capture_2</param> -->
                        <param name="metadatafilename">metadata</param>
                </input>
        <runner>
            <instance>
                <name>test transmission</name>
                <genre>various</genre>
                <description>low bandwidth stream</description>
                <shout>
                    <hostname>'$host'</hostname>
                    <port>'$port'</port>
                    <password>'$password'</password>
                    <mount>'$mount'</mount>
                    </shout>
 
                <!--
                <resample>
                    <out-rate>22050</out-rate>
                </resample>
                -->
 
                <!--
                <downmix>1</downmix>
                -->
                <encode>
                    <quality>1.1</quality>
                </encode>
            </instance>
'>/tmp/ices_trv.xml
if [ "$9" ] ;then
        path_archiv=$9
            echo '<instance>
                <encode>
                    <quality>1.1</quality>
                </encode>
                <savestream>
                    <filename>'$path_archiv'/%X/stream-%M.ogg</filename>
 
                    <fmask>0600</fmask>
                    <dmask>0700</dmask>
                    <duration>7200</duration>
                    <on-metadata>1</on-metadata>
                    <reset-time>0</reset-time>
                </savestream>
            </instance>
        '>>/tmp/ices_trv.xml
fi
echo '
        </runner>
        </stream>
</ices>
'>>/tmp/ices_trv.xml
 
### on lance ices
 
rm -f -f /var/ices/ices.pid'$$'
ices /tmp/ices_trv.xml &
 
### on test si la glace a fondue
 
[ -f /var/ices/ices.pid'$$' ]; then 
    echo "ok"
else
    echo "down"
fi
 
##########################

il s'utilise de la manière suivante: ices_cream host port passwd mount channels stream_name stream_genre stream_descrpt path_archiv

ou en version minimale

ices_cream host port passwd mount

Ce qui revient à lancer un client ices sur le serveur host, port,mote de passe et point de montage défini, sur 2 canaux sans archivage. A vous d'y connecter une sortie d'un autre client de jackd, par exemple xmms.

Vous pouvez lancer plusieurs instance de ices , faites attention à changer les points de montage.

Documentation Ices (Eng)

Config File

The ices 2 configuration file is in XML format, which is described in detail below. There are some sample XML files provided in the distribution under the conf directory which show the main way ices is used.

live audio streaming, takes audio from the soundcard which can be captured from say the Mic, line-In, CD or a combination of these. ices-oss.xml ices-alsa.xml

Playlist audio streaming, takes pre-encoded Ogg Vorbis files and either sends them as-is or re-encodes them to different settings

ices-playlist.xml

General layout

    <?xml version="1.0"?>
    <ices>
        general settings
        stream section
    </ices>

General settings

These apply to IceS as a whole. The example below gives a useful example to work to

     <background>0</background>
     <logpath>/var/log/ices</logpath>
     <logfile>ices.log</logfile>
     <logsize>2048</logsize>
     <loglevel>3</loglevel>
     <consolelog>0</consolelog>
     <pidfile>/var/log/ices/ices.pid</pidfile>

background

Set to 1 if you want IceS to put itself into the background.

logpath

A directory that can be written to by the user that IceS runs as. This can be anywhere you want but as log files are created, write access to the stated must be given.

logfile

The name of the logfile created. On log re-opening the existing logfile is renamed to <logfile>.1

logsize

When the log file reaches this size (in kilobytes) then the log file will be cycled (the default is 2Meg)

loglevel

A number that represents the amount of logging performed. 1 - Only error messages are logged 2 - The above and warning messages are logged 3 - The above and information messages are logged 4 - The above and debug messages are logged

consolelog

A value of 1 will cause the log messages to appear on the console instead of the log files. Setting this to 1 is generally discouraged as logs are cycled and writing to screen can cause stalls in the application, which is a problem for timing critical applications.

pidfile

State a filename with path to be created at start time. This file will then contain a single number which represents the process id of the running IceS. This process id can then be used to signal the application of certain events.

Stream section

This describes how the input and outgoing streams are configured.

     <stream>
         Metadata
         Input
         Instance
     </stream>

Metadata

     <metadata>
         <name>My Stream</name>
         <genre>Rock</genre>
         <description>A short description of your stream</description>
         <url>http://mysite.org</url>
     </metadata>

This section describes what metadata information is passed in the headers at connection time to icecast. This applies to each instance defined within the stream section but maybe overridden by a per-instance <metadata> section.

Input

This section deals with getting the audio data into IceS. There are a few ways that can happen. Typically it's either from a playlist or via a soundcard.

The layout is consistent between the different input modules. Within the input section a module tag is needed to identify the module in question. The rest are made up of param tags specific to the module. There can be several param tags supplied to a module. Details of the module parameters are shown later.

Instance

Multiple instances can be defined to allow for multiple encodings, this is useful for encoding the same input to multiple bitrates. Each instance defines a particular set actions that occur on the passed in audio. Any modifications to the input data is isolated to the instance.

     <instance>
        hostname
        port

        password
        mount
        yp
        resample
        downmix
        savefile
        encode
     </instance>

hostname

State the hostname of the icecast to contact, this can be a name or IP address and can be ipv4 or ipv6 on systems that support IPv6. The default is localhost.

port

State the port to connect to, this will be the port icecast is listening on, typically 8000 but can be any.

password

For providing a stream, a username/password has to be provided, and must match what icecast expects.

mount

Mountpoints are used to identify a particular stream on a icecast server, they must begin with / and for the sake of certain listening clients should end with the .ogg extension.

yp

By default streams will not be advertised on a YP server unless this is set, and only then if the icecast if configured to talk to YP servers.

Resample

    <resample>
        <in-rate>44100</in-rate>
        <out-rate>22050</out-rate>
    </resample>

When encoding or re-encoding, there is a point where you take PCM audio and encode to Ogg Vorbis. In some situations a particular encoded stream may require a lower samplerate to achieve a lower bitrate. The resample will modifiy the audio data before it enters the encoder, but does not affect other instances.

The most common values used are 48000, 44100, 22050 and 11025, and is really only used to resample to a lower samplerate, going to a higher rate serves no purpose within IceS.

Downmix

  <downmix>1</downmix>
 

Some streams want to reduce the bitrate further, reducing the number of channels used to just 1. Converting stereo to mono is fairly common and when this is set to 1 the number of channels encoded is just 1. Like resample, this only affects the one instance it's enabled in.

Savefile

  <savefile>/home/ices/dump/stream1.ogg</savefile>
 

Sometimes the stream transmitted wants to be saved to disk. This can be useful for live recordings.

encode

    <encode>  
        <quality>0</quality>
        <nominal-bitrate>65536</nominal-bitrate>
        <maximum-bitrate>131072</maximum-bitrate>
        <minimum-bitrate>-1</minimum-bitrate>
        <managed>0</managed>
        <samplerate>22050</samplerate>
        <channels>1</channels>
        <flush-samples>11000</flush-samples>
    </encode>

quality

State a quality measure for the encoder. The range goes from -1 to 10 where -1 is the lowest bitrate selection (default 3), and decimals can also be stated, so for example 1.5 is valid. The actual bitrate used will depend on the tuning in the vorbis libs, the samplerate, channels and the audio to encode. A quality of 0 at 44100hz and 2 channels is typically around the 64kbps mark.

nominal-bitrate

State a bitrate that the encoder should try to keep to. This can be used as an alternative to selecting quality.

managed

State 1 to enable full bitrate management in the encoder. This is used with nominal-bitrate, maximum-bitrate and minimum-bitrate to produce a stream with more strict bitrate requirements. Enabling this currently leads to higher CPU usage.

maximum-bitrate

State bitrate in bits per second to limit max bandwidth used on a stream. Only applies if managed is enabled.

minimum-bitrate

State bitrate in bits per second to limit minimum bandwidth used on a stream. Only applies if managed is enabled, this option has very little use so should not really be needed.

samplerate

State the samplerate used for the encoding, this should be either the same as the input or the result of the resample. Getting the samplerate wrong will cause the audio to be represented wrong and therefore sound like it's running too fast or too slow.

channels

State the number of channels to use in the encoding. This will either be the number of channels from the input or 1 if downmix is enabled.

flush-samples

This is the trigger level at which Ogg pages are created for sending to the server. Depending on the bitrate and compression achieved a single ogg page can contain many seconds of audio which may not be wanted as that can trigger timeouts.

Setting this to the same value as the encode samplerate will mean that a page per second is sent, if a value that is half of the encoded samplerate is specified then 2 ogg pages per second are sent.

pages/nomades/clients_stream.txt · Last modified: 2015/08/30 22:55 by 127.0.0.1