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?
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:
It's 21 sec. mistake.
INFO server comment - Outbytes: 2526989
INFO server comment - OutRate: 80634.0
INFO server comment - Seconds: 31.339000917727013