Radioleve - Configuração alternativa para web rádios

Como ouvir a RadioLeve

Se você não consegue ouvir a RadioLeve então pode ser que no seu computador não tenha nenhum player compatível com o codec livre de patente Ogg Vorbis. Baixe e instale o VLC Media Player abaixo para resolver esse problema.

Clic aqui para baixar o VLC Media Player

Clic aqui para informações adicionais sobre o VLC Media Player

Para outros detalhes, siga o link como tocar arquivos ogg vorbis.

Depois de instalar o VLC Media Player em seu computador (no caso do MS Windows XP) você pode copiar a linha abaixo:


"C:\Arquivos de programas\VideoLAN\VLC\vlc.exe" http://icecast.ufba.br:8000/radioleve.ogg

Ou caso seu MS Windows seja em inglês:

"C:\Program Files\VideoLAN\VLC\vlc.exe" http://icecast.ufba.br:8000/radioleve.ogg

E colar no menu Iniciar --> Executar para ouvir a RadioLeve.

Você também pode tocar a RadioLeve executando diretamente o VLC Media Player. Vá no menu Arquivo --> Open Network Stream --> Selecione a opção HTTP e cole o link da RadioLeve no campo URL.

Link da RadioLeve:

http://icecast.ufba.br:8000/radioleve.ogg

Características da solução de web rádio baseada no software livre Ices2

Antes de começar...

Realizei todos os testes utilizando um computador configurado com Debian GNU/Linux, sendo que o subsistema de som integrado na placa-mãe foi configurado com o alsaconf.

Instalação do Ices2

Execute o comando:

apt-get install ices2

Pronto. Ices2 instalado.

Arquivos de configuração do Ices2

Abaixo seguem exemplos de arquivos de configuração do Ices2 trabalhando com o Icecast2 para tocar uma playlist e para fazer transmissão ao vivo gravando no disco local. É preciso editar os parâmetros hostname e password em cada arquivo para a conexão com o servidor icecast2 de sua preferência. Esses arquivos estão disponíveis para download no final dessa página. (Falta traduzir e ampliar os comentários desses arquivos)

Playlist


<?xml version="1.0"?>
<ices>
    <!-- run in background -->
    <background>0</background>
    <!-- where logs, etc go. -->
    <logpath>.</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>./ices.pid</pidfile> -->

    <stream>
        <!-- metadata used for stream listing (not currently used) -->
        <metadata>
            <name>RadioLeve</name>
            <genre>Desenvolvimento</genre>
            <description>Configuracao leve para ser adicionada a configuracoes de desktops</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">./playlist.txt</param>
            <!-- random play -->
            <param name="random">0</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>xxxxxxxxxxx</hostname>
            <port>8000</port>
            <password>xxxxxx</password>
            <mount>/radioleve.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>32000</nominal-bitrate> <!-- bps. e.g. 64000 for 64 kbps -->
                <samplerate>11025</samplerate>
                <channels>1</channels>
            </encode>
        </instance>

   </stream>
</ices>

Transmissão ao vivo


<?xml version="1.0"?>
<ices>
    <!-- run in background -->
    <background>0</background>
    <!-- where logs, etc go. -->
    <logpath>.</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>./ices.pid</pidfile> -->

    <stream>
        <!-- metadata used for stream listing (not currently used) -->
        <metadata>
            <name>RadioLeve</name>
            <genre>Desenvolvimento</genre>
            <description>Configuracao leve para ser adicionada a configuracoes de desktops</description>
        </metadata>

        <!--    Input module.

            This example uses the 'alsa' module. It takes input from the
            audio device (e.g. line-in), and processes it for live
            encoding.  -->
        <input>
            <module>alsa</module>
            <param name="rate">48000</param>
            <param name="channels">2</param>
            <param name="device">hw:0,0</param>
            <!-- Read metadata (from stdin by default, or -->
            <!-- filename defined below (if the latter, only on SIGUSR1) -->
            <param name="metadata">1</param>
            <param name="metadatafilename">test</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>xxxxxxxxxxx</hostname>
            <port>8000</port>
            <password>xxxxxxx</password>
            <mount>/radioleve_aovivo.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>32000</nominal-bitrate> <!-- bps. e.g. 64000 for 64 kbps -->
                <samplerate>11025</samplerate>
                <channels>1</channels>
            </encode>


            <downmix>1</downmix>


            <resample>
                <in-rate>48000</in-rate>
                <out-rate>11025</out-rate>
            </resample>

      <savefile>./gravacao_transmissao01.ogg</savefile>


    </instance>

      </stream>
</ices>

Exemplo de lista de músicas (playlist.txt)

Para gerar esse arquivo a partir de sua coleção de músicas em formato ogg vorbis guardadas na pasta musicas_ogg execute o comando:

find  musicas_ogg/  >  playlist.txt


musicas_ogg/musica01.ogg
musicas_ogg/musica02.ogg
musicas_ogg/musica03.ogg

Iniciando uma transmissão de web rádio com o Ices2

ices2  ices2_config_playlist.xml

Acesse a página de administração do seu servidor icecast2 e verifique o link "radioleve". Copie esse link no VLC Media PLayer e escute a transmissão. As músicas listadas no arquivo playlist.txt serão executadas. Para interromper a transmissão basta pressionar a combinação de teclas CRTL+C no terminal onde o ices2 estiver sendo executado.

ices2  ices2_config_transmissao.xml

Pode ser preciso ajustar o volume do microfone com o mixer de sua preferência. Sugerimos o alsamixer em um terminal. Acesse a página de administração do seu servidor Icecast2 e verifique o link radioleve_aovivo. Copie esse link no VLC Media PLayer e escute a transmissão. A transmissão ao vivo será gravada no arquivo gravacao_transmissao01.ogg.

Importante Renomear esse arquivo ao final de cada transmissão, pois quando for iniciada uma nova transmissão ele será sobrescrito.

ATENÇÃO: Os comandos devem ser rodados dentro da pastas com o arquivo de configuração e/ou playlist relativa. A playlist contém o caminho para as músicas que a compõe, por isso, use do comando find para criar a playlist a partir da pasta na qual o ices2 deve ser chamado.

Múltiplas instâncias do Ices2 em um mesmo computador

É possível ter mais de uma rádio transmitindo em um mesmo computador. Basta abrir um novo terminal e executar os comandos já vistos. Entretando é necessário editar os arquivos de configuração para que não sejam utilizados os mesmos nomes para os pontos de montagem no servidor icecast2. Se a primeira instância do ices2 usa o ponto de montagem /radioleve então outra instância pode usar /radioleve_clone01. E assim por diante.

Obs.: Essa documentação ainda está em fase inicial. Todas as contribuições para sua melhoria são benvindas.

Organização dos stream e músicas da Rádio FACED Web

Na máquina da Rádio Faced Web, no home do usuário rádio, foi criado a pasta programacao, e dentro dela as pastas musicaEvinheta e programasEvinhetas, para facilitar a criação das playlists para o multi-stream. As músicas são organizadas de acordo a sua licença, se é CC ou se apenas temos permissão de uso. Lembre que não usamos músicas comerciais sem autorização.

Também na home do usuário rádio, foi criada a pasta configuracaoIces2. A partir dela encontram-se as pastas aovivo, playlist e playlistGeral. Nelas se encontram os arquivos XML de configuração do ices2 para cada stream gerado e sua playlist. Os arquivos de log também estão em sua devida pasta.

O terminal com os comandos de geração dos 3 streams se encontram na segunda área de trabalho, para que os trabalhos na máquina da rádio não derrubem a rádio. Para facilitar apenas use a memória do terminal para escolher os comandos (seta direcional para cima). O terminal com o comando para s transmissão ao vivo (o primeiro) fica apenas em espera por um evento que o use.

Referências para mixagem de áudio via software usando ALSA em computadores de baixo custo

http://alsa.opensrc.org/index.php/Hardware_mixing%2C_software_mixing

http://wiki.flightgear.org/flightgear_wiki/index.php?title=Linux_software_audio_mixing_with_FlightGear

http://gentoo-wiki.com/HOWTO_ALSA_sound_mixer_aka_dmix

http://buglandia.blogspot.com/2007/08/howto-software-audio-mixing-in-ubuntu.html

http://fedoranews.org/contributors/andre_costa/alsa/

Arquivo .asound que reconfigura o ALSA para fazer mixagem de som via software na hora de gravar e tocar

O arquivo .asound deve ser criado no diretório do usuário que vai fazer a transmissão de rádio (o que executa o ices2). A mixagem de som só vai estar ativada para esse usuário.


pcm.my_card {
    type hw
    card 0
    # mmap_emulation true
}

pcm.dmixed {
    type dmix 
    ipc_key 1024 
    #  ipc_key_add_uid false   # let multiple users share
    #  ipc_perm 0666           # IPC permissions for multi user sharing (octal, default 0600)
    slave {
    pcm "my_card" 
    #   rate 48000
    #   period_size 512
    }
}

pcm.dsnooped {
    type dsnoop 
    ipc_key 2048 
    slave {
    pcm "my_card" 
    #   rate 48000
    #   period_size 128
    }
}

pcm.asymed {
    type asym 
    playback.pcm "dmixed" 
    capture.pcm "dsnooped"
}

pcm.pasymed {
    type plug 
    slave.pcm "asymed"
}

pcm.dsp0 {
    type plug
    slave.pcm "asymed"
}

pcm.!default {
    type plug
    slave.pcm "asymed"
}


Configuração do alsamixer

Essa parte pode depender da forma como o kernel do GNU/Linux (ALSA) atribui os nomes dos dispositivos do subsistema de som.

http://en.wikipedia.org/wiki/Alsamixer

http://alsa.opensrc.org/index.php/Alsamixer

http://linux.die.net/man/1/aplay

http://linux.die.net/man/1/alsamixer

http://linux.die.net/man/1/amixer

http://linux.die.net/man/8/alsaconf

http://linux.die.net/man/1/alsactl


-- HilbertoCosta - 19 Dez 2009

Editar Anexar Versões Mais...

TableLess - Coerência, Simplicidade e Acessibilidade no código HTML TWiki - Ambiente Web Colaborativo
última revisão: r17 - 19 Feb 2010 - 14:08:20 - HilbertoCosta?     |     Copyleft Faced-UFBA