Weekend Hack: Raspberry Pi hosted Jellyfin alternative
I've been a long time Jellyfin user since the Emby days. The server as well as clients are well-designed and do the job most of the time. The latest version irons out quite a few long-standing issues. So, out of no real necessity, I began thinking - "What's the lightest, most performant media streaming server I could run for devices on the LAN?"
So I did the following:
- A folder on the Raspberry Pi that contains all media files is mounted on my laptop using SSHFS. This can be accessed on Android devices using Solid Explorer's SFTP plugin. Ingestion is by copying files over the LAN
- A simple zx shell script watches the folder for changes and automatically dumps thumbnails is a predefined "meta" directory. Flat structure, dupes be damned. And no fancy metadata lookup required
- Use Caddy for simple, efficient, lightweight HTTP/2 streaming. Caddy's built-in file-server combined with Basic Auth and directory indexing goes a long way
- Rude surprise: HTTP/2 is HTTPS by default. Okay, let's do this the right way:
a. Use a subdomain on an already purchased public domain ('A' record points to public IP only)
b. Use acme.sh with ZeroSSL and DNS API w/ Cloudflare DNS (enable API access) to generate certificates for a subdomain
c. Script to copy generated certs fromacme.sh
home to Raspberry PI
d. Configure Caddyfile to usetls <cert> <keyfile>
e. Configure Pi-Hole, which was already my local network DNS resolver, to have a DNS override pointing the subdomain to the Raspberry Pi LAN IP
f. Took longer than I thought. All for a tiny boost in network streaming perf. Phew! - Web Client
a. Frontend client is basically a Caddy directory listing parser w/ video.js player (could've done a JSON API, but this was quite simple)
b. Thin endpoint API in Caddy that does some rewrite URL stuff to lookup media thumbnails in the right location
c. Search function: all done in the frontend. Media files are organized in folders, but thumbnails are dumped into a single predefinedmeta
directory (dupe handling is ignored). Search loads the entire metadata file list and does a fuzzy lookup