Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR new stats #20

Open
Niko78 opened this issue Jun 27, 2017 · 1 comment
Open

PR new stats #20

Niko78 opened this issue Jun 27, 2017 · 1 comment

Comments

@Niko78
Copy link

Niko78 commented Jun 27, 2017

After talking with @lucasrodcosta he asked me to post a PR here.
I worked a bit to ouput "latency" and "current buffer"
I'm not a dev so I do my best but I'm sure there are better ways to do it

current buffer
hls.on(Hls.Events.LEVEL_LOADED,function(event,data) {
var pos = video.currentTime;
var bufferLen = video.buffered.end(0) - pos;
console.log('CURRENT BUFFER : ' + bufferLen.toFixed(2) + ' seconds');
});

=> I detected an issue about current buffer in my code but I don't know yet how to fix it : when encoder is started if I stop it then restart it, value begins to be negative because of video.buffered.end(0) which is frozen to a very small value (0.0x)

latency (it needs EXT-X-PROGRAM-DATE-TIME header)
hls.on(Hls.Events.LEVEL_LOADED,function(event,data) {
var current = video.currentTime;
var frag = data.details.fragments[0].start;
var tps = current - frag;
var now = new Date();
var unixnow = Date.parse(now)/1000;
var tunix = Date.parse(data.details.fragments[0].rawProgramDateTime)/1000;
var latence = unixnow - tunix - tps;
console.log('LATENCY : ' + latence.toFixed(2) + ' seconds');
});

I made some tests and It works rather well.

Nico

@leandromoreira
Copy link
Member

Thanks, @Niko78 we need to have in mind that this only works for the hls.js playback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants