Untitled

 avatar
unknown
plain_text
6 months ago
1.1 kB
3
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