Sharing music library from a Linux server to iTunes

With the new entry into the world of OS X, one of the first things I decided to do was to get access to my music library stored on a Linux server. I know a lot of people that are hooked completely on Apple with iPods/iPhones/MacBooks/Airport etc, and they don’t understand why I have to go trough all this trouble when the Apple stuff “just works”. And to that I answer:

  • I have a fairly high quality stereo setup hooked up to my server and can easily hear the difference between compressed formats (MP3, AAC) and loss less formats (like Flac)
  • We have numerous devices with different format support (Portable MP3 players, mobile phones, windows clients etc). So using a neutral, open, DRM-free format seems likes the best bet to get all this going.
  • I never buy music from the iTunes music store (until they provide songs in a lossless format anyway)

Installing the software

I’ll use the Firefly software to share the library across the network. It can convert formats not supported by iTunes (flac, ogg etc) on the fly. The server is running Debian Etch (in a Xen VM) so to install I just do

mediaserver2:~# apt-get install mt-daapd

Strangely, this seems to also install the avahi-daemon which provides the Bonjour mDNS service even if this service is built into mt-daapd and they seem not be compatible (at least I couldn’t get it to work). So need to disable mDNS in mt-daapd. So create the file /etc/default/mt-daapd with the contents

DAEMON_OPTS=-m

Then edit /etc/mt-daapd.conf and change the settings admin_pw and mp3_dir. I then started the avahi-daemon & mt-daapd. You can then go to http://yourserver:3689 to see the mt-daapd admin interface and tell it to scan your folders. Then I started up iTunes…….and nothing happened! I then downloaded Firefly client which can connect directly to the mt-daapd server without any of the Bonjour service discovery magic. That worked fine. It could download my library just fine (about 12000 songs) and playback everything. Hmmm, I installed avahi-utils and ran

mediaserver2:~# avahi-browse -at
+ eth0 IPv4 iMac                                          SFTP File Transfer   local
+ eth0 IPv4 iMac                                          SSH Remote Terminal  local
+ eth0 IPv4 iMac [00:23:32:96:b2:29]                      Workstation          local
+ eth0 IPv4 Mediaserver2 [00:16:3e:22:22:22]              Workstation          local

Which showed that the iMac can be discovered just fine (and thus multicast seems to work :-)), but my server didn’t provide any services. So after a little googling, I figured out you need to create a daap.service file in the /etc/avahi/services directory:

<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<!-- See avahi.service(5) for more information about this configuration file -->
<service-group>
  <name replace-wildcards="yes">%h</name>
  <service>
    <type>_daap._tcp</type>
    <port>3689</port>
  </service>
  <service>
    <type>_rsp._tcp</type>
    <port>3689</port>
  </service>
</service-group>

Restart avaha-daemon and now the service is advertised:

mediaserver2:~# avahi-browse -at
+ eth0 IPv4 iMac                                          SFTP File Transfer   local
+ eth0 IPv4 iMac                                          SSH Remote Terminal  local
+ eth0 IPv4 iMac [00:23:32:96:b2:29]                      Workstation          local
+ eth0 IPv4 Mediaserver2 [00:16:3e:22:22:22]              Workstation          local
+ eth0 IPv4 Mediaserver2                                  iTunes Audio Access  local
+ eth0 IPv4 Mediaserver2                                  _rsp._tcp            local

And the server now shows up in iTunes! Nice. Unfortunately iTunes doesn’t support coverflow view on this library, but this seems to be a deliberate feature of iTunes and remote libraries 😦

2 responses to this post.

  1. […] Not tried yet, but may be interesting: it should be possible to share your music library via ZeroConf. Here’s more information. […]

    Reply

  2. […] Not tried yet, but may be interesting: it should be possible to share your music library via ZeroConf. Here’s more information. […]

    Reply

Leave a comment