Settings for Transcoding in Subsonic (Linux)

If you also have many music files in flac format, it is frustrating that the default configuration of Subsonic won’t play them.  This is easy to fix.  I began with the following transcoding settings (from the Subsonic Forum,  thanks to jeremyh):


Name: mp3 audio
Convert From: ogg oga aac m4a flac wav wma aif aiff ape mpc shn
Convert To: mp3
Step 1: avconv -i %s -b %bk -q 0 -loglevel error -f mp3 –
Step 2: (blank)


At first this did not work, even though I’d installed avconv and all codecs through my package manager.  I discovered that Subsonic was only searching in /var/subsonic/transcode for the avconv binary.  This limited Subsonic to using the converters that were installed with it.  I suppose this is intentional, to maintain compatibility on diverse systems and avoid the need for users to find/download/install the converters.

Instead of tweaking the environment variable for the Subsonic user, I opted to symlink some specific binaries.

Edit:  Apparently the path for user subsonic is correct.  It could be that Subsonic is hard-coded to ignore it.  If anyone reading this knows the answer it could be interesting, but for now all is working so I’ll leave it alone.

From /var/subsonic/transcode I ran:


ln -s  /usr/bin/avconv avconv

ln -s /usr/bin/nice nice


The reason I symlinked nice is to be able to reduce processor load during transcoding; more about this below.

I had also symlinked lame in the past, but avconv is able to do everything I need now.

With all that done and confirmed working, I edited Step 1 of the transcoding instruction to:


nice -n15 avconv -i %s -b %bk -q 0 -loglevel error -f mp3 –


Each time the avconv process starts, it is reniced to 15.  This means it has a lower priority than most other processes.  If some more important process needs to do something, avconv will get out of the way for a while.

I use the official Android client for Subsonic on my phone.  I set it to preload (cache) an unlimited number of songs from my playlist, which helps me quickly load music for offline listening.  This can occupy the Pi for a while, but renicing avconv helps ensure that this process doesn’t interfere with other tasks on the Pi.

 

Hardware:  Raspberry Pi B+

Operating System:  Raspbian

Subsonic Version:  5.2.1 for Debian/Ubuntu (deb)


Edit June 1/2016:

Now my Subsonic installation is up to version 6 and running on an AMD64 system with Debian 7 (openmediavault).  For a while, even before Subsonic 6, there would be stoppages in playback of flac files.  The backend was transcoding the file over and over during the song, each time getting further from the start and eventually not being able to keep up with playback.

I think it’s something to do with the adaptive transcoding, adjusting the bitrate as the song plays but being unable to transcode only part of the file as needed rather than starting from the beginning.  It could be due to the use of metaflac as the first step in playback.

Using instructions from the Arch Wiki (https://wiki.archlinux.org/index.php/Subsonic) I set my flac transcoding to:

Step 1:  flac –silent –decode –stdout %s

Step 2: lame –silent -h -b %b –

Now it works interruption-free except it takes a long time for playback to start in the default Subsonic web interface.  It’s seamless with D-sub though.

The whole reason for employing metaflac in step 1 was to overcome playback problems with certain flac files.  Now I can’t remember which files were the problem, so I’ll need to test further.