Neat project! You could use WebCodec's ImageDecoder plus some custom controls to do this all in JavaScript without transcoding if you wanted. Otherwise you could use VideoEncoder and MSE for native video support.
https://developer.mozilla.org/en-US/docs/Web/API/WebCodecs_A... https://w3c.github.io/webcodecs/samples/ https://developer.mozilla.org/en-US/docs/Web/API/Media_Sourc...