thenickdude / webm-writer-js

JavaScript-based WebM video encoder for Google Chrome
272 stars 43 forks source link

Using WebMWriter inside a WebWorker #39

Open dayaftereh opened 2 years ago

dayaftereh commented 2 years ago

I would like to use the WebMWriter inside a WebWorker, but I get the exception

'window' is not defined

Some digging in the code I found that window is used at:

https://github.com/thenickdude/webm-writer-js/blob/62cc83222c01288c1488dd75c31f2a385a83b346/src/WebMWriter.js#L43

Changing the line to:

return self.atob(url.substring("data:image\/webp;base64,".length)); 

solved the issue.

nuthinking commented 2 years ago

@dayaftereh Do you get better performances?

dayaftereh commented 2 years ago

@nuthinking I haven't measured the performance yet. I'm transfering a video frame by frame to the WebWorker. A the WebWorker I run some green screen removing and 2d particle simulation by redraw everything with an offscreen canvas. I do all the stuff at the WebWorker to keep the Main-Loop responsive.

nuthinking commented 2 years ago

I don't need the main loop to be responsive, but I really need to find ways to speed up the recording. See #40 . Any tips on how to move it to a WebWorker so that I can test it? If passing the same frame to multiple workers doesn't take many milliseconds. I might be able to cut the time needed by half. Thanks!