hey there,having a bit of an issue with views counter - it works, but it counts all views except publisher's as localhost. Wtf?
location /views {
# Disable cache
add_header Cache-Control no-cache;
# CORS setup
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
add_header 'Access-Control-Allow-Headers' 'Range';
# allow CORS preflight requests
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Headers' 'Range';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
proxy_pass http://127.0.0.1/stat;
xslt_stylesheet html/nclients.xsl app='$arg_app' name='$arg_name';
add_header Refresh "3; $request_uri";
}
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:param name="app"/>
<xsl:param name="name"/>
<xsl:template match="/">
<xsl:value-of select="count(//application[name=$app]/live/stream[name=$name]/client[not(publishing)])"/>
</xsl:template>
</xsl:stylesheet>
also, next time pls write in bold that in order to hookup xsl template you'll need libxml2 and libxslt1.1
How do i also display the status of a stream of an app (online/offline)?
In your "query" you have
not(publishing)
so it won't count publisher.
@misiek08, obviously, but the problem is - stats won't record views for hls streams except the publisher and localhost, wtf?

Is it that bad for DASH as well?
HLS and DASH are delivered by HTTP protocol, not RTMP. Their statistics are not counted with this module, because this module was only RTMP module at the beginning. Adding http stats requires your own logic, it's not built-in for HLS and DASH.
@misiek08 is there an existing solution for this?
Also, what about the second part of the issue:
How do i also display the status of a stream of an app (online/offline)?
(separately throught the xslt template to at least monitor the status and pass it to my php app)
Monitoring if stream is online can be made by checking if there is any "publishing" client in app.
There are probably some solutions for HLS and DASH, but I haven't seen anything good or perfect. Many people have their private solution and don't share them because it requires knowledge and some time to complete.
@misiek08
how about streamstate? Am i missing something?
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:param name="app"/>
<xsl:param name="name"/>
<xsl:template match="/">
<xsl:value-of select="//application[name=$app]/live/stream[name=$name]/streamstate"/>
</xsl:template>
</xsl:stylesheet>
I'll be doing this by firing off commands via the html5 player when a user presses start and stop etc... Once I have some working code I'll post it here.
@UKNickyD would love to check out your solution...
@misiek08 thanks for the insight into the issue... Considering this is something that I (and many others) need, I'd love to collaborate on a solution.
What that solution would be, you probably know better than me. But seeing the # of viewers for a livestream is pretty crucial to the experience, and it would be great to support this. hlswatch is underway, but I'm not sure if it's actively maintained.
Most helpful comment
HLS and DASH are delivered by HTTP protocol, not RTMP. Their statistics are not counted with this module, because this module was only RTMP module at the beginning. Adding http stats requires your own logic, it's not built-in for HLS and DASH.