pavement

Icecast and Musicpd

From FreeBSDwiki
(Difference between revisions)
Jump to: navigation, search
(Setting up MusicPD)
Line 13: Line 13:
 
   --enable-ogg --disable-ipv6
 
   --enable-ogg --disable-ipv6
 
Each of these arguments is for a reason.  FLAC, ogg, and vorbis install in /usr/local/wherever on freebsd and I guess that the script assumes them to be elsewhere.  --disable-tremor is required because tremor and shout are mutually exclusive for mpd.  --enable-shout enables shout protocol streaming (which icecast2 uses) and --disable-ipv6 was necessary to overcome a bug with musicpd on freebsd.  After that:
 
Each of these arguments is for a reason.  FLAC, ogg, and vorbis install in /usr/local/wherever on freebsd and I guess that the script assumes them to be elsewhere.  --disable-tremor is required because tremor and shout are mutually exclusive for mpd.  --enable-shout enables shout protocol streaming (which icecast2 uses) and --disable-ipv6 was necessary to overcome a bug with musicpd on freebsd.  After that:
  gmake && gmake install
+
  gmake
With musicpd installed, there's the task of configuring it.  From the musicpd port, I copied and filled in this startup script:
+
#!/bin/sh
+
#
+
+
# PROVIDE: musicpd
+
# REQUIRE:
+
# BEFORE:
+
# KEYWORD: FreeBSD shutdown
+
+
# Add the following line to /etc/rc.conf to enable mpd:
+
#
+
#musicpd_enable="YES"
+
+
. /etc/rc.subr
+
+
name=musicpd
+
rcvar=`set_rcvar`
+
+
config=/usr/local/etc/mpd.conf
+
command=/usr/local/bin/mpd
+
required_files=$config
+
+
musicpd_flags="$musicpd_flags $config"
+
+
[ -z "$musicpd_enable" ] && musicpd_enable="NO"
+
[ -z "$musicpd_flags" ]  && musicpd_flags=
+
+
load_rc_config $name
+
+
run_rc_command "$1"
+
In /usr/local/etc/mpd.conf I modified the example configuration file (from the doc subdirectory of the svn repository that we checked out earlier) to have the following lines:
+
music_directory        "/mnt/storageDrive/media/music"
+
playlist_directory      "/mnt/storageDrive/media/music"
+
db_file                "/var/mpd/mpd.db"
+
log_file                "/var/mpd/mpd.log"
+
error_file              "/var/mpd/mpd.error"
+
pid_file                "/var/mpd/mpd.pid"
+
audio_output {
+
  type            "shout"
+
  name            "my cool stream"
+
  host            "127.0.0.1"
+
  port            "8000"
+
  mount          "/mpd.ogg"
+
  password        "sourcepasswordfromicecastconfigfile"
+
  bitrate        "128"
+
  format          "44100:16:1"
+
  user            "source"
+
}
+
bind_to_address        "127.0.0.1"
+
Again, the 127.0.0.1 address as I don't want this control available to everyone on the internet.  Make sure that the password in this file and <source-password> in icecast's configuration file match.  Set the bitrate to be whatever format you would like.  MusicPD will reencode all of your music to that bitrate and ogg format as you listen.
+
Now icecast and musicpd should be installed and configured.  To get them to start automagically at boot, Try adding the following to /etc/rc.conf :
+
#for musicpd
+
musicpd_enable="YES"
+
#for icecast
+
icecast_enable="YES"
+
 
+
== Getting the music to the client ==
+
Once icecast and musicpd are running, it's very easy to get music to the client.  I use ssh port-forwarding to do it.
+
ssh -N -L6600:127.0.0.1:6600 username@server &
+
ssh -N -L8000:127.0.0.1:8000 username@server &
+
And now to enjoy the tunes and control the server, you can install your favourite ogg-player (I'm currently using xmms-kde) and mpd client (kmp here).
+
== Audioscrobbler support ==
+
For audioscrobbler support, I am using mpdscribbler downloaded from http://www.frob.nl/projects/scribble/mpdscribble-0.2.7.tar.gz .  To install it, I exported LDFLAGS=-lc_r and then did this:
+
tar -xf mpdscribble-0.2.7.tar.gz
+
cd mpdscribble-0.2.7
+
./configure
+
make
+
make install
+
After this, the usual setup procedure is to run setup.sh.  Unfortunately the setup.sh script is a bit linuxified so I simply made a config in the following format:
+
username = username
+
password = md5ofmypassword
+
cache = /usr/home/username/.mpdscribble/mpdscribble.cache
+
log = /usr/home/username/.mpdscribble/mpdscribble.log
+
verbose = 2
+
Just running mpdscribble after this works for me without trouble.  To get the md5 of a password, the following works:
+
md5 -s 'My super cool password'
+
 
+
== External links ==
+
[http://www.icecast.org/ Icecast homepage]
+
 
+
[http://musicpd.org/ MusicPD homepage]
+
 
+
[http://www.frob.nl/scribble.html mpdscribble homepage]
+
 
+
 
+
[[Category:Ports and Packages]]
+
[[Category:FreeBSD Multimedia]]
+

Revision as of 13:59, 22 June 2007

Introduction

As my laptop's music collection was getting larger and I was wanting more elbow room, I decided it was finally time to offload most of it to a remote machine and figure out some way to access it easily via the internet.

Setting up Icecast2

The first step was to install Icecast2. I did this from audio/icecast2 in ports, but it can probably be done via pkg_add instead. Once installed, it should be configured. It seems that /usr/local/share/icecast/doc/ has some config examples. In the configuration file, the <source-password>, <admin-password>, and <bind-address> are the main fields that I changed. As I want to be the only one listening to this (which is to say didn't want the stream shared via the internet), I set <bind-address> to 127.0.0.1 . I also changed <user> and <group> to be nobody as I had been starting the server as root.

Setting up MusicPD

The second thing I did was set up musicpd. As the version in ports doesn't yet support streaming to the icecast server, I had to grab the version from their svn (this requires having subversion installed). Go to a directory of you choosing and try this:

svn co https://svn.musicpd.org/mpd/trunk musicpd
 cd mpd
 ./autogen.sh

Now, as autogen.sh (probably a way to make it do the right thing) didn't actually do everything quite right for me I had to export LD_FLAGS=-lc_r and then the following:

./configure --with-libFLAC=/usr/local/ --with-ogg=/usr/local/ \
 --with-vorbis=/usr/local/ --disable-tremor --enable-shout \
 --enable-ogg --disable-ipv6

Each of these arguments is for a reason. FLAC, ogg, and vorbis install in /usr/local/wherever on freebsd and I guess that the script assumes them to be elsewhere. --disable-tremor is required because tremor and shout are mutually exclusive for mpd. --enable-shout enables shout protocol streaming (which icecast2 uses) and --disable-ipv6 was necessary to overcome a bug with musicpd on freebsd. After that:

gmake
Personal tools