Results 1 to 6 of 6

Thread: How many seconds user was watching video?

  1. #1
    Join Date
    Jun 2014

    Post How many seconds user was watching video?


    I'd like to implement my own statistics sytem. I'm using this code to count how many seconds user was watching video but my tests are different then reality. For example i'm watching video and shutdown player in 10 sec. but logs show me then I was watching video 15 sec. I tested this module in RTMP, RTSP na HLS streaming but always result are bad. How can I solve this problem? Maybe someone has better method to do this?

    Example below:

    public void onStreamDestroy(IMediaStream stream)
    		getLogger().info("onStreamDestroy() - invoked");
    		IOPerformanceCounter perf = stream.getMediaIOPerformance();
    		Long outbytes = perf.getMessagesOutBytes();
    		getLogger().info("Outbytes: " + outbytes);
    		Double outrate = perf.getMessagesOutBytesRate();
    		getLogger().info("OutRate: " + outrate);
    		Double seconds = outbytes / outrate;
    		getLogger().info("Seconds: " + seconds);	

    After 10 sec logs show:

    INFO server comment - Outbytes: 2526989
    INFO server comment - OutRate: 80634.0
    INFO server comment - Seconds: 31.339000917727013
    It's 21 sec. mistake.
    Last edited by summer_soon; 06-20-2014 at 04:33 AM.

  2. #2
    Join Date
    May 2013


    If you are looking to obtain information on a given session/client connection, you might review our serverinfo HTTP Provider source code as a starting point. There are even elapsed time and time running related functions that could be of use on a per connection basis.

  3. #3
    Join Date
    Jun 2014


    I tried use ElapsedTimer:

    public void onStreamDestroy(IMediaStream stream) {
    		getLogger().info("Seconds: " + iClient.getElapsedTime().getTimeSeconds());
    but result is also wrong.

  4. Default


    Wowza Wrench has a feature that allows you to measure the elapsed time per user. It also uses client.getElapsedTime().getTimeSeconds() under the hood. When I was investigating time differences, I found that maybe connections are administered periodically in Wowza and that's why there is a varying difference between the time you see and the time the client object reports. There are some idle* settings in VHost.xml which might have effect on this. Would be good to get some official explanation on the inaccuracy we both saw.
    Last edited by matt_y; 07-08-2014 at 01:30 AM.

  5. #5
    Join Date
    May 2013


    You might try eliminating the global variable for iClient and utilizing the following:
    Alternatively, it may prove more precise to check this within the onDisconnect event as follows:
     public void onDisconnect(IClient client) {
      getLogger().info("onDisconnect: " + client.getElapsedTime().getTimeSeconds());

  6. Default


    Can you explain why can may it be more precise withing onDisconnect..? And why we are seeing difference between the time we measure and what the client object reports..?

Similar Threads

  1. Insufficient permissions with ec2-user SSH user, how to log in as wowza user?
    By elyngved in forum Wowza Media Server 3 for Amazon EC2 Discussion
    Replies: 2
    Last Post: 05-24-2013, 01:39 PM
  2. Replies: 2
    Last Post: 08-19-2012, 06:34 AM
  3. Video Streaming terminating 5 seconds before the end of the video
    By rminari in forum Performance Tuning Discussion
    Replies: 4
    Last Post: 05-15-2012, 04:48 AM
  4. time watching video - vod app
    By Reinaldo Almeida in forum Server-side Modules and Code Samples Discussion
    Replies: 3
    Last Post: 01-20-2012, 01:32 PM
  5. Replies: 2
    Last Post: 11-24-2011, 09:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts