Mark Sergienko Posted April 19, 2020 Share Posted April 19, 2020 It seems like HLS Viewer Count is higher than the actual number of HLS viewers. What is the method it's calculated by? It shows anywhere from 6 to 14 viewers when there's only one person watching. Anyone got a formula how to find exact number of viewers? Thanks, Mark Link to comment Share on other sites More sharing options...
0 Sherin Fathima Posted April 19, 2020 Share Posted April 19, 2020 you can use rest api for couting the viewersOn Sunday, April 19, 2020 at 9:20:55 PM UTC+5:30, Mark Sergienko wrote:It seems like HLS Viewer Count is higher than the actual number of HLS viewers. What is the method it's calculated by? It shows anywhere from 6 to 14 viewers when there's only one person watching. Anyone got a formula how to find exact number of viewers? Thanks, Mark Link to comment Share on other sites More sharing options...
0 Ray Jender Posted April 20, 2020 Share Posted April 20, 2020 Rest api is broke. That's how the management page gets the count. Here is the rest output with only one viewer! root@AMSC1:/usr/local/antmedia/webapps# curl -X GET "http://localhost:5080/WebRTCApp/rest/broadcast/get?id=stream1" | json_pp | grep hls % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed100 709 100 709 0 0 98k 0 --:--:-- --:--:-- --:--:-- 98k "hlsViewerCount" : 13, On Sunday, April 19, 2020 at 11:56:00 AM UTC-4, Sherin Fathima wrote:you can use rest api for couting the viewersOn Sunday, April 19, 2020 at 9:20:55 PM UTC+5:30, Mark Sergienko wrote:It seems like HLS Viewer Count is higher than the actual number of HLS viewers. What is the method it's calculated by? It shows anywhere from 6 to 14 viewers when there's only one person watching. Anyone got a formula how to find exact number of viewers? Thanks, Mark Link to comment Share on other sites More sharing options...
0 Mark Sergienko Posted April 20, 2020 Author Share Posted April 20, 2020 This is consistent with what I'm getting.That is why I'm curious with how HLS Viewer count is calculated in Ant Media On Monday, 20 April 2020 07:58:56 UTC-4, Ray Jender wrote: Rest api is broke. That's how the management page gets the count. Here is the rest output with only one viewer! root@AMSC1:/usr/local/antmedia/webapps# curl -X GET "http://localhost:5080/WebRTCApp/rest/broadcast/get?id=stream1" | json_pp | grep hls % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed100 709 100 709 0 0 98k 0 --:--:-- --:--:-- --:--:-- 98k "hlsViewerCount" : 13, On Sunday, April 19, 2020 at 11:56:00 AM UTC-4, Sherin Fathima wrote:you can use rest api for couting the viewersOn Sunday, April 19, 2020 at 9:20:55 PM UTC+5:30, Mark Sergienko wrote:It seems like HLS Viewer Count is higher than the actual number of HLS viewers. What is the method it's calculated by? It shows anywhere from 6 to 14 viewers when there's only one person watching. Anyone got a formula how to find exact number of viewers? Thanks, Mark Link to comment Share on other sites More sharing options...
0 Mark Sergienko Posted May 7, 2020 Author Share Posted May 7, 2020 So apparently this has to do with Cookies (I'm assuming ant media server should set / check a cookie on requests to HLS ts files)I could not find any reference to where this should be set. Please adviceOn Monday, 20 April 2020 09:23:33 UTC-4, Mark Sergienko wrote:This is consistent with what I'm getting.That is why I'm curious with how HLS Viewer count is calculated in Ant Media On Monday, 20 April 2020 07:58:56 UTC-4, Ray Jender wrote: Rest api is broke. That's how the management page gets the count. Here is the rest output with only one viewer! root@AMSC1:/usr/local/antmedia/webapps# curl -X GET "http://localhost:5080/WebRTCApp/rest/broadcast/get?id=stream1" | json_pp | grep hls % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed100 709 100 709 0 0 98k 0 --:--:-- --:--:-- --:--:-- 98k "hlsViewerCount" : 13, On Sunday, April 19, 2020 at 11:56:00 AM UTC-4, Sherin Fathima wrote:you can use rest api for couting the viewersOn Sunday, April 19, 2020 at 9:20:55 PM UTC+5:30, Mark Sergienko wrote:It seems like HLS Viewer Count is higher than the actual number of HLS viewers. What is the method it's calculated by? It shows anywhere from 6 to 14 viewers when there's only one person watching. Anyone got a formula how to find exact number of viewers? Thanks, Mark Link to comment Share on other sites More sharing options...
0 Alex O Posted June 7, 2020 Share Posted June 7, 2020 Any update on this? Needing accurate numbers for licensing, so can't use this until it's fixed (if there are plans to fix it). Link to comment Share on other sites More sharing options...
0 Mark Sergienko Posted June 7, 2020 Author Share Posted June 7, 2020 HI Alex, Actually we dug into the problem and found the following: - To count number of HLS viewers antmedia is using Cookies - You need to enable crossorigin="use-credentials" on your <video tag - Once you enable you will see Headers like Set-Cookie: JSESSIONID=09C9C61FFBxxxx64B0E93D; Path=/xxx; Secure; HttpOnly - You need to then configure CORS options to allow your origin specifically (not through *) - See config in webapps/WebRTCAppEE/WEB-INF/web.xml for cors.allowed.origins - also there's a bug where after reconnect HLS count is negative (issue created) You're welcome MarkOn Sunday, 7 June 2020 11:19:11 UTC-4, Alex O wrote:Any update on this? Needing accurate numbers for licensing, so can't use this until it's fixed (if there are plans to fix it). Link to comment Share on other sites More sharing options...
0 Selim Emre Posted June 14, 2020 Share Posted June 14, 2020 Hi everyone! I just upgraded a new structure in this case. Let me explain how we collect HLS viewers. In the HLS viewer's side, All sessions counting 1 real viewer. So, every different session counting as 1 HLS Viewer. Also, we upgraded new performance improvement in HLS Viewer side. HLS Viewer Count upgrading every 10 seconds with each session. More detail in the code side :) -> https://github.com/ant-media/Ant-Media-Server/blob/master/src/main/java/io/antmedia/statistic/HlsViewerStats.java Best Regards, SelimOn Sunday, April 19, 2020 at 6:50:55 PM UTC+3, Mark Sergienko wrote:It seems like HLS Viewer Count is higher than the actual number of HLS viewers. What is the method it's calculated by? It shows anywhere from 6 to 14 viewers when there's only one person watching. Anyone got a formula how to find exact number of viewers? Thanks, Mark Link to comment Share on other sites More sharing options...
0 Alex O Posted June 20, 2020 Share Posted June 20, 2020 Hi Mark, Thanks for this info, though I have to say that this has gone completely over my head and seems a bit complicated. We don't use a video tag, so would a div with an alternative player, so would act the same way? <div class="video_container"> <div class="video" id="player"></div> <script> var player = new Clappr.Player({ source:"STREAM_URL", poster: "./assets/img/video_poster.jpg", parentId: "#player", height: '100%', width: '100%', }); </script> </div>If that would work the same way, by inserting the 'crossorigin' into the div tag above somewhere, where will I see these headers you speak of?I'm using the community edition so my install doesn't have webapps/WebRTCAppEE/, but webapps/WebRTCApp/ instead. Does configuring the web.xml file in that folder still work? If so, what am I replacing the '*' with? Don't quite understand the 'origin' that is meant to be entered. Is it just the URL of the stream?Also, as far as I'm aware, my site doesn't require cookies with my current setup for AMS. If I enable the above, would I then have to ensure all GDPR notices/warning were in place for this to work?Thanks,AlexOn Sunday, June 7, 2020 at 5:55:00 PM UTC, Mark Sergienko wrote:HI Alex, Actually we dug into the problem and found the following: - To count number of HLS viewers antmedia is using Cookies - You need to enable crossorigin="use-credentials" on your <video tag - Once you enable you will see Headers like Set-Cookie: JSESSIONID=09C9C61FFBxxxx64B0E93D; Path=/xxx; Secure; HttpOnly - You need to then configure CORS options to allow your origin specifically (not through *) - See config in webapps/WebRTCAppEE/WEB-INF/web.xml for cors.allowed.origins - also there's a bug where after reconnect HLS count is negative (issue created) You're welcome MarkOn Sunday, 7 June 2020 11:19:11 UTC-4, Alex O wrote:Any update on this? Needing accurate numbers for licensing, so can't use this until it's fixed (if there are plans to fix it). Link to comment Share on other sites More sharing options...
Question
Mark Sergienko
Link to comment
Share on other sites
Top Posters For This Question
4
2
1
1
Popular Days
Apr 19
2
Apr 20
2
Jun 7
2
May 7
1
Top Posters For This Question
Mark Sergienko 4 posts
Alex O 2 posts
Ray Jender 1 post
Sherin Fathima 1 post
Popular Days
Apr 19 2020
2 posts
Apr 20 2020
2 posts
Jun 7 2020
2 posts
May 7 2020
1 post
8 answers to this question
Recommended Posts