Self-hosted music streaming
I wanted a self-hosted music player alternative to google music and the bandcamp web player. Here’s the steps I took.
Download music from bandcamp
I sometimes remember to download the files when I purchase music on bandcamp but I’m not diligent about it.
I used the batchcamp extension on Firefox to make it easier for me to download the ones I’d missed.
I decided to download them as FLAC files, since this is a lossless format but with smaller file sizes than WAV.
I stored the original FLAC files in my Dropbox.
Set up Navidrome
I installed Navidrome to act as my music server. I could self-host this, but it’s easier to use a pikapod.
I added a pod running navidrome. I then logged in, created an admin account and then a regular user account. I logged out and logged in as the latter.
I turned on the files option in the Pikapod admin panel and copied the SFTP credentials so I could connect to it and add my music. There isn’t a web-based way to add files as far as I can see.
Transcode audio (optional)
A typical album in FLAC format runs around 0.5GB-1GB. My complete bandcamp collection came to 90GB. I could pay for a pikapod with this much storage, or self-host one. But as I mostly listen to music on the go or on basic sound systems, my ears cannot tell the difference if I used a compressed format. I decided to go with the Opus codec at 96kb.
I first copied my entire music directory to a new location to easily preserve the folder structure, cover art etc.
I installed parallel find alternative fd (https://github.com/sharkdp/fd) with
sudo apt-get install fd-find
Then inside the music folder I ran
fdfind -t f -e flac -x ffmpeg -i "{}" -c:a libopus -b:a 96k "{.}.opus"
This left me with a .flac and .opus file for each audio file.
I then removed the .flac versions, since I have a copy of those elsewhere
fdfind -t f -e flac -x rm -f "{}"
This took a few minutes to run and reduced the size of the library to less than 10% of the original
~/music_transcodes ❯ du -hs
7.6G .
Add music to Navidrome
I connected to my Navidrome using the SFTP credentials in the Gnome Files application using the connection string sftp://username@server.
Once connected I saw a data, libraries and music directory. Navidrome has support for multiple users and libraries but I decided to put all my music under music.
I copied all of the transcoded album directories from the previous step into this directory. This step took a while as it is dependent of network speed.