Show HN: I MitM'd Plex to make remote streaming suck less (github.com)
After getting laid off a while back, I started working on a degree online. It seemed like a good opportunity to spend some time traveling too, so I signed up for Starlink and got a friend to host my Plex server in his basement for the duration. Surely that would be good enough to watch whatever from where-ever.
Turns out that no, it's not. Plex really doesn't like streaming over Starlink. It would top out at 8-9mbps in good conditions, often dropping down to 2 or 3, while other streams and downloads would happily hum along at 100mbps+.
I spent a little time looking into the issue early on. None of the remote or server network changes I could think of made a noticable difference. Customizing Plex's internal MPV configuration to increase the chunk size and buffer limit helped a bit, but it was still too slow to watch anything in realtime.
My best guess was that the problem largely boiled down to a combination of Starlink's fairly frequent latency spikes and Plex's short timeouts. With things at school winding down, I decided to finally put that to the test by building some kind of caching proxy.
Initially the plan was to MITM the client/server connections so it could serve everything out of a cache and set it up to proactively cache things in the background. Once the client and server were talking reliably through the proxy, I realised those features wouldn't really be necessary. All it needed was a bit of parallelism and patience.
With my particular setup, 5 workers can reliably pull down segments at ~35-40mbps, adding another 5 pushes that up to about 60mbps. Either is more than enough to stream anything 1080p in realtime and 60mbps can handle almost anything 4K HDR. Ended up building the prefetching features despite that, because at that point why not?
Fast-forward a few days and I'm willing to call this a Good Enough first version. There are plenty of significant limitations and rough edges. It's almost entirely vibecoded and far from my best work ever. There's enough spaghetti under the hood that I have to actively avoid thinking about it. It works well enough that I don't have to start buffering a TV show 2 hours before I plan to watch it though, and that's what matters.
This is a niche tool for a niche problem. I don't really expect this to be of much use to anyone. It was a fun project though and a satisfying solution to an irritating problem, so thought I'd share it anyway.
2 comments
[ 4.1 ms ] story [ 12.0 ms ] thread