Untitled
unknown
plain_text
10 months ago
1.1 kB
4
Indexable
function measureFps(video) {
var {
corruptedVideoFrames,
creationTime,
droppedVideoFrames,
totalVideoFrames
} = video.getVideoPlaybackQuality();
function calculate() {
const now = video.getVideoPlaybackQuality();
const totalFrames = now.totalVideoFrames - totalVideoFrames;
const droppedFrames = now.droppedVideoFrames - droppedVideoFrames;
const corruptedFrames = now.corruptedVideoFrames - corruptedVideoFrames;
const elapsed = now.creationTime - creationTime;
console.log(`Total frames: ${totalFrames}`);
console.log(`Dropped frames: ${droppedFrames}`);
console.log(`Corrupted frames: ${corruptedFrames}`);
console.log(`Elapsed time: ${elapsed}`);
console.log(`FPS: ${(1_000 * totalFrames / elapsed).toFixed(1)}`);
totalVideoFrames = now.totalVideoFrames;
droppedVideoFrames = now.droppedVideoFrames;
corruptedVideoFrames = now.corruptedVideoFrames;
creationTime = now.creationTime;
}
setInterval(calculate, 1_000);
}
measureFps(document.getElementById("video"));Editor is loading...
Leave a Comment