Does computeFrame have to return a "new" Uint8Array, or am I guaranteed that encodeMP4 won't call it again until it is done with the previous one, allowing me to re-use the same one? ArrayBuffer initiation is still a huge bottleneck on many browsers, so this could be a nice optimization for any situation involving software rendering
Usage of the array is strictly synchronous so that you can use it, modify it, and return the same buffer time and time again. I removed that from the example since it seemed not strictly necessary to convey, but maybe that’s worth keeping in. And of course, my wrapper, to reiterate, is just silly eye candy over the synchronous wasm based module which is not at all hard to use if your needs become more specific.
There are also some tricks like asking wasm for a no-copy view of the heap, to which you could write directly, though I’m not sure a copy is significant relative to other things like the speed of encoding.