Coder Social home page Coder Social logo

rvfc-polyfill's Introduction

requestVideoFrameCallback polyfill

Usage:

npm install rvfc-polyfill
import 'rvfc-polyfill'

Warning: this polyfill is at BEST roughly accurate as it runs using RAF, which is bound to the window's framerate, unlike RVFC which is bound to the video's framerate [but still capped by the window's framerate].

Because this polyfill uses RAF, the timestamps reported are ones used by the DOM renderer, rather than video decoder. Notable differences:

  • presentationTime - time when a new painted frame was detected, this is the time of when a RAF was fulfilled + the time it took to paint the last frame [rough estimate]
  • expectedDisplayTime - time when the RAF was fulfilled + the time it takes to render a frame on the browser
  • mediaTime - time of the video when the RAF was fulfilled - processingTime [this ISNT the video time when a video frame was decoded, but is closely accurate]
  • presentedFrames - if the video framerate is higher than the browser window framerate, this will omit frames
  • processingDuration - time it took to paint a frame

Notable examples: Given a video with 50 fps and having the browser window limited to 60 fps the mediaTime reported will be in order:

By the original:

  • 0.001
  • 0.021
  • 0.043
  • 0.064
  • 0.084
  • 0.106

By this polyfill:

  • 0.001
  • 0.027
  • 0.041
  • 0.066
  • 0.081
  • 0.108

[+- 5ms as the highrestimestamps reported by browsers are marginally inaccurate] which means the times arent inline with the video frames

rvfc-polyfill's People

Contributors

thaunknown avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.