Raspberry Pi As Media Server

Raspberry Pi as a Small Media Player


As I tried many different solutions (Logitech squeezeboxes, XBMC,…) I ended up buying a raspberry pi mini computer. This little small box has everything you need to run Music Player Daemon on it.

My setup looks like:

* Synology DS-212 NAS
* Raspberry PI with MPD (Music Player Deamon)
* Pro-Ject USB DAC connected to the PI


I’m not sure if the PI is capable to play 96khz or higher solution files. There
is a lot of noise, when trying to play it. Could also be the DAC. If I fix
the audio_output – format to 44100:16:2, the 96khz files will be played.

Here is a small how-to

First get yourself a raspberry pi. I got mine from digitec

* Raspberry Pi
* Power Supply – Xqisit universal Reiselader – Micro-USB
* Case

I already had an 8GB SD Card to install the OS.

Installation of the OS

Download the OS img: Rasbian “wheezy” – I used the file which you can get here. It’s a Debian tailored for the PI. You’ll also find there some useful informations how the write the img file to the SD Card.

After you expanded the img file to the SD Card, you are ready to go. Put the SD Card into the PI, attach power, keyboard (you won’t need it later anymore), USB DAC, monitor and finally power.

Your PI should now boot, and getting to a Menu.


First select expand_rootfs – otherwise you won’t be able to use the full space on your SD Card

Then set your keyboard layout, change the password for the pi user, set the locale, the timezone.

Memory_split. Here you define how the 512MByte Memory will be split up. As we don’t need a graphical UI on the PI use 16, that will to the trick.

Overclock, it’s possible to overclock your PI. I use Medium over clocking.

Then enable the SSH Server – for remote access, later when you unplug the keyboard.

And disable boot straight to desktop

Then reboot your PI. After the reboot you should be able to connect to you PI by remote connection thru SSH – use e.g. putty.

After first login, update your PI

sudo apt-get update
sudo apt-get upgrade

and reboot.

Export NFS Share/Mount Share

Next export your music directories on the NAS. I use NFS, as it’s more performant than samba/cifs.

I added the following line to /etc/exports on my Synology nas


To mount this export on your PI, we first have to install and setup some additional services

sudo aptitude install nfs-common portmap
sudo update-rc.d rpcbind enable

Add the mountpoint, so after reboot the NFS Filesystem will be remounted automatically

Create the mount point, my NAS is called disk station

sudo mkdir -p /music

sudo vi /etc/fstab

Add the following line

diskstation:/volume1/music /diskstation/music nfs rsize=8192,wsize=8192,timeo=14
,intr 0 0

Mpd is only able to have one directoy where the music is stored. So one way is the create a music directory and link the different source into that directory. With this setup you can incremental add your music.

sudo mkdir /music

Then you can link your subdirectories from the mount point into music, like

sudo ln -s /diskstation/music/flac /music/flac

Repeat the step above for each subdirectory you have. I personally suggest, just add one subdirectory first, and test the configuration. First scan could take quite a long time.

Install mpd

sudo apt-get install mpd

Then edit mpd.conf which is in the /etc/ directory

vi /etc/mpd.conf

Change the parameter music_directory to /music

Comment out the line bind_to_address

Now we have to get the id of the USB Dac

aplay --list-devices
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
Subdevices: 7/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 1: DAC [USB Audio DAC], device 0: USB Audio [USB Audio]
Subdevices: 0/1
Subdevice #0: subdevice #0

So here the DAC has the address 1 (card 1) ,0 (sub device). Change this in your /etc/mpd.conf

audio_output {
type "alsa"
name "USB Audio DAC"
device "hw:1,0" # optional
# format "44100:16:2" # optional
# mixer_device "default" # optional
# mixer_control "PCM" # optional
# mixer_index "0" # optional

Change mixer_type to “disabled” as we want best quality.

Load the Covers by HTTP on the clients

Install lighttpd

sudo apt-get install lighttpd

edit /etc/lighttpd/lighttpd.conf


server.document-root = "/music"

Comment out

# server.username = "www-data"
# server.groupname = "www-data"

and add

server.dir-listing = "enable"

Now you can start httpd-server: /etc/init.d/lighttpd start

Try, if you get a directory listing by enter http://

Internet Radio

Adding internet radio streams is quite easy. They will be showed in the playlist folder.

As an example for WDR2 (taken from einsnull magazine)

cd /var/lib/mpd/playlists
sudo wget http://www.wdr.de/wdrlive/media/wdr2.m3u
sudo mv wdr2.m3u "WDR 2.m3u"

If you have a stream url without m3u ending do the following

sudo vi "Sunshine Live.m3u"

Copy and Paste the URL in that file


Control your MPD-Raspberry pi.

I’m using for the iPad MPaD. Which works like a charm.

Add mpd to MPaD by entering a name and the server’s ip address.

Enter the same ip-address, but starting wiht http:// at URL found just under Local Cover Art.

Adjust Cover Filename accordingly to your choice. I use Folder.jpg.

Click on the wheel and select Update Database and Refresh local cache.