2011-04-03

Subsonic refusing to play some OGG files

I stumbled upon some tracks refusing to be played in subsonic when using the web-player (no problem in jukebox mode). The web-player mode is doing some transcoding with ffmpeg, the jukebox mode does not requires it. OGG files were not affected by this problem.

Some errors from the log file around the problematic file:
DEBUG InputStreamReaderThread - (/var/subsonic/transcode/ffmpeg) [NULL @ 0x9b45bc0]Format detected only with low score of 24, misdetection possible!
DEBUG InputStreamReaderThread - (/var/subsonic/transcode/ffmpeg) [mp3 @ 0x9b46df0]Header missing

Looking closer to the problematic files showed an ID3v2 header at begin of the file, followed by the expected Ogg header. After removing the ID3v2 header (using the great 'tag'), the problem was gone.

This just showed that ffmpeg is a bit sensible to the tags in the audio files. Of course, these tags should not have been there. However, VLC and foobar had no problem with these (buggy) files.

Non-root subsonic installation

I choose already for some time subsonic as music streaming and jukebox system. This was working well with the basic installation information provided from the website:

sudo apt-get install openjdk-6-jre
sudo dpkg -i subsonic-x.x.deb
sudo apt-get install lame flac faad vorbis-tools ffmpeg

First problem: no sound in jukebox mode. The solution is to install the java from sun, and use this one instead of the openjdk provided by default.

sudo apt-get install sun-java6-jre sun-java6-plugin

Installing is only half of the job. Selecting what java to use is done with following command:

update-java-alternatives -s java-6-sun

Second problem: subsonic is now running as root. This is not a big deal when the server is intended to be use behind your firewall, but becomes a bit scary when allowing access from internet. The solution is described in the official subsonic forum. I preferred the second post of the thread explaining how to do the changes to run as a specific user still using the simple package based installation. The first post requires to configure your own web-server, a bit more complex for similar result.

I used slightly different commands:
sudo su
service subsonic stop
adduser --system --no-create-home subsonic
adduser subsonic audio
chown -R subsonic:nogroup /tmp/subsonic 
chown -R subsonic:nogroup /var/subsonic 
chown -R root:root /var/subsonic/transcode 
chown -R root:root /var/subsonic/jetty/*/webapp

Now we need to edit /usr/share/subsonic/subsonic.sh to use sudo -u subsonic before the call to java. The line looks like that with the change applied:

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

Now subsonic can be started, and we can verify it uses the correct assigned user instead of root. Start subsonic: service subsonic start.

ps -Af | grep subsonic shows what user runs subsonic.

To finish, enjoy some music :)