phoboslab / jsmpeg

MPEG1 Video Decoder in JavaScript
MIT License
6.34k stars 1.43k forks source link

WebWorker #157

Open samsonradu opened 7 years ago

samsonradu commented 7 years ago

Would it be more effective to offload the decoding process to a WebWorker (perhaps also the WebSocket conn) and just do the Canvas render in the main thread?

EDIT

WebGL in a web worker is also possible in Mozilla.

rwrzesniewski commented 7 years ago

It most definately would, we did that for one of the previous versions of the jsmpeg and it wokred like a charm. Definately thumbs up for the feature request :)

samsonradu commented 7 years ago

I've made some research and managed to offload all the video decoding and canvas rendering to a WebWorker in Firefox only (which is already great). Still looking if this is possible in Chrome/Safari.

https://hacks.mozilla.org/2016/01/webgl-off-the-main-thread/

The AudioContext does not work yet in a web worker afaik. There's the AudioWorklet draft but it's not ready yet.

https://github.com/WebAudio/web-audio-api/wiki/AudioWorklet-Examples