TIL counting viewers of an HLS live stream is a hard fucking problem and there's no right answer. It's all based on heuristics and approximations.

This stems from the fact that viewers are just constantly making intermittent http calls for the .ts fragments of the stream. That's basically a huge mess to figure out who is connected since it's not long lasting.

There seems to be 3 main ways to count:

* Using an analytics proxy server 🤮🤮🤮

* Using the current number of established tcp inbound connections to port 443 from unique IPs

* Parsing the webserver (nginx) logs to make sense of it.

My question is, with so many good technical alternatives, why did the world settled on HLS as the standard for livestreams? It sucks.

Reply to this note

Please Login to reply.

Discussion

See it as a feature, not as a bug.

It's a common issue with livestreams. I've setup rtmp servers and the same thing. New connections and dropped connections. The approach of watching IP's or using a cookie is typically the easiest way to evaluate users.