ennuicastr / libavjs-webcodecs-polyfill

A polyfill for the WebCodecs API. No, really.
82 stars 8 forks source link

Support for Web Workers #22

Closed RavikumarTulugu closed 8 months ago

RavikumarTulugu commented 8 months ago

I am getting an error "document is not defined" while trying to call LibAVWebCodecs.load() from a web worker. Is this library meant to be used in browser ?? or is it just meant for node. I tried importing worker-utils and then ran into some other errors and a warning that the file is only meant for node environment. I was trying to use it with libav.js for aac encoding as the chrome does not support aac encoding yet. Please advise. Thanks & regards

Yahweasel commented 8 months ago

document would certainly not be defined in Node, but it also wouldn't be defined in a Worker. It's meant to be used only from browsers, but I never particularly worked to make it work in Workers; the actual processing work it does is always in a worker, so there's not a need to run the polyfill itself from a worker. That being said, that's obviously not especially general, so I'll rename this issue as a bug about working in Workers. The biggest problem with working in Workers is that the DOM spec provides no way for me to make, e.g., frames transferable, so even if it all works in workers, transferring data would be problematically slow.

Yahweasel commented 8 months ago

(Incidentally, it's not quite accurate to say that Chrome doesn't support encoding AAC. Whether it supports AAC depends on platform details.)

RavikumarTulugu commented 8 months ago

All of our encoding and decoding and muxing logic is inside a worker, the main thread just forwards raw video frames and gets back muxed chunks. The intent of looking at the polyfill library was , that i was reluctant to use libavjs low level api and preferred webcodecs polyfill. is it an easy bug to fix or needs effort. Do you advise to wait couple of days/weeks for the fix or will it take time ?

Yahweasel commented 8 months ago

My suspicion is that it shouldn't take more than a small number of hours when I get the chance (probably some time this week), just bear in mind that this is volunteer work on my spare time ;)

Yahweasel commented 8 months ago

Another issue I will mention as it'll come up for you: if you want AAC support, you're going to have to add it yourself. I neither support nor intend to support any codecs by the Misanthropic Patent Extortion Gang (MPEG).

Yahweasel commented 8 months ago

Resolved in f6a8feb576d660bd6635f474d8476b76575df8b9