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

wip live #15

Closed happylinks closed 1 year ago

happylinks commented 1 year ago

@Vanilagy Hey, sorry I didn't realise I had opened the PR it to your repo already. I've been working on live-streaming webm with your repo, I couldn't get it to work with the ideas you had in https://github.com/Vanilagy/webm-muxer/issues/12. For live to get working, I removed a lot from this repo, but we can of course make it a mode instead of removing this all.

I had to:

Most of the disabling is because you shouldn't write stuff in the past (like you mentioned as well).

I probably removed too much, and maybe not everything is needed, I just pushed what I got working now :)

I can open a new PR where I implement it a lot cleaner with a mode, do you have any suggestions on how you would add this in that I can take into account?

I also changed the demo to record the camera, because I needed that, maybe we can make 2 demo's if it makes sense.

Edit: And thanks a lot for this repo! The code was easy to understand, and it's helping us to do WebCodecs -> Webm muxer -> FFmpeg.js DASH in the browser!

Vanilagy commented 1 year ago

Thanks for the work! Obviously, I can't merge something like this in because it removed large parts of the codebases. Regarding a proper implementation of live-streaming, I'd have to read into it a bit more, but I guess it does iindeed boil down to not writing into the past. So, off the top of my head:

I would not disable writing the CodecPrivate info, as those are crucial for decoding; what we should do instead is wait, before writing out the tracks definition part, for the first chunks from all relevant media in the file. Then, when we have all of the relevant metadata, we can flush out the tracks part with correct CodecPrivate (and even without using any EBML Voids!)

And then add a config flag to enable this. We could call it streaming: boolean, or something more technical like monotonic: boolean, with proper descriptions in the README.

happylinks commented 1 year ago

Yep, I understand. I'll work on this a bit and will open a proper PR with a streaming property. Thanks for the suggestions, I'll keep that in mind. I already added "unknown" support in the write target in this PR, so will copy that over. Will come back to you early next week with the first version :)