As a developer it's rare to see something which leaves me feeling "how would you even build something like that..." but this is one of those. Huge cudos for even attempting and following through with something like this!
Isn't this no longer an issue thanks to SharedArrayBuffer?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
I believe the ONNX Runtime uses this for multithreading on the web, see https://github.com/nagadomi/nunif/issues/34
Web Codecs can take a compressed media packet and get you the decoded image or audio buffer it corresponds to. Conversely it can take audio or images with timestamps and get you a series of encoded media packets you can then containerize (we say mux) and get you e.g. an mp4 file.
I don't know if this project uses it, but there's ffmpeg.wasm [1].