1 Star 0 Fork 0

fengyongjun/nginx-rtmp-module-m

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
getting_number_of_subscribers.md 1.08 KB
一键复制 编辑 原始数据 按行查看 历史
Jan Stabenow 提交于 9年前 . MOD move wiki to /docs

Getting number of subscribers

There's an easy way to display number of clients watching the stream. You need to

Set up statistics page at location /stat

location /stat {
    rtmp_stat all;
    allow 127.0.0.1;
}

Create a simple xsl stylesheet nclients.xsl extracting number of stream subscribers

<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) and flashver])"/>
</xsl:template>

</xsl:stylesheet>

Set up a location returning number of suscribers

location /nclients {
    proxy_pass http://127.0.0.1/stat;
    xslt_stylesheet /www/nclients.xsl app='$arg_app' name='$arg_name';
    add_header Refresh "3; $request_uri";
}

Use HTTP request http://myserver.com/nclients?app=myapp&name=mystream to get the number of stream subscribers. This number will be automatically refreshed every 3 seconds when opened in browser or iframe.

Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/fengyongjun/nginx-rtmp-module-m.git
git@gitee.com:fengyongjun/nginx-rtmp-module-m.git
fengyongjun
nginx-rtmp-module-m
nginx-rtmp-module-m
dev

搜索帮助