My self-hosted music streaming solution
To skip the boring memories and go straight to the technical part.
I am a millenial, born at the end of the 80s, and my listening-to-music history is probably rather typical of my generation in the so-called “western world”.
First I listened to music from cassettes, you know, those rectanglish things you could rewind with a pencil. I still remember that the first cassette I bought with my own money was Americana by The Offspring*. Later on came the audio CDs and the Discman that would chew through the batteries painfully fast. But this blog post is not about the physical media, it’s about listening to music on a computer.
*The Kids Aren’t Alright hits very different now
My first source of music in the form of digital files, something like 20 years ago, was the world of p2p file sharing. Everyone around had Kazaa, BearShare, Limewire. We would download music not by album, but by single files, burn them on CDs and share between ourselves. From time to time someone would download a banger such as linkin_park-one_step_closer.mp3.exe
and brick the family computer, but that was an inherent part of the Internet experience at the time. People would amass collections of thousand of mp3 files, barely fitting on the 20GB hard drives of the times. Winamp was an indispensable software, and downloading new skins for it a fun activity.
Years passed, I went to university, started my first real work, and then came the time of music streaming services. My first one was Deezer, later I moved to Tidal because I got a free year with my phone plan, and finally I landed on Spotify, mostly because of the network effect. And using them at the beginning was exciting, it felt both like the future and something proper adults should do. I was earning my own money and now I was spending it on music, funding the artists. I did not have to store music in files, I could just stream it to anywhere!
And now we are where we are. With the increasing enshittification (1) (2) (3) of music streaming services, and my move to more local, private software solutions, using Spotify or Deezer or Youtube Music has lost its appeal. I just want to buy music and have it on my storage on my own terms, and give money to artists that make it.
I ended my Spotify subscription months ago. I buy albums from Bandcamp (which I know has its own share of issues) or from other places where the artists share their music, I am again buying physical media. Once again I have music in the form of files on my hard drive.
And as I am a homelabber and selfhoster, I did not want to just copy files from my NAS to my desktop, laptop and phone, I wanted a solution to access my music wherever I am.
Streaming music from a NAS
The server
I am storing the mp3 files on my server at home. The files live in Nextcloud which is running in an LXD container and uses my mirrored ZFS pool as storage. I can access Nextcloud from anywhere using WireGuard VPN. Before I switched to WireGuard, I had been using Tailscale to have access to my private data. I already talked about those topics in previous blog posts:
Deploying Nextcloud locally with LXD
Access local Nextcloud with HTTPS anywhere by using Tailscale TLS certificates
New, leaner network setup: removing NATs, and ditching Tailscale
So now I have access to my private files even when I am away from home, but how to actually listen to them?
Nextcloud has an app called simply “Music”, which allows listening to music via the Nextcloud Web UI. Installing it is easy, you just need to have an account with administrative rights, and find the app in the app store built-in into Nextcloud. Later it’s only a matter of pointing the app to the folder when you are storing the music, and le voila, files get loaded, and can be played from the browser.
The downsides are you need a browser to play then this way, and the app has no means to edit mp3 tags or scrobble to Last.fm. Yes, I still use Last.fm.
My last.fm account is so old, I created it before even coming up with stfn
.
But the Music app has a trick up its sleeve. It can work as a server for any apps that use either the Ampache or Subsonic protocols. Auth is being done via generated API credentials.
Nextcloud Music settings with information how to configure the music clients
The clients
For listening to music on other computers I use Strawberry. Strawberry is a fork of an older music player called Clementine (Oh the FOSS naming), and has support for the Subsonic protocol, and supports scrobbling to several services. But it cannot edit tags of external files.
On my Android (fair)phone I use Power Ampache 2. Sadly, it does not support scroblling, but apart from that works just fine. It allows downloading songs to the phone for playing them when offline.
Editing mp3 tags in Linux
As I mentioned before, neither Nextcloud Music nor Strawberry allow editing mp3 tags, and that is something so very much needed from time to time.
I’m handling that problem in two ways. For small edits I access the terminal in the LXD container and edit the files using the command line tool id3v2. Not the simplest way, but it’s fast for single files.
For larger edits, I use EasyTAG, but that requires downloading the music files to my personal computer, editing them locally, and reuploading to Nextcloud.
The bottom line
And that’s it, this is how I stream music these days. One less reliance on large corporations who are never your friends, and one more usecase for my homelab.
And I’m a nostalgic person, and once again having audio files makes me feel like going back to those old days when I would burn CDs full of Nightwish, Metallica and Evanescence to listen to on my way to high school. Wake me up, wake me up inside.
PS. I just checked and the Managed Nextcloud service offered by Hetzner supports the Music app, so it can be used instead of a NAS for people who don’t want to or cannot have file storing hardware at home. Hetzner is not paying me for this recommendation, actually I am paying them to host all my public-facing stuff, and I think they are a company worth recommending :)
Thanks for reading!
If you enjoyed this post, please consider helping me make new projects by supporting me on the following crowdfunding sites: