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

Support for OffscreenCanvas #11

Open
nahkd123 opened this issue Apr 30, 2020 · 2 comments
Open

Support for OffscreenCanvas #11

nahkd123 opened this issue Apr 30, 2020 · 2 comments

Comments

@nahkd123
Copy link

It would be nice if webm writer support OffscreenCanvas, because I'm trying to do render stuffs inside web worker. As far I know, you can get the WebP blob by using OffscreenCanvas#convertToBlob({type: "image/webp"})

@guest271314
Copy link
Contributor

You can pass the Blob from convertToBlob() to FileReader or FileReaderSync readAsDataURL(), then pass the data URL to addFrame()

(async _ => {
  const osc = new OffscreenCanvas(1,1);
  const osctx = osc.getContext('2d');
  const blob = await osc.convertToBlob({type:'image/webp'});
  const frs = new FileReaderSync();
  const canvas = frs.readAsDataURL(blob);
  videoWriter.addFrame(canvas);
})();

@dayaftereh
Copy link

I use the WebMWriter with an OffscreenCanvas inside a WebWorker and came across the exception:

Failed to find VP8 keyframe in WebP image, is this image mistakenly encoded in the Lossless WebP format?

To solve the issue I changed the quality of the conversion to

const blob = await osc.convertToBlob({type:'image/webp', quality: 0.9999});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants