Vanilagy / webm-muxer

WebM multiplexer in pure TypeScript with support for WebCodecs API, video & audio.
https://vanilagy.github.io/webm-muxer/demo
MIT License
197 stars 12 forks source link

Stream to web storage #34

Closed nsharma1396 closed 3 months ago

nsharma1396 commented 3 months ago

Hi @Vanilagy

Just wanted to check if there is any way that we can use the streaming option to stream data to web storage like IndexedDB. I would like to avoid array buffer target as the in-memory usage may increase for larger videos but I do not have the flexibility to prompt for saving to a file hence was wondering if an in-memory streaming option is available somehow

Thanks, Neeraj

Vanilagy commented 3 months ago

You can't really "stream" to IndexedDB sadly, which is the problem here. Of course, we could chunk it up and write multiple ArrayBuffers into IndexedDB, but reading the file and playing it back is the issue then in that case. If we had an entire Blob storing the media in the IndexedDB, that would solve the problem (because the browser intelligently reads from the Blob), but to write the Blob we need to have the entire video in memory, so that's no option here.

I suggest you look into using the OPFS instead of IndexedDB! This will solve your problem and does not require you to ask for user permission, and you can use it to store large files you can incrementally write to.

nsharma1396 commented 3 months ago

Awesome! Thanks, will take a look into it 👍