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

Web Workers #34

Open
positlabs opened this issue Dec 7, 2015 · 4 comments
Open

Web Workers #34

positlabs opened this issue Dec 7, 2015 · 4 comments

Comments

@positlabs
Copy link
Contributor

Recording at high res / fps is pretty choppy. Is there some way we can improve this by offloading the .toDataURL() call to web workers? I assume that is where the bottleneck is, but I don't think you can reference dom elements in worker scripts.

Thoughts?

@antimatter15
Copy link
Owner

Yeah you can't reference DOM elements in worker scripts, so unfortunately
it probably isn't possible to parallelize by using webworkers.

On Mon, Dec 7, 2015 at 2:59 PM, Josh Beckwith notifications@github.com
wrote:

Recording at high res / fps is pretty choppy. Is there some way we can
improve this by offloading the .toDataURL() call to web workers? I assume
that is where the bottleneck is, but I don't think you can reference dom
elements in worker scripts.

Thoughts?


Reply to this email directly or view it on GitHub
#34.

@positlabs
Copy link
Contributor Author

Ok, so we definitely need to call canvas.toDataURL() to get the webp format, right? What if we did something like cached the frames until whammyVid.compile() is called? context.getImageData() is probably pretty fast compared to canvas.toDataURL(). Then we could draw all of those frames back on to a canvas, and call .toDataURL() on them during the compile step. It might make compilation noticeably slower, but I think it's worth making things smoother during capture.

@positlabs
Copy link
Contributor Author

I've just tried it. This method of delayed encoding works perfectly. It's almost an order of magnitude faster, during recording (at least for my application).

Current Whammy: https://youtu.be/QK9AOAvGMsw

Delayed encoding: https://youtu.be/99Kob5Xv0Yk

@rikkertkoppes
Copy link

rikkertkoppes commented May 12, 2017

delayed encoding turns out to be a huge benefit while recording video on mobile. Built in MediaRecorder api results in choppy video, Whammy saved the day here.

However, the encoding process really stalls the interface afterwards.

I'd like to point to the OffscreenCanvas interface:

This is not yet there, but may provide even further improvements during the compile phase by actually using webworkers for that

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