Difference between revisions of "Subsonic"

From ArchWiki
Jump to: navigation, search
m (Removed unnecessary "sudo" keywords.)
(37 intermediate revisions by 8 users not shown)
Line 1: Line 1:
 
[[Category:Audio/Video]]
 
[[Category:Audio/Video]]
[[Category:Daemons and system services]]
 
 
 
'''Subsonic''' is a music server that lets you store your music on one machine and play it from other machines, cell phones, via a web interface, or various other applications. It can be installed using the {{AUR|subsonic}} package on [[AUR]].
 
'''Subsonic''' is a music server that lets you store your music on one machine and play it from other machines, cell phones, via a web interface, or various other applications. It can be installed using the {{AUR|subsonic}} package on [[AUR]].
  
Line 7: Line 5:
 
===Run subsonic daemon NOT as root===
 
===Run subsonic daemon NOT as root===
  
Stop subsonic daemon is running
+
By default, subsonic runs as root. This can be changed at any time after installation, even if the daemon has never run.
  
# sudo /etc/rc.d/subsonic stop
+
Stop the daemon, if it's running:
  
Add a system user "subsonic" without home folder and add it to "audio" group if you want to use the "jukebox" feature
+
# rc.d stop subsonic
  
# sudo useradd --system --groups audio subsonic
+
Add a system user "subsonic" without home folder and add it to "audio" group if you want to use the [http://www.subsonic.org/pages/features.jsp jukebox] feature:
  
Change folder owners as follow. Path may changes; these are the default ones:
+
# useradd --system --groups audio subsonic
  
# sudo chown -R subsonic:subsonic /tmp/subsonic
+
Change folder owners as follow. Path may change, and the ones listed below are the current (2013-02-05) defaults. If the {{ic|transcode}} folder does not exist, you should [[#Install Transcoders]].
# sudo chown -R subsonic:subsonic /var/subsonic
+
# sudo chown -R root:root /var/subsonic/transcode
+
# sudo chown -R root:root /var/subsonic/jetty/*/webapp
+
  
Change this line in {{ic|/var/subsonic/subsonic.sh}}
+
# chown -R subsonic:subsonic /tmp/subsonic
 +
# chown -R subsonic:subsonic /var/subsonic
 +
# chown -R root:root /var/subsonic/transcode
 +
# chown -R root:root /var/subsonic/jetty/*/webapp
  
{{ic|<nowiki>${JAVA} -Xmx${SUBSONIC_MAX_MEMORY}m \</nowiki>}}
+
Change this line in {{ic|/var/subsonic/subsonic.sh}}:
  
with this one
+
${JAVA} -Xmx${SUBSONIC_MAX_MEMORY}m \
  
{{ic|<nowiki>sudo -u subsonic ${JAVA} -Xmx${SUBSONIC_MAX_MEMORY}m \</nowiki>}}
+
to this:
  
Restart subsonic daemon
+
sudo -u subsonic ${JAVA} -Xmx${SUBSONIC_MAX_MEMORY}m \
  
  # sudo /etc/rc.d/subsonic start
+
and restart the subsonic daemon.
 +
 
 +
  # rc.d start subsonic
 +
 
 +
===Install Transcoders===
 +
 
 +
By default, Subsonic uses FFmpeg to transcode videos and songs to an appropriate format and bitrate on-the-fly. After installation, you can change these defaults so that, for example, Subsonic will transcode FLAC files using FLAC + LAME instead of FFmpeg. At a minimum, you should [[pacman|Install]] the {{Pkg|ffmpeg}} package from the [[Official Repositories|official repositories]]. You may also want to install {{Pkg|flac}} and {{Pkg|lame}}.
 +
 
 +
For security reasons, Subsonic will not search the system for any transcoders. Instead, the user has to create links to the necessary transcoders in the {{ic|/var/subsonic/transcode}} folder. Create the {{ic|transcode}} folder if it does not already exist, then make the necessary symlinks.
 +
 
 +
# mkdir /var/subsonic/transcode
 +
$ cd /var/subsonic/transcode
 +
# ln -s `which ffmpeg`
 +
# ln -s `which flac`
 +
# ln -s `which lame`
 +
 
 +
Finally, restart subsonic daemon.
 +
 
 +
# rc.d start subsonic
 +
 
 +
=== Systemd Setup ===
 +
 
 +
The subsonic installation includes a systemd service file. To install it:
 +
 
 +
# cp /var/subsonic/subsonic.service /usr/lib/systemd/system/subsonic.service
 +
 
 +
Then, run:
 +
 
 +
# systemctl --system daemon-reload
 +
 
 +
And finally enable it:
 +
 
 +
# systemctl enable subsonic.service
  
 
==Troubleshooting==
 
==Troubleshooting==
Line 39: Line 69:
  
 
If you start subsonic using {{ic|/etc/rc.d/subsonic}}, and your /etc/[[rc.conf]] has {{ic|<nowiki>DAEMON_LOCALE="no"</nowiki>}}, then the subsonic daemon will be started with the C locale, and Java will skip any folders with "international characters" (e.g. ßðþøæå etc.). Either set {{ic|DAEMON_LOCALE}} to {{ic|"yes"}} (but this will affect '''all''' rc.daemons), or add a line to the beginning of {{ic|/var/subsonic/subsonic.sh}} which sets {{ic|LANG}} to an installed UTF-8 locale, e.g. {{ic|<nowiki>LANG=nn_NO.utf8</nowiki>}}.
 
If you start subsonic using {{ic|/etc/rc.d/subsonic}}, and your /etc/[[rc.conf]] has {{ic|<nowiki>DAEMON_LOCALE="no"</nowiki>}}, then the subsonic daemon will be started with the C locale, and Java will skip any folders with "international characters" (e.g. ßðþøæå etc.). Either set {{ic|DAEMON_LOCALE}} to {{ic|"yes"}} (but this will affect '''all''' rc.daemons), or add a line to the beginning of {{ic|/var/subsonic/subsonic.sh}} which sets {{ic|LANG}} to an installed UTF-8 locale, e.g. {{ic|<nowiki>LANG=nn_NO.utf8</nowiki>}}.
 +
 +
===FLAC playback===
 +
 +
The FFmpeg transcoder doesn't handle FLAC files well, and clients will often fail to play the resultant streams. (at least, on [[User:Ichimonji10|my]] machine) Using FLAC + LAME instead of FFmpeg solves this issue. This workaround requires that the FLAC and LAME transcoders have been installed, as explained in [[#Install Transcoders]].
 +
 +
Start Subsonic and go to {{ic|settings > transcoding}}. Ensure that the default FFmpeg transcoder does not get used on files with a "flac" extension, then add a new entry. You'll end up with something like this:
 +
 +
{| class="wikitable" border="1" cellpadding="5" cellspacing="0"
 +
! Name !! Convert from !! Convert to !! Step 1 !! Step 2
 +
|-
 +
| mp3 default || ... NOT flac ... || mp3 || ffmpeg ... || &nbsp;
 +
|-
 +
| mp3 flac || flac || mp3 || flac --silent --decode --stdout %s || lame --silent -h -b %b -
 +
|}
  
 
==External links==
 
==External links==
 
* [http://www.subsonic.org Official web site]
 
* [http://www.subsonic.org Official web site]

Revision as of 15:10, 12 February 2013

Subsonic is a music server that lets you store your music on one machine and play it from other machines, cell phones, via a web interface, or various other applications. It can be installed using the subsonicAUR package on AUR.

Additional config

Run subsonic daemon NOT as root

By default, subsonic runs as root. This can be changed at any time after installation, even if the daemon has never run.

Stop the daemon, if it's running:

# rc.d stop subsonic

Add a system user "subsonic" without home folder and add it to "audio" group if you want to use the jukebox feature:

# useradd --system --groups audio subsonic

Change folder owners as follow. Path may change, and the ones listed below are the current (2013-02-05) defaults. If the transcode folder does not exist, you should #Install Transcoders.

# chown -R subsonic:subsonic /tmp/subsonic
# chown -R subsonic:subsonic /var/subsonic
# chown -R root:root /var/subsonic/transcode
# chown -R root:root /var/subsonic/jetty/*/webapp

Change this line in /var/subsonic/subsonic.sh:

${JAVA} -Xmx${SUBSONIC_MAX_MEMORY}m \

to this:

sudo -u subsonic ${JAVA} -Xmx${SUBSONIC_MAX_MEMORY}m \

and restart the subsonic daemon.

# rc.d start subsonic

Install Transcoders

By default, Subsonic uses FFmpeg to transcode videos and songs to an appropriate format and bitrate on-the-fly. After installation, you can change these defaults so that, for example, Subsonic will transcode FLAC files using FLAC + LAME instead of FFmpeg. At a minimum, you should Install the ffmpeg package from the official repositories. You may also want to install flac and lame.

For security reasons, Subsonic will not search the system for any transcoders. Instead, the user has to create links to the necessary transcoders in the /var/subsonic/transcode folder. Create the transcode folder if it does not already exist, then make the necessary symlinks.

# mkdir /var/subsonic/transcode
$ cd /var/subsonic/transcode
# ln -s `which ffmpeg`
# ln -s `which flac`
# ln -s `which lame`

Finally, restart subsonic daemon.

# rc.d start subsonic

Systemd Setup

The subsonic installation includes a systemd service file. To install it:

# cp /var/subsonic/subsonic.service /usr/lib/systemd/system/subsonic.service

Then, run:

# systemctl --system daemon-reload 

And finally enable it:

# systemctl enable subsonic.service

Troubleshooting

UTF-8 file names not added to the database

You must have at least one UTF-8 locale installed.

If you start subsonic using /etc/rc.d/subsonic, and your /etc/rc.conf has DAEMON_LOCALE="no", then the subsonic daemon will be started with the C locale, and Java will skip any folders with "international characters" (e.g. ßðþøæå etc.). Either set DAEMON_LOCALE to "yes" (but this will affect all rc.daemons), or add a line to the beginning of /var/subsonic/subsonic.sh which sets LANG to an installed UTF-8 locale, e.g. LANG=nn_NO.utf8.

FLAC playback

The FFmpeg transcoder doesn't handle FLAC files well, and clients will often fail to play the resultant streams. (at least, on my machine) Using FLAC + LAME instead of FFmpeg solves this issue. This workaround requires that the FLAC and LAME transcoders have been installed, as explained in #Install Transcoders.

Start Subsonic and go to settings > transcoding. Ensure that the default FFmpeg transcoder does not get used on files with a "flac" extension, then add a new entry. You'll end up with something like this:

Name Convert from Convert to Step 1 Step 2
mp3 default ... NOT flac ... mp3 ffmpeg ...  
mp3 flac flac mp3 flac --silent --decode --stdout %s lame --silent -h -b %b -

External links