I'm building a web app that is able to stream 9 live video from our server and I would like to dive deeper and improve the web performance by inspecting the FPS rate for each video. By that I mean I'm trying to get number of frames that graphic hardware trying to render in one second.
This is the FPS meter provided by Chrome. Is there a way to build my own FPS meter that corresponds to the videos? Each video should have its own meter running.
Update 1
I have tried using this Library and the result is kinda peculiar.
var stats1 = new Stats(); stats1.setMode( 0 );
var vSource = 'trailer.mp4';
var myVideo1 = document.createElement( 'video' );
myVideo1.width = 512;
myVideo1.src = vSource;
myVideo1.controls = 'true';
var myTable = document.getElementById('myTable');
var row1 = document.getElementById('row1');
row1.appendChild( stats1.domElement );
row1.appendChild(myVideo1);
setInterval( function () {
stats1.begin();
myVideo1.play();
stats1.end();
}, 1000 / 24 );
This is the library snippet that I'm using Link
begin: function () {
startTime = Date.now();
},
end: function () {
var time = Date.now();
ms = time - startTime;
msMin = Math.min( msMin, ms );
msMax = Math.max( msMax, ms );
msText.textContent = ms + ' MS (' + msMin + '-' + msMax + ')';
updateGraph( msGraph, Math.min( 30, 30 - ( ms / 200 ) * 30 ) );
frames ++;
if ( time > prevTime + 1000 ) {
fps = Math.round( ( frames * 1000 ) / ( time - prevTime ) );
fpsMin = Math.min( fpsMin, fps );
fpsMax = Math.max( fpsMax, fps );
fpsText.textContent = fps + ' FPS (' + fpsMin + '-' + fpsMax + ')';
updateGraph( fpsGraph, Math.min( 30, 30 - ( fps / 100 ) * 30 ) );
prevTime = time;
frames = 0;
}
return time;
},
update: function () {
startTime = this.end();
}
My concern is, the algorithm seems to be wrong and the result I'm getting is not 'right'.....
The original intent of the library is to measure Javascript Performance, can I use it to measure specific video FPS?