Come creare una web radio con Linux e Shoutcast (guida avanzata)
marzo 11, 2007 1:47 pm
Ventisettesimo articolo dedicato alle web radio.
C’eravamo lasciati facendo partire (nel migliore dei casi) la nostra web radiolina in ambiente linux. Senza però scendere nei particolari dovuti ad errori, a come fare dirette radiofoniche, a come trasmettere playlist, a come insomma avere tutti gli strumenti che avevamo con windows.
Devo essere obiettivo, in ambiente linux ci sono delle limitazioni, che sono aggirabili, ma che possono inibire l’utente medio.
Cominciamo dal Server, studieremo il file sc_serv.conf:
Il file sc_serv.conf è un file di configurazione, vediamo cosa contiene al suo interno.
; SHOUTcast Distributed Network Audio Server configuration file
; Copyright (C) 1998-2004 Nullsoft, Inc.
; All Rights Reserved.
; Last modified Mar 17 2004; If you want to manage multiple configurations, just copy
; this file to another name, and run sc_serv with that name
; such as:
; sc_serv.exe sc_leet.conf
Premessa: In questo file ogni riga che comincia con un punto e virgola è un commento. Detto ciò, questa prima parte, è una presentazione e un avviso della possibilità di manipolare più file di configurazione. E questa è cosa buona e giusta
; MaxUser. The maximum number of simultaneous listeners allowed.
; Compute a reasonable value for your available upstream bandwidth (i.e. if
; you have 256kbps upload DSL, and want to broadcast at 24kbps, you would
; choose 256kbps/24kbps=10 maximum listeners.) Setting this value higher
; only wastes RAM and screws up your broadcast when more people connect
; than you can support.
MaxUser=32
Questa sezione permette di modificare l’upper bound di utenze contemporanee. Ovvero quanti utenti potrete avere al massimo. Scegliete con oculatezza, inutile settare un limite alto se non lo raggiungerete mai.
; Password. While SHOUTcast never asks a listener for a password, a
; password is required to broadcast through the server, and to perform
; administration via the web interface to this server. This server should
; consist of only letters and numbers, and is the same server your broadcaster
; will need to enter in the SHOUTcast Source Plug-in for Winamp. THIS VALUE
; CANNOT BE BLANK.
Password=changeme
Questa sezione permette di modificare la password del server, sceglietene una complicata, in quanto è molto semplice sniffarla. Se poi non la cambiate, ricordate che la password di default la conoscono tutti, e conoscendola, non ci vuole nulla a fare seri danni. Io stesso una volta sono entrato nel pannello di amministrazione avanzato di una radio beccata a caso, e devo dire che mi sono divertito a vedere i loro file log e quello che facevano.. Ho un etica, non ho creato danni, ma avrei potuto farlo.
; PortBase. This is the IP port number your server will run on. The
; value, and the value + 1 must be available. If you get a fatal error when
; the DNAS is setting up a socket on startup, make sure nothing else on the
; machine is running on the same port (telnet localhost portnumber — if you
; get connection refused then you’re clear to use that port). Ports < 1024
; may require root privledges on *nix machines. The default port is 8000.PortBase=8000
La porta che utilizzerete per trasmettere.. Scegliete a piacere, con un valore sopra 1024
; LogFile: file to use for logging. Can be ‘/dev/null’ or ‘none’
; or empty to turn off logging. The default is ./sc_serv.log
; on *nix systems or sc_serv_dir\sc_serv.log on win32.
; Note: on win32 systems if no path is specified the location is
; in the same dir as the executable, on *nix systems it is in the
; current directory.
LogFile=sc_serv.log
In questa sezione si setta il nome del file di log. Siamo in ambiente unix, quindi posso dirvi che non mettendo nessun nome, non si avrà file di log, mentre non settando una directory, si avrà il posizionamento nella directory corrente.
; RealTime displays a status line that is updated every second
; with the latest information on the current stream (*nix and win32
; console systems only)
RealTime=1
Settando ad uno questa impostazione, avrete una “status line” con le informazioni sullo stream in corso, aggiornata ogni secondo. Comoda, sempre utilizzata, ma consuma. Se siete minimalisti, potreste anche staccarla settandola a 0.
; ScreenLog controls whether logging is printed to the screen or not
; on *nix and win32 console systems. It is useful to disable this when
; running servers in background without their own terminals. Default is 1
ScreenLog=1
Impostazioni di sicurezza in caso di server esterni, disabilita il controllo dei log dallo schermo, nel pannello di amministrazione avanzato.
; ShowLastSongs specifies how many songs to list in the /played.html
; page. The default is 10. Acceptable entries are 1 to 20.
ShowLastSongs=10
Setta il numero di canzoni che si vedranno nella dietrologia della radio. Ovvero nel file http://vostroip:numeroporta/played.html. Si possono settare da 1 a 20 canzoni massimo.
; TchLog decides whether or not the DNAS logfile should track yp
; directory touches. Adds and removes still appear regardless of
; this setting.
; Default is yes
; TchLog=yes
Come potete vedere questa opzione è commentata. Questa opzione permette di eliminare nei file di log i TOUCH che si hanno periodicamente dal server delle pagine gialle di shoutcast. Io consiglio di mantenerla a yes, ma obiettivamente per file log molto lunghi in caso di trasmissioni continuate, può essere un mezzo comodo per togliere informazioni inutili.
; WebLog decides whether or not hits to http:// on this DNAS will
; be logged. Most people leave this off because the DSP plug-in
; uses http:// calls to update titles and get the listener count,
; which takes up a lot of log space eventually. If you want to
; see people making hits on your admin.cgi or index pages, turn
; this back on. Note that this setting does NOT affect XML stats
; counters for hits to http:// pages.
; Default is no.
; WebLog=no
Anche questa opzione è commentata.. Questa opzione permette di visualizzare nei log anche chi accede al vostro pannello di amministrazione. E’ un opzione impostata a no di default. Se volete un controllo maggiore, abilitatela, ma i vostri log aumenteranno notevolmente di volume.
; W3CEnable turns on W3C Logging. W3C logs contain httpd-like accounts
; of every track played for every listener, including byte counts those listeners
; took. This data can be parsed with tools like Analog and WebTrends, or given
; to third parties like Arbitron and Measurecast for their reporting systems.
; Default is Yes (enabled).
W3CEnable=Yes
Questa opzione abilita il Logging W3C, ovvero si abilita un log che tiene conto delle canzoni ascoltate da ciascun ascoltatore, dei byte trasmessi e di altre info, tutte ovviamente in un formato http-like. E’ settato a yes di default.
; W3CLog describes the name of the logfile for W3C logging. Default logfile is
; sc_w3c.log, in the same directory wherever the DNAS gets started from.
W3CLog=sc_w3c.log
Indica la posizione del file di log W3C.
; SrcIP, the interface to listen for source connections on (or to make relay
; connections on if relaying). Can and usually will be ANY or 127.0.0.1
; (Making it 127.0.0.1 will keep other machines from being able to
; broadcast using your shoutcast server )
SrcIP=ANY
Questa opzione seleziona l’ip che può trasmettere dal vostro server. Di default è ANY, ovvero tutti possono utilizzare il vostro server per streammare. Se settate 127.0.0.1 verrà mantenuta la possibilità per tutti di effettuare streaming dal vostro server. Settate un ip particolare, per avere una sola fonte possibile di streaming.
; DestIP, IP to listen for clients on (and to contact yp.shoutcast.com)
; can and usually will be be ANY. If your machine has multiple IP addresses,
; set this to the one you want it to be accessed by.
DestIP=ANY
Al contrario di quello che si crede, questa opzione non permette di selezionare quali client possono ascoltarvi, ma seleziona quale ip sarà raggiungibile connettendosi a quel server. DI solito si setta ad ANY proprio perchè cosi avete la possibilità di connettervi a qualsiasi macchina utilizzi il server. Settatene uno per avere maggiore sicurezza.
; Yport, port to connect to yp.shoutcast.com on. For people behind caching
; webproxies, change this to the alternate port (666 is what it might be,
; check www.shoutcast.com if you have problems). Otherwise, leave this at 80.
; We’re actively working on re-opening port 666, but as of release the only
; working port is port 80.
Yport=80
Attraverso quale porta deve connettersi il server per avere contatti con il sito delle pagine gialle? Ovvio! con la porta 80, ma è sempre cosi? be, no.. per ora è disponibile solo la porta 80, quindi non cambiate questa opzione.
; NameLookups. Specify 1 to perform reverse DNS on connections.
; This option may increase the time it takes to connect to your
; server if your DNS server is slow. Default is 0 (off).
NameLookups=0
Questa opzione abilita o disabilita il reverse DNS. Disabilitata per default.
; RelayPort and RelayServer specify that you want to be a relay server.
; Relay servers act as clients to another server, and rebroadcast.
; Set RelayPort to 0, RelayServer to empty, or just leave these commented
; out to disable relay mode.
; RelayPort=8000
; RelayServer=192.168.1.58
Queste impostazioni sono da decommentare, nel caso in cui tu voglia fare da relay per un altra radio, altrimenti lasciale commentate.
; AdminPassword. This password (if specified) changes the
; behavior of Password to be a broadcast-only password, and
; limits HTTP administration tasks to the password specified
; here. The broadcaster, with the password above, can still
; log in and view connected users, but only the AdminPassword
; will grant the right to kick, ban, and specify reserve hosts.
; The default is undefined (Password allows control for both
; source and admin)
; AdminPassword=adminpass
Questa impostazione permette di creare una password di amministrazione che da una maggiore sicurezza a chi deve svolgere attività di ban e di reserve ip, nel pannello di amministrazione avanzato. E’ commentata (e quindi disabilitata) di default.
; AutoDumpUsers controls whether listeners are disconnected if the source
; stream disconnects. The default is 0.
AutoDumpUsers=0
Un controllo non molto utile…
; AutoDumpSourceTime specifies how long, in seconds, the source stream is
; allowed to be idle before the server disconnects it. 0 will let the source
; stream idle indefinately before disconnecting. The default is 30.
AutoDumpSourceTime=30
Tempo di sopravvivenza della connessione con il server quando la sorgente crasha.
; ContentDir specifies the directory location on disk of where to stream
; on-demand content from. Subdirectories are supported as of DNAS 1.8.2.
; Default is ./content, meaning a directory named content in the same directory
; as where sc_serv was invoked from.
; ContentDir=./content
Identifica una directory di contenuti nel caso di Radio On-demand, non è il nostro caso.
; IntroFile can specify a mp3 file that will be streamed to listeners right
; when they connect before they hear the live stream.
; Note that the intro file MUST be the same samplerate/channels as the
; live stream in order for this to work properly. Although bitrate CAN
; vary, you can use ‘%d’ to specify the bitrate in the filename
; (i.e. C:\intro%d.mp3 would be C:\intro64.mp3 if you are casting at 64kbps).
; The default is no IntroFile
; IntroFile=c:\intro%d.mp3
Esiste la possibilità di trasmettere un brano di presentazione ogni qual volta qualcuno si connette alla radio, in modo che prima di sentire il flusso vero e proprio, si senta questo file. Per default questa opzione è commentata. Avete anche la possibilità di settare una variabile %d nel nome del file, in modo da potere separare file a vari bitrate in caso di streaming multipli a vari bitrate.
; BackupFile can specify a mp3 file that will be streamed to listeners over
; and over again when the source stream disconnects. AutoDumpUsers must be
; 0 to use this feature. When the source stream reconnects, the listeners
; are rejoined into the live broadcast.
; Note that the backup file MUST be the same samplerate/channels as the
; live stream in order for this to work properly. Although bitrate CAN
; vary, you can use ‘%d’ to specify the bitrate in the filename
; (i.e. C:\backup%d.mp3 would be C:\backup32.mp3 if you are casting at 32kbps).
; The default is no BackupFile
; BackupFile=C:\intro%d.mp3
Ecco una delle opzioni parafondoschiena per tutte le radio che intendono avere un unico server e molte sorgenti interscambiabili. Questa opzione permette di settare un file di backup, con le stesse modalità del file di intro di cui sopra, ma al contrario di quello, questo file verrà trasmesso solo quando la sorgente si disconnette dal server, e viene ripetuto più volte fintantochè non si ha di nuovo una sorgente. Utilissima opzione se il file mp3 ha un testo del tipo: “Attendere prego.. ci stiamo riconnettendo a radio taldetali…”
; TitleFormat specifies a format string for what title is sent to the listener.
; For example, a string of ‘Justin Radio’ forces the title ‘Justin Radio’ even
; when the source changes the title. You can use up to one ‘%s’ in the string
; which lets you contain the title from the source. For example, if your
; TitleFormat is ‘Justin Radio: %s’, and the source plug-in’s title is
; ‘Billy plays the blues’, then the net title is
; ‘Justin Radio: Billy plays the blues’. Note: only works on non-relay servers.
; The default is no format string.
; TitleFormat=Justin Radio: %s
Questa opzione permette di modellare il formato titoli visualizzato nei player a proprio piacimento.
; URLFormat specifies a format string for what url is sent to the listener.
; Behaves like TitleFormat (see above).
; The default is no format string.
; URLFormat=http://www.server.com/redirect.cgi?url=%s
Lo stesso comportamento di TitleFormat, ma in questo caso si considera un url.
; PublicServer can be always, never, or default (the default, heh)
; Any setting other than default will override the public status
; of the source plug-in or of a SHOUTcast server that is being relayed.
PublicServer=default
Il server deve essere pubblico? Potete scegliere, ma lasciate default che è meglio.
; AllowRelay determines whether or not other SHOUTcast servers will be
; permitted to relay this server. The default is Yes.
AllowRelay=Yes
Opzione che permette di avere o non avere relay per la propria radio.
; AllowPublicRelay, when set to No, will tell any relaying servers not
; to list the server in the SHOUTcast directory (non-public), provided
; the relaying server’s Public flag is set to default. The default is
; Yes.
AllowPublicRelay=Yes
I relay devono essere pubblici? Decidete.
; MetaInterval specifies how often, in bytes, metadata sent.
; You should really leave this at the default of 8192, but the option is
; provided anyway.
MetaInterval=32768
Quantità di metadata inviati insieme ai dati. Il default è 8 Kb.
Tralasciamo la parte relativa all’access control perchè è stata trattata quando abbiamo parlato del pannello di amministrazione avanzato. Nella seconda parte della guida avanzata, si commenteranno gli altri file, orientati al plug-in.
Categories: Web Radio
2 Comments »
2 Responses to “Come creare una web radio con Linux e Shoutcast (guida avanzata)”
Ciao, bellissima guida complimenti!
Ti chiedo una cosa, è possibile al posto della pagina sulla porta 8000 avere una pagina con un player stile win media player? o un player tipo quelli che si trovano su ad esempio radio 105?
O indirizzami su uno di questi plug-in?
Grazie! Ciao
@Matteo:
In sostituzione al pannello di amministrazione, non si può mettere niente, quello c’è e quello rimane, pubblico.
Puoi crearti tu una pagina con tutti i player che vuoi…
Care to comment?
