Luke Vo
Luke Vo

Reputation: 20718

Play video with unknown codec from a ReadableStream with HTMLVideoElement?

I have a ReadableStream received from a WebWorker and I would like to play it with a HTMLVideoElement (Blob is not an option and ArrayBuffer is available but not usable, see below). The format can be anything as the video is picked by user and the best I can do is the general MIME type like video/mp4 or video/webm.

Right now the only solution I can find is this answer but I need to know the codec (passing video/mp4 would fail):

// The codec for SourceBuffer is not known:
const sourceBuffer = mediaSource.addSourceBuffer('audio/webm; codecs="opus"');
// ...

The alternatives is to load the whole thing into an ArrayBuffer instead but with large files (I tested with 4.5GB file) it would hang the browser.

Is there anyway to play a ReadableStream in HTMLVideoElement?

Upvotes: 2

Views: 533

Answers (0)

Related Questions