Jump to content
  • 0

How is hlsViewerCount calculated?


Mark Sergienko
 Share

Question

  • Answers 8
  • Created
  • Last Reply

Top Posters For This Question

8 answers to this question

Recommended Posts

  • 0
you can use rest api for couting the viewers

On 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

  • 0
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  Speed
100   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 viewers

On 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

  • 0
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  Speed
100   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 viewers

On 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

  • 0
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 advice

On 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  Speed
100   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 viewers

On 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

  • 0
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 

Mark

On 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

  • 0
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.


Best Regards,
Selim

On 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

  • 0
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,
Alex

On 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 

Mark

On 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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share


×
×
  • Create New...