FireFly

From AwkwardTV

Jump to: navigation, search

I wanted to be able to access my music library on all macs and PCs at home, so I decided to install a central media server on my AppleTV.
After a quick search on the options, I found mt-daapd, which is now called FireFlyMediaServer in its newer incarnation.


1. Requirements
- SSH-enabled appleTV
- FireFly Media Server


2. Getting the files
The FireFly Media Server can be downloaded from Roku. The version I used was the 1.1b1, which can be found at

http://forums.rokulabs.com/viewtopic.php?t=11098

After downloading the disk image, mount it (if not done automatically). On the mounted disk you will see 2 applescripts and 1 readme file, which we do not need. The only required file is "FireFly.prefPane"

Right-click on that file and choose "Choose Package Contents".
Browse through the directories: Contents > Resources

You will see the different languages supported and a couple of files.
One of those files is "Firefly Helper.app" (the .app extension may be invisible).

Right-click that "FireFly Helper.app" file and again choose "Show Package Contents".
Browse through the directories: Contents > Resources

You should now see a directory called "Server". Copy this to the Desktop.
Now tranfer this directory to the appleTV. I install my extra applications in a directory Applications in the home directory of the appleTV:

scp -1 -r ~/Desktop/Server frontrow@appletv.local:Applications/FireFly

Quicker method, without browsing to the directory or copying the Server directory to the Desktop:
Download and mount the disk image, then in the terminal enter:

scp -1 -r /Volumes/Install\ Firefly/Firefly.prefPane/Contents/Resources/Firefly\ Helper.app/Contents/Resources/Server frontrow@appletv.local:Applications/FireFly


3. Configure the server

Copy the sample configuration file below into a new file called "firefly.conf" and copy that file to the appleTV.
You might want to edit the "appletv" and "admin" passwords.
Also make sure that the music directories are filled in right (/Users/frontrow/Music). You can enter multiple directories by separating them by a comma (,). Subdirectories will automatically be scanned for compatible audio files.
I put the firefly.conf file in the main home directory of the appleTV (/Users/frontrow).

# $Id: mt-daapd.conf.templ 1000 2006-05-01 08:07:56Z rpedde $
#
# This is the mt-daapd config file.
#
# If you have problems or questions with the format of this file,
# direct your questions to rpedde@users.sourceforge.net.
#
# You can also check the website at http://mt-daapd.sourceforge.net,
# as there is a growing documentation library there, peer-supported
# forums and possibly more.
#

[general]

#
# web_root (required)
#
# Location of the admin web pages.
#
# If you installed from .RPM, .deb, or tarball with --prefix=/usr, then
# this is correct. 
#
# If you installed from tarball without --prefix=/usr, then the correct
# path is probably /usr/local/share/mt-daapd/admin-root.
#
# In the default Mac install, this is a relative path, compared to the server

web_root = /Users/frontrow/Applications/FireFly/admin-root

#
# port (required)
#
# What port to listen on.  Leave blank to auto-assign.  If the port is
# specified, and that port is already taken, the server will not start.
#

port = 

#
# admin_pw (required)
#
# This is the password to the administrative pages.  If blank, access
# will only be possible from the local host.
#
# In the default Mac install, this is left blank so that only local
# host control is allowed

admin_pw = admin


#
# db_type (required)
#
# This is what kind of backend database to store the song
# info in.  Valid choices are "sqlite" and "sqlite3".
#

db_type = sqlite

#
# db_parms
#
# This is any extra information the db needs to connect.
# in the case of sqlite and sqlite3, this is the name
# of the directory to store the database in
#
# If you installed from RPM or .deb, this path likely already
# exists.  If not, then you must create it.  The directory itself
# must be writable by the "runas" user.
#
# On the Mac, this lives in the Application Support folder, in our
# Firefly folder.
#

db_parms = /Users/frontrow/Applications/FireFly/

#
# mp3_dir (required)
#
# Location of the mp3 files to share.  Note that because the
# files are stored in the database by inode, these must be
# in the same physical filesystem.
# comma separated for multiple directories... -- Added by Thomas

mp3_dir = /Users/frontrow/Music

#
# servername (required)
#
# This is both the name of the server as advertised
# via rendezvous, and the name of the database
# exported via DAAP.  Also know as "What shows up in iTunes".
#

servername = AppleTV Music

#
# runas (required)
#
# This is the user to drop privs to if running as
# root.  If mt-daapd is not started as root, this
# configuration option is ignored.  Notice that this
# must be specified whether the server is running
# as root or not.
#
# This is also ignored on Windows.
#

runas = nobody

#
# playlist (optional)
#
# This is the location of a playlist file.
# This is for Apple-style "Smart Playlists"
# See the mt-daapd.playlist file in the 
# contrib directory for syntax and examples
#
# This doesn't control static playlists... these
# are controlled with the "process_m3u" directive
# below.
#
#
# On the Mac, this lives in our Firefly folder in Application Support

playlist = /Users/frontrow/Applications/FireFly/firefly.playlist

#
# password (optional)
#
# This is the password required to listen to MP3 files
# i.e. the password that iTunes prompts for
#

password = appletv

#
# extensions (optional)
#
# These are the file extensions that the daap server will
# try to index and serve.  By default, it only indexes and
# serves .mp3 files.  It can also server .m4a and .m4p files,
# and just about any other files, really.  Unfortunately, while
# it can *attempt* to serve other files (.ogg?), iTunes won't
# play them.  Perhaps this would be useful on Linux with
# Rhythmbox, once it understands daap.  (hurry up!)
#
# Failing that, one can use server-side conversion to transcode
# non-standard (.ogg, .flac) music to wav on the server side.
# See the ssc_* options below.
#
# To be able to index .ogg files, you'll need to have configured
# with --enable-oggvorbis.  For .flac, --enable-flac, for .mpc,
# --enable-musepack.
#

extensions = .mp3,.m4a,.m4p,.aiff

#
# ssc_codectypes (optional)
#
# List of codectypes for files that the daap server should
# perform internal format conversion and present to clients
# as WAV files.  The file extensions that these codectypes correspond
# to must also be present in 'extensions'
# configuration value, or files are not probed in the first
# place.
#
# Valid codectypes:
#
# mp4a - for AAC (.aac, .mp4, .m4a, .m4p)
# mpeg - for mp3
# wav - for wav
# wma - for wma
# ogg - for ogg
# flac - for flac (.flac, .fla)
# mpc for musepack (.mpc, .mpp, .mp+)
# alac for alac (.m4a)
#
# NOTE: 1.0b3 of the Mac server does not have support for transcoding
# Ogg and FLAC.  Stay tuned

ssc_codectypes = alac

#
# ssc_prog (optional)
#
# Program that is used in server side format conversion.
# Program must accept following command line syntax:
#     ssc_prog filename offset length ...
# Parameter filename is the real name of the file that is
# to be converted and streamed, offset is number of bytes
# that are skipped from the beginning of the _output_ file
# before streaming is started, length is length of the song
# in seconds (or zero).  All other possible arguments must
# be ignored.  The resulting wav file (or the rest of
# the file after initial seek) is written to the standard
# output by the ssc_prog program.  This is typically
# a script that is a front end for different conversion tools
# handling different formats.
#
# On the Mac, this is a relative path by default

ssc_prog = ./mt-daapd-ssc.sh

#
# logfile (optional)
#
# This is the file to log to.  If this is not configured,
# then it will log to the syslog.
#
# Not that the -d <level> switch will control the log verbosity.
# By default, it runs at log level 1.  Log level 9 will churn
# out scads of useless debugging information.  Values in between
# will vary the amount of logging you get.
#
# On the Mac, this lives in our Firefly folder in Application Support

logfile = /Users/frontrow/Applications/FireFly/firefly.log

#
# truncate (optional)
#
# If logging is configured and this flag is enabled, the
# server will truncate the log file each time it starts.
# This is a good idea for both disk space and readability.
#

truncate = 1

#
# art_filename (optional)
#
# There is experimental support thanks to Hiren Joshi
# (hirenj@mooh.org) for dynamically adding art to the id3v2
# header as it is streamed (!!).  If you were using a music system
# like zina or andromeda, for example, with cover art called 
# "_folderOpenImage.jpg", you could use the parameter
# art_file _folderOpenImage.jpg and if the file _folderOpenImage.jpg
# was located in the same folder as the .mp3 file, it would appear
# in iTunes.  Cool, eh? 
#

#art_filename = _folderOpenImage.jpg

#
# rescan_interval
#
# How often to check the file system to see if any mp3 files
# have been added or removed. 
#
# if not specified, the default is 0, which disables background scanning.
#
# If background rescanning is disabled, a scan can still be forced from the 
# "status" page of the administrative web interface
#
# Setting a rescan_interval lower than the time it takes to rescan
# won't hurt anything, it will just waste CPU, and make connect times
# to the daap server longer.
#
#

rescan_interval = 3600

# always_scan 
#
# The default behavior is not not do background rescans of the
# filesystem unless there are clients connected.  The thought is to
# allow the drives to spin down unless they are in use.  This might be
# of more importance in IDE drives that aren't designed to be run
# 24x7.  Forcing a scan through the web interface will always work
# though, even if no users are connected.

# always_scan = 0

# 
# process_m3u
#
# By default m3u processing is turned off, since most m3u files
# sitting around in peoples mp3 directories have bad paths, and
# I hear about it.  :)
#
# If you are sure your m3u files have good paths (i.e. unixly pathed,
# with relative paths relative to the directory the m3u is in), then
# you can turn on m3u processing by setting this directive to 1.
#
# I'm not sure "unixly" is a word, but you get the idea.
#
# On the Mac, process_m3u needs to be on in order to scan the iTunes
# database for playlists, so this is on in the default Mac install.

process_m3u = 1

#
# scan_type
# 
#
# This sets how aggressively mp3 files should be scanned to determine
# file length.  There are three values:
#
# 0 (Normal) 
#   Just scan the first mp3 frame to try and calculate size.  This will
#   be accurate for most files, but VBR files without an Xing tag will
#   probably have wildly inaccurate file times.  This is the default.
#
# 1 (Aggressive)
#   This checks the bitrates of 10 frames in the middle of the song.  
#   This will still be inaccurate for VBR files without an Xing tag,
#   but they probably won't be quite as inaccurate as 0.  This takes
#   more time, obviously, although the time hit will only happen the
#   first time you scan a particular file.
#
# 2 (Painfully aggressive)
#   This walks through the entire song, counting the number of frames.
#   This should result in accurate song times, but will take the most
#   time.  Again, this will only have to be incurred the first time
#   the file is indexed.
# 

scan_type = 2

#
# compress
#
# Whether to use gzip content-encoding when transferring playlists etc.
# This was contributed as a patch by Ciamac Moallemi just prior to the 0.2.1
# release, and as such, hasn't gotten as much testing as other features.
#
# This feature should substantially speed up transfers of large databases
# and playlists.
#
# It will eventually default to 1, but currently it defaults to 0.
#

#compress = 0

[scan]

#
# correct_order
#
# When set to 1, ensures that items in a playlist are returned in the
# order in which they are set in the playlist.  On platforms with
# limited memory, this may impose an unacceptable performance penalty,
# but on a PC or Mac, it's fine.
#
correct_order = 1

[plugins]
plugin_dir = /Users/frontrow/Applications/FireFly/plugins
plugins = ssc-script.so,rsp.so
[scanning]
ignore_dotfiles = 1



4. Firing up the engines
Log in on the appleTV and start the service by giving this command:

/Users/frontrow/Applications/FireFly/firefly -y -f -c /Users/frontrow/firefly.conf &

A lot of data will be spit out on the shell, but the last line should be similar to this:
"Scanned 972 songs (was 972) in 2 seconds"
Just tap "enter" on your keyboard to get a command prompt again.

You can now safely log out of your appleTV and the server will keep running.

If you get errors it may be because the permissions are wrong. Try changing the permissions of the FireFly directory:

chmod 777 FireFly
chown -R 777 FireFly

The flag -f make it run on foreground, If you are using Iscripts! you should not use the flag -f

Create a file called FireFly.sh in the ~/Documents/Scripts/

#!/bin/bash 
#
/Users/frontrow/Applications/FireFly/firefly -y -c /Users/frontrow/firefly.conf &


5. Connect to the server
Open iTunes on your mac (or PC) and the appleTV should appear in the "shared" part in column at the left (just under "Devices", in which your appleTV should be present).
Click on the "appleTV Music" (name can be changed in the config file) and you should see the songlist.
Just click play or double-click any song to get it streamed to you.


6. Extras
You can edit the configuration file through a webbased interface, right from your mac. Only requirement is that you did enter a password as admin_pw in the config file.
Point your browser to

http://appletv.local:1024/index.html
and enter as login 'admin', as password the one given in the config file (if you copied the above file: 'admin').

Of course you could write a LaunchAgent to automatically start up the firefly service on boot time, or add the startup command to the rc.local file.

--Tego 14:11, 24 March 2008 (CET)


If you wish to serve the same files which the AppleTV has in its iTunes library you need to change the location of the media files as follows:

mp3_dir = /mnt/Media/Media Files

Alternatively, you could create a symbolic link in /Users/frontrow/Music directory which point to the Media Files, however I have not tested this approach.

--PatentBoy 21:33, 26 March 2008 (CET)


If you leave the scan interval as stated above, a file scan will occur every 3600 seconds or once per hour. If you have a lot of files - 20,000 + for example - the scan could take upwards of 10 minutes. A better approach may be to disable the scan by preceding the command by a "#" character - #rescan_interval = 3600 - and simply force a scan in the webpage interface. This will ensure you don't burn excess cpu cycles supporting FireFly while you are using the AppleTV in other ways, watching movies or downloading songs for example.

To force a full scan of the music library simply kill the FireFly instance(s) running, delete the FireFly database (songs.db) located per the directive 'db_parms = /Users/frontrow/Applications/FireFly/' and restart the FireFly service.

--PatentBoy 21:45, 26 March 2008 (CET)

Personal tools