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

Writing to disk via node #27

Closed nsharma1396 closed 8 months ago

nsharma1396 commented 10 months ago

Hi @Vanilagy! First of all, thank you for creating this amazing library and for the active maintenance. This is super helpful for a use case that I have been working on.

I was following this comment and had a couple of doubts:

  1. For writing to disk in node.js environment, would you suggest using StreamTarget with a chunked approach or without the chunked approach and why so?
  2. For StreamTarget, is backpressure being handled by default via the library as writing to the WriteStream will require this capability to be present at some point so that the writes happen efficiently.

Another quick question, is it possible to increase the width, height or bitrate configurations of the Muxer midway

Thanks, Neeraj

Vanilagy commented 10 months ago

Hi! Thanks for the kind words!

It's not possible to change the configuration mid-encoding. I mean, you could try, but the behavior is undefined - there's no support for crazy files that change dimensions somewhere in the middle, sorry!

Regarding the other questions:

  1. I'd say a chunked approach is much recommended. This is way easier for the file system and the disk I/O to handle since we'll be writing large contiguous chunks instead of many small chunks.
  2. Backpressure is not being handled by the library, although I feel like the encoding should typically be slower than disk I/O. However, you can always pause the muxer from emitting data by stopping to feed the video/audio encoders new data. You could check if the I/O stream is under too much pressure (its queue is too large), and if so, wait until you encode more data. But I'm not an expert with this, so you'd have to dig through some docs.

~Vani

Vanilagy commented 9 months ago

Is this issue resolved for you? Can it be closed? :)

nsharma1396 commented 8 months ago

Hey! Yes, this is resolved Missed out on responding, will close :)