Difference between revisions of "Webradio"

From YobiWiki
Jump to navigation Jump to search
Line 114: Line 114:
 
** there are plenty of tools to tune id3 tags, mp3info is one of them and by default allows to change one item without touching the other id3 infos.
 
** there are plenty of tools to tune id3 tags, mp3info is one of them and by default allows to change one item without touching the other id3 infos.
 
* ices:
 
* ices:
** default playlist: get songs randomly from playlist file but don't install it in mpd<br>put fallback playlist in /usr/share/mpd/fallbackplaylist.m3u
 
 
** next song: killall -s USR1 ices
 
** next song: killall -s USR1 ices
 
** how to make it remotely?? through icecast2(php auth?) or mpd...
 
** how to make it remotely?? through icecast2(php auth?) or mpd...

Revision as of 13:40, 25 June 2007

Intro

I was struggling to fit some requirements:

  • I ripped all my CDs on the HD attached to the slug
  • I wanted my Philips Streamium (which is not UPnP) to be able to play whatever I want
    • Streamium is not UPnP
    • Streamium doesn't understand Ogg format
    • Streamium has a very poor UI
  • I wanted to be able to control the playlist from any other computer in the house
  • Why not extending those possibilities from anywhere on the Net?

Resources

  • madplay/libmad (fixed point mp3 player)
    • In terms of codecs this is the only fixed-point lib available for the slug and it allows only mp3 playback.
  • musicdp, aka mpd (its faq)
    • That's THE solution to manage the playlists, now we need to cope with its playing capabilities...
  • http://www.nslu2-linux.org/wiki/HowTo/SlugAsAudioPlayer
    • With mpd and libmad, good idea but is using the slug soundcard (if you add one), not icecast
  • icecast2
    • The solution for streaming, if we find the right way to add a mp3 source to it.
  • mpd + icecast2
    • 2 problems: only streaming in Ogg and needs to reencode the stream, too much without a fixed point encoder!
  • oggfwd
    • Would solve one problem: does not reencode, but, as the name tells you, only Ogg.
  • EzStream
    • Good candidate, feeds icecast with mp3 without reencoding, but needs to be hooked to mpd
  • Ices and especially the versions 0.x
    • Same as for EzStream
  • Jinzora
    • To be explored... but requires php/mysql, maybe too much for the slug
  • Hack mpd with ices client
    • That's the best I could find: a Perl script as scriptable playlist for ices fetches the songs from mpd playlist ans streams them to icecast2
    • Ices in its basic configuration doesn't perform any reencoding
    • Note that the old version of ices is required as the new one supports only Ogg

Let's go

mpd

apt-get install mpd mpc
  • Edit /etc/mpd.conf
    • point music_directory to your mp2s or make a symlink from /var/lib/mpd/music
    • define password for clients if you want
  • On the slug there is by default no soundcard but mpd cannot start without at least one output, we'll give it a dummy soundcard:
echo snd-dummy >> /etc/modules
modprobe snd-dummy
  • Generate DB
/etc/init.d/mpd stop
mpd --create-db
  • Launch mpd
/etc/init.d/mpd start
mpc stop

(Remember that we don't use mpd to play music but only to handle playlists)

  • When need to update the DB:
mpc update
  • gmpc can display content in UTF-8 but depending on the locales of your platform, encoding done by mpd could be wrong, in that case you need to add to /etc/mpd.conf sth like this and recreate the db
filesystem_charset              "UTF-8"
id3v1_encoding                  "UTF-8"
mpd --create-db

icecast2

apt-get install icecast2
  • Edit /etc/icecast2/icecast.xml
    • Change passwords in <authentication>
    • Change <hostname> if it's relevant
    • You can add clients authentication as well:
   <mount>
       <mount-name>/mymountpoint</mount-name>
       <authentication type="htpasswd">
               <option name="filename" value="/etc/icecast2/authusers"/>
               <option name="allow_duplicate_users" value="0"/>
       </authentication>
   </mount>
touch /etc/icecast2/authusers
chown icecast2 /etc/icecast2/authusers
chmod 700 /etc/icecast2/authusers

Note that my streamium cannot handle basic authentication, the only way would then be based on IP, with URL auth in icecast2 or simply through iptables.

  • Edit /etc/default/icecast2
    • ENABLE=true
/etc/init.d/icecast2 start
  • Then to manage users, go to the admin page http://myserver:port/admin/ -> Manage authentication of that source
  • Stream playing can be achieved with sth like
xmms http://user:pwd@myserver:port/mymountpoint
vlc http://user:pwd@myserver:port/mymountpoint.m3u

ices

  • Debian features only ices2 so we've to compile the old version ourselves
apt-get install libshout3-dev libperl-dev libmp3-info-perl
wget http://downloads.us.xiph.org/releases/ices/ices-0.4.tar.gz
tar xzf ices-0.4.tar.gz 
cd ices-0.4
./configure --with-perl
make
cp src/ices /usr/local/bin
cp conf/ices.conf.dist /etc/ices.conf
wget -q -O - http://mpd.wikia.com/wiki/Hack:ices-client | awk '/<pre/,/<\/pre/'|html2text -width 200 > mpdplaylist.pm
  • Edit mpdplaylist.pm
    • my $mediaroot: points to your mp3 directory, must be identical to music_directory in /etc/mpd.conf but with trailing /
    • my $playlistdir: points to your playlists dir, must be identical to playlist_directory in /etc/mpd.conf (default is /var/lib/mpd/playlists) but with trailing /
    • Add the following lines to use authentication for musicp clients (cf password in /etc/mpd.conf) or to connect to a remote mpd or a non default port
$ENV{'MPD_HOST'} = 'mypassword@localhost';
$ENV{'MPD_PORT'} = '6600';
  • Edit /etc/ices.conf
 <Playlist>
   <Type>perl</Type>
   <Module>mpdplaylist</Module>
 </Playlist>

Maybe you need to adapt also <Mountpoint>, <Password> to match the icecast2 source pwd and the <Bitrate> but that's just for info as we won't recode the stream anyway, and once everything is running properly, set <Background> to 1.

  • Run
rm /tmp/ices.log
ices -c /etc/ices.conf
# or as icecast2 user:
su icecast2 -m /bin/bash -c "ices -c /etc/ices.conf"

TODO

  • setup phpmp2?
  • auto upload of ripped CDs?
    • there are plenty of tools to tune id3 tags, mp3info is one of them and by default allows to change one item without touching the other id3 infos.
  • ices:
    • next song: killall -s USR1 ices
    • how to make it remotely?? through icecast2(php auth?) or mpd...
    • ices crossfade?
    • use mpc play to sync display of played song? will consume a few CPU (dummy sound card, we could try to do a dummy libmad ;-)), otherwise be sure to do mpc stop
  • icecast authorisation, cf http://www.icecast.org/docs/icecast-2.3.1/icecast2_listenerauth.html
    • as streamium does not understand http auth_basic, one solution is to use iptables to filter access locally and use an icecast2 relay with auth_basic for external use when I'm on-the-go