Closed zenkyuv closed 6 days ago
This repository is home to the Web Codecs specification.
Questions on how to do something with Web Codecs are better suited to Stack Overflow, for example.
That said, please have a look at the dequeue event, and the concept of codec saturation: https://w3c.github.io/webcodecs/#dom-audioencoder-ondequeue, https://w3c.github.io/webcodecs/#saturated, and it will become clear: you're not supposed to keep a thousand frames around in general, you're likely to use all memory of the computer. For example if your frames are standard 1920 * 1080 pixels in YUV420 (2 bytes per pixel), and you have exactly 1000 buffered at the input of the decoder, it goes:
(1920 1080 2 * 1000) / 1024 / 1024 / 1024 ≈ 3.86GB of memory
In contrast, a decoder buffers encoded media, which is much much smaller. It's also not a good idea to keep 20k elements buffered at its input either.
Im trying to understand what is causing such massive ram usages, ive isolated it and seems like when video encoder's encodeQueueSize hits about 1000 items, memory starts to spike really quick taking all of it and crashing browser, whereas its not a problem for decoder to have like 20k items in queue and probably even more but havent tested with bigger videos, is there any way to work around this without sacrificing performance ?