It looks like I can crib most of what I need from Jellyfin's DynamicHlsController, which --
Goodness, this API is giving me flashbacks to every API controller I've ever worked on professionally that had 300 million parameters. At least they're documented.
Anyway, I think I just need to make one of these giant VideoRequestDto objects, pass it to StreamingHelpers.GetStreamingState
, and then give that to ITranscodeManager.StartFfmpeg
, which starts my process. This all feels suspiciously like a leaky abstraction over a bare call to FFmpeg, but whatever, it's not my code (and since Jellyfin itself is just a fork of Emby, it probably wasn't their code either).
[30 minutes later]
Oh no. I have to build all of these DTOs and then build the command-line arguments to FFmpeg myself? What's the point of the abstraction then?
I've become really disillusioned with REST APIs over the years. I don't think they were ever a good fit for most applications beyond simple CRUD operations; REST always felt too academic, like trying to make your entire database meet third normal form but then needing a ton of complex stored procedures to actually manipulate it. The "stateless" part especially kills me, because you need to ship giant blobs of JSON around in order to avoid hitting the database for the same information multiple times (and is that really such a huge problem?), but then you end up with absolutely massive, poorly documented JSON schemas -- kind of like this Jellyfin API. Fun in theory, but what does it actually accomplish?
Also, trying to pack application-level semantics into HTTP response codes is a disaster. I spent a few hours once trying to figure out why an API was returning 404 to me, only to discover that it wasn't the API itself, it was actually a load balancer in front of the API. The second T in "HTTP" stands for "transport," not "this customer's account has a moratorium in effect."
I'm convinced REST is near the root of reasons why I burned out. Not to say I'm not guilty of rejecting pull requests because pushes up glasses this should actually return 409 Conflict, not 400 Bad Request. I like to think I've grown since then.
Maybe I'm a masochist, but I love this part of writing code against legacy codebases -- write some code, run it, hit a null reference exception, go look at the code to figure out which property I didn't set correctly, set it correctly, get a little farther into the method you're calling, repeat ad nauseam.
Eventually, you don't get a null reference exception, and you stare at the debugger, waiting for it to break, and...
You get a Dolby Vision MP4 file remuxed from an MKV! Yay!