Main Page/Stuff/Icecast instructions

From phurvitz
Jump to: navigation, search

On gismo:

Starting icecast

to start icecast, as root:

  su - iceuser
  cd /usr/local/icecast2
  icecast -c icecast.xml &
  exit

(Note may require changing iptables to allow port 8000).

Loading playlists

playlists can be obtained as m3u files, which simply give the path to mp3 files, e.g.,

/home/phurvitz/phmusic/e/evoria/EvoriaCesaria_Untitled - 03-17-03_03 carnaval de sao vicente.mp3
/home/phurvitz/phmusic/e/evoria/EvoriaCesaria_Untitled - 03-17-03_01 sodade.mp3
/home/phurvitz/phmusic/e/evoria/EvoriaCesaria_Untitled - 03-17-03_02 fala pa fala.mp3
/home/phurvitz/phmusic/e/evoria/EvoriaCesaria_Untitled - 03-17-03_12 flor di nha esperanca.mp3
/home/phurvitz/phmusic/e/evoria/EvoriaCesaria_Untitled - 03-17-03_04 crepuscular solidao.mp3
/home/phurvitz/phmusic/e/evoria/EvoriaCesaria_Untitled - 03-17-03_05 cize.mp3
/home/phurvitz/phmusic/e/evoria/EvoriaCesaria_Untitled - 03-17-03_06 petit pays.mp3
/home/phurvitz/phmusic/e/evoria/EvoriaCesaria_Untitled - 03-17-03_07 tchintchirote.mp3
/home/phurvitz/phmusic/e/evoria/EvoriaCesaria_Untitled - 03-17-03_08 angola.mp3
/home/phurvitz/phmusic/e/evoria/EvoriaCesaria_Untitled - 03-17-03_09 vida tem um so vida.mp3
/home/phurvitz/phmusic/e/evoria/EvoriaCesaria_Untitled - 03-17-03_10 bondade e maldade.mp3
/home/phurvitz/phmusic/e/evoria/EvoriaCesaria_Untitled - 03-17-03_11 sangue de beirona.mp3
/home/phurvitz/phmusic/e/evoria/EvoriaCesaria_Untitled - 03-17-03_15 nho antone escaderode.mp3
/home/phurvitz/phmusic/e/evoria/EvoriaCesaria_Untitled - 03-17-03_13 lua nha testemunha.mp3
/home/phurvitz/phmusic/e/evoria/EvoriaCesaria_Untitled - 03-17-03_14 esperanca irisada.mp3
/home/phurvitz/phmusic/e/evoria/EvoriaCesaria_Untitled - 03-17-03_16 fidjo maguado.mp3
/home/phurvitz/phmusic/e/evoria/EvoriaCesaria_Untitled - 03-17-03_17 embarcacao.mp3

or read from the contents of a directory, recursively.

to load a playlist, as phurvitz:

  icegenerator -f /home/phurvitz/icecast/icegenerator.conf.3
(or whatever icegenerator file)

Playing files

Use foobar 2000 and a URL of the form

http://gismo.gis.washington.edu:8000/test1

Icegenerator configuration files

The configuration files let icegenerator know what/how to serve audio files. Examples:

the icegenerator file reading from an m3u file:

NAME=Gismo Streaming Server
IP=128.208.113.5
PORT=8000
# 2 - Icecast 2.0 (HTTP protocol compatible)
SERVER=2
SOURCE=source
PASSWORD=LUCINDA
FORMAT=1
RECURSIVE=1
DUMPFILE=
LOOP=1
SHUFFLE=0
BITRATE=48000
PUBLIC=0
METAUPDATE=5
MDFPATH=/mypath/global.mdf
LOG=2
LOGPATH=/var/log/icegenerator.log
DATAPORT=8796

#######################################################
MOUNT=/jobim
MP3PATH=m3u:/home/phurvitz/phmusic/j/Jobim/jobin.m3u
GENRE=Brasilian Jazz
DESCRIPTION=Home Radio
URL=http://gismo.gis.washington.edu:8000/jobim


the icegenerator file reading from contents of a directory recursively:

NAME=Gismo Streaming Server
IP=128.208.113.5
PORT=8000
# 2 - Icecast 2.0 (HTTP protocol compatible)
SERVER=2
SOURCE=source
PASSWORD=LUCINDA
FORMAT=1
RECURSIVE=1
DUMPFILE=
LOOP=1
SHUFFLE=1
BITRATE=48000
PUBLIC=0
METAUPDATE=5
MDFPATH=/mypath/global.mdf
LOG=2
LOGPATH=/home/phurvitz/icecast/logs/icegenerator.log
DATAPORT=8796

#######################################################
MOUNT=/test1
MP3PATH=pth:/home/phurvitz/phmusic
GENRE=All random
DESCRIPTION=Home Radio
URL=http://gismo.gis.washington.edu:8000/test1

Encoding files

I rip all of my CDs as aac/mp4/m4a files so they can be loaded on the iPod. But icecast/icegenerator serves mp3 files (I could use Darwin to serve aac files presumably). Here is the script for finding and ripping all m4a files into mp3 files in a subdir called mp3:

#! /usr/bin/perl -w
use File::List;

# find all dirs
@dirs = `find -type "d"`;
#print "@dirs";

# for each dir
foreach $d (@dirs){
  chomp $d;
  #print "$d\n";
  ## skip the top level
  if ($d ne ".") {

      # tally m4a files
      @m4as = `ls \"$d\"/*.m4a 2>/dev/null`;
      $m4acount = @m4as;

      # tally mp3 files
      @mp3s = `ls \"$d\"/*.mp3 2>/dev/null`;
      $mp3count = @mp3s;

      ## if dir contains m4a files
      if ($m4acount > 0) {
          # if dir does not have a subdir called "mp3" then make one
          $mp3dir = join('/', $d, "mp3");
          if (! -e "$mp3dir") {
              print "making \"$mp3dir\" \n";
              system "mkdir \"$mp3dir\"";
          }

          # if the mp3dir exists then move mp3s there
          if (-e "$mp3dir") {
            if ($mp3count > 0) {
              chdir ("$d");
              print "moving *.mp3 mp3\n"; 
              system "mv *.mp3 mp3"; 
              chdir ("/home/phurvitz/phmusic");
            }
          }

          # make a list of mp3s in the mp3 dir
          @mp3files = `ls \"$d\"/mp3/*.mp3 2>/dev/null`;
          $mp3filecount = @mp3files;

          @m4as = `ls \"$d\"/*.m4a 2>/dev/null`;
          $m4acount = @m4as;

          # if the count of mp3s is not the same as the m4as then rip
          if ($m4acount != $mp3filecount) {
            chdir ($d);
            while(defined($m4a = <*.m4a>)) {
              ($mp3 = $m4a) =~ s/m4a/mp3/;
              if (! -e "mp3/$mp3"){
                #print  "faad -o - \"$m4a\" | lame -h -b 192 - \"mp3/$mp3\" \n";
                system  "faad -o - \"$m4a\" | lame -h -b 192 - \"mp3/$mp3\"";
              }
            }
            chdir ("/home/phurvitz/phmusic");

          }

      }
  }

}