

But for livestreaming audio/video, this basically describes all the backend needs. You'd need to improve on the pseudo code a lot before it would actually be a viable option. This is grossly oversimplifying how it really would work.

Let stream = fs.createReadStream("path/to/video.mp4") say, we wait until there are 10 seconds left in the video to load the next chunk. nd((currentVideoBuffer - video.currentTime) >= 10) I didn't implement throttling, but in pseudo-code terms, the way I would do that is: It just pipes the video to the client, no throttling, and works very well. I ran a quick test on my browser with a 1-minute video and localhost. You can then send this to the client in a big stream.Īnother, probably better way to do this, is have the client establish a WebSocket, with the client requesting chunks of video, and the server using writeStreams to pipe the selected portions down to the client. const crypto = require("crypto")Ĭonst browser = getClientConnectionSomehow()Ĭonst encryptor = crypto.createCipheriv("aes256", "32 character long string", Buffer.alloc(16))įs.createReadStream("path/to/video.mp4").pipe(encryptor).pipe(browser) Encrypting audio/video can be done manually by your server.
