<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://www.freebsdwiki.net/skins/common/feed.css?303"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.freebsdwiki.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mahoney</id>
		<title>FreeBSDwiki - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://www.freebsdwiki.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mahoney"/>
		<link rel="alternate" type="text/html" href="http://www.freebsdwiki.net/index.php/Special:Contributions/Mahoney"/>
		<updated>2026-04-06T00:42:52Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.18.0</generator>

	<entry>
		<id>http://www.freebsdwiki.net/index.php/Icecast_and_Musicpd</id>
		<title>Icecast and Musicpd</title>
		<link rel="alternate" type="text/html" href="http://www.freebsdwiki.net/index.php/Icecast_and_Musicpd"/>
				<updated>2007-02-27T18:50:59Z</updated>
		
		<summary type="html">&lt;p&gt;Mahoney: /* Setting up MusicPD */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
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.&lt;br /&gt;
== Setting up Icecast2 ==&lt;br /&gt;
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 &amp;lt;source-password&amp;gt;, &amp;lt;admin-password&amp;gt;, and &amp;lt;bind-address&amp;gt; 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 &amp;lt;bind-address&amp;gt; to 127.0.0.1 .  I also changed &amp;lt;user&amp;gt; and &amp;lt;group&amp;gt; to be nobody as I had been starting the server as root.&lt;br /&gt;
== Setting up MusicPD ==&lt;br /&gt;
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:&lt;br /&gt;
 &amp;lt;nowiki&amp;gt;svn co https://svn.musicpd.org/mpd/trunk musicpd&lt;br /&gt;
 cd mpd&lt;br /&gt;
 ./autogen.sh&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
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:&lt;br /&gt;
 ./configure --with-libFLAC=/usr/local/ --with-ogg=/usr/local/ \&lt;br /&gt;
  --with-vorbis=/usr/local/ --disable-tremor --enable-shout \&lt;br /&gt;
  --enable-ogg --disable-ipv6&lt;br /&gt;
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:&lt;br /&gt;
 gmake &amp;amp;&amp;amp; gmake install&lt;br /&gt;
With musicpd installed, there's the task of configuring it.  From the musicpd port, I copied and filled in this startup script:&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 #&lt;br /&gt;
 &lt;br /&gt;
 # PROVIDE: musicpd&lt;br /&gt;
 # REQUIRE:&lt;br /&gt;
 # BEFORE:&lt;br /&gt;
 # KEYWORD: FreeBSD shutdown&lt;br /&gt;
 &lt;br /&gt;
 # Add the following line to /etc/rc.conf to enable mpd:&lt;br /&gt;
 #&lt;br /&gt;
 #musicpd_enable=&amp;quot;YES&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 . /etc/rc.subr&lt;br /&gt;
 &lt;br /&gt;
 name=musicpd&lt;br /&gt;
 rcvar=`set_rcvar`&lt;br /&gt;
 &lt;br /&gt;
 config=/usr/local/etc/mpd.conf&lt;br /&gt;
 command=/usr/local/bin/mpd&lt;br /&gt;
 required_files=$config&lt;br /&gt;
 &lt;br /&gt;
 musicpd_flags=&amp;quot;$musicpd_flags $config&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 [ -z &amp;quot;$musicpd_enable&amp;quot; ] &amp;amp;&amp;amp; musicpd_enable=&amp;quot;NO&amp;quot;&lt;br /&gt;
 [ -z &amp;quot;$musicpd_flags&amp;quot; ]  &amp;amp;&amp;amp; musicpd_flags=&lt;br /&gt;
 &lt;br /&gt;
 load_rc_config $name&lt;br /&gt;
 &lt;br /&gt;
 run_rc_command &amp;quot;$1&amp;quot;&lt;br /&gt;
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:&lt;br /&gt;
 music_directory         &amp;quot;/mnt/storageDrive/media/music&amp;quot;&lt;br /&gt;
 playlist_directory      &amp;quot;/mnt/storageDrive/media/music&amp;quot;&lt;br /&gt;
 db_file                 &amp;quot;/var/mpd/mpd.db&amp;quot;&lt;br /&gt;
 log_file                &amp;quot;/var/mpd/mpd.log&amp;quot;&lt;br /&gt;
 error_file              &amp;quot;/var/mpd/mpd.error&amp;quot;&lt;br /&gt;
 pid_file                &amp;quot;/var/mpd/mpd.pid&amp;quot;&lt;br /&gt;
 audio_output {&lt;br /&gt;
  type            &amp;quot;shout&amp;quot;&lt;br /&gt;
  name            &amp;quot;my cool stream&amp;quot;&lt;br /&gt;
  host            &amp;quot;127.0.0.1&amp;quot;&lt;br /&gt;
  port            &amp;quot;8000&amp;quot;&lt;br /&gt;
  mount           &amp;quot;/mpd.ogg&amp;quot;&lt;br /&gt;
  password        &amp;quot;sourcepasswordfromicecastconfigfile&amp;quot;&lt;br /&gt;
  bitrate         &amp;quot;128&amp;quot;&lt;br /&gt;
  format          &amp;quot;44100:16:1&amp;quot;&lt;br /&gt;
  user            &amp;quot;source&amp;quot;&lt;br /&gt;
 }&lt;br /&gt;
 bind_to_address         &amp;quot;127.0.0.1&amp;quot;&lt;br /&gt;
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 &amp;lt;source-password&amp;gt; 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.&lt;br /&gt;
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 :&lt;br /&gt;
 #for musicpd&lt;br /&gt;
 musicpd_enable=&amp;quot;YES&amp;quot;&lt;br /&gt;
 #for icecast&lt;br /&gt;
 icecast_enable=&amp;quot;YES&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Getting the music to the client ==&lt;br /&gt;
Once icecast and musicpd are running, it's very easy to get music to the client.  I use ssh port-forwarding to do it.&lt;br /&gt;
 ssh -N -L6600:127.0.0.1:6600 username@server &amp;amp;&lt;br /&gt;
 ssh -N -L8000:127.0.0.1:8000 username@server &amp;amp;&lt;br /&gt;
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).&lt;br /&gt;
== Audioscrobbler support ==&lt;br /&gt;
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:&lt;br /&gt;
 tar -xf mpdscribble-0.2.7.tar.gz&lt;br /&gt;
 cd mpdscribble-0.2.7&lt;br /&gt;
 ./configure&lt;br /&gt;
 make&lt;br /&gt;
 make install&lt;br /&gt;
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:&lt;br /&gt;
 username = username&lt;br /&gt;
 password = md5ofmypassword&lt;br /&gt;
 cache = /usr/home/username/.mpdscribble/mpdscribble.cache&lt;br /&gt;
 log = /usr/home/username/.mpdscribble/mpdscribble.log&lt;br /&gt;
 verbose = 2&lt;br /&gt;
Just running mpdscribble after this works for me without trouble.  To get the md5 of a password, the following works:&lt;br /&gt;
 md5 -s 'My super cool password'&lt;br /&gt;
&lt;br /&gt;
== External links ==&lt;br /&gt;
[http://www.icecast.org/ Icecast homepage]&lt;br /&gt;
&lt;br /&gt;
[http://musicpd.org/ MusicPD homepage]&lt;br /&gt;
&lt;br /&gt;
[http://www.frob.nl/scribble.html mpdscribble homepage]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Ports and Packages]]&lt;br /&gt;
[[Category:FreeBSD Multimedia]]&lt;/div&gt;</summary>
		<author><name>Mahoney</name></author>	</entry>

	</feed>