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

Improve frame count for dom videos #866

Open
ivmartel opened this issue Feb 8, 2021 · 1 comment
Open

Improve frame count for dom videos #866

ivmartel opened this issue Feb 8, 2021 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@ivmartel
Copy link
Owner

ivmartel commented Feb 8, 2021

The calculation of the number of frames for dom videos is based on a hard coded frame rate (see domReader.js#L133). This leads to the generation of images larger that necessary.

A first improvement would be to not store all frames but check the video.currentTime to see if it is close to the seeked one. Something like a if (Math.abs(nextTime - video.currentTime) < 1e-8).

Another one would be to use the `` (see video-rvfc draft and video-rvfc repo). For now it is only supported on chrome based browser: caniuse requestvideoframecallback). The code would look like:

video.addEventListener('ended', function () {
  onload({
    source: origin
  });
  onloadend({
    source: origin
  });
});

var frameCb = function (/*now, metadata*/) {
  // repeat
  video.requestVideoFrameCallback(frameCb);
  // store
  // warn: if placed before the frame request, will
  //   skip the second frame, I guess because of the call
  //   to context.draw...
  storeFrame();
};
video.requestVideoFrameCallback(frameCb);

video.loop = false;
video.autoplay = false;
video.muted = true;
video.currentTime = 0;

video.play();

Both solution need to rethink how the number of frames is passed to the app.

@ivmartel ivmartel added the enhancement New feature or request label Feb 8, 2021
@ivmartel ivmartel added this to the Future milestone Feb 8, 2021
@ivmartel
Copy link
Owner Author

ivmartel commented Feb 8, 2021

Some notes:

ivmartel added a commit that referenced this issue Feb 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant