My primary music library is in lossless FLAC format, which Subsonic, by default, transcodes to mp3 for streaming to PC’s and mobile devices.
I’ve always used a two-step transcode for this as FFmpeg doesn’t always handle FLAC files as well as other formats, which can result in streaming problems.
You can use FLAC in step 1 to decode the initial stream and pipe it to stdout: –
This can be followed by lame to read from stdin and transcode to mp3: –
I recently discovered the Fraunhofer FDK-AAC codec that Google have open sourced as part of Android.
Here’s what FFmpeg say about the fdk-aac codec: –
The Fraunhofer FDK AAC codec library. This is currently the highest-quality AAC encoder available with ffmpeg. Requires ffmpeg to be configured with --enable-libfdk-aac (and additionally --enable-nonfree if you’re also using --enable-gpl). But beware, it defaults to a low-pass filter of around 14kHz ( details). If you want to preserve higher frequencies, use -cutoff 18000. Adjust the number to the upper frequency limit you prefer, keeping in mind that a higher limit may audibly reduce the overall quality.
This codec can be enabled in FFmpeg, but usually requires re-compiling from source, I found a simple script on github that made that dead easy on Fedora (the distro used by Vortexbox): –
Once this script has finished you will have a new version of FFmpeg compiled and located in /usr/local/bin
Subsonic does not use the system FFmpeg, it has its own stored in /var/subsonic/transcode
From this path, move or delete the existing FFmpeg binary and symlink to the newly compiled version: –
All that remains to do now is to set up subsonic to transcode to aac, instead of mp3: –
Save the settings and you should be ready to go, you will notice that mobile devices will now show flac > m4a as the transcoding settings: –
You can experiment with settings and bitrate, but overall aac should allow you to use lower bitrates for the same perceived quality, improving streaming efficiency and reducing bandwidth use. Bitrate can be adjusted on a per-user basis within Subsonic’s settings.
You may also wish to experiment with the low-pass filter option too (-cutoff), by default there’s a 14kHz filter, reducing high frequency content, to allow more bits for the lower frequency sounds, but depending upon your ears and your music content this can be adjusted using FFmpeg’s -cutoff switch: –
-cutoff 16000 (filter sounds above 16kHz)
-cutoff 18000 (filter sounds above 18kHz)
Have fun, let me know what settings you settle on, I’m still experimenting here.