ffmpeg.wasm icon indicating copy to clipboard operation
ffmpeg.wasm copied to clipboard

Is there a way to generate Video from image ArrayBuffer data instead of fetching the image?

Open rajat10cube opened this issue 3 years ago • 3 comments

I have referred the examples given in the repo where it uses ffmpeg.FS to fetch images. I want that instead of fetching the files locally, it uses the image array buffers (blobs) that we can pass from other functions to generate videos from that.

rajat10cube avatar Aug 26 '22 15:08 rajat10cube

async function blobToUint8Array(blob) {
  const arrayBuffer = await new Response(blob).arrayBuffer();
  var uint8View = new Uint8Array(arrayBuffer);
  return uint8View;
}

you may convert blob to Uint8Array to write to ffmpeg fs.

AnilSonix avatar Sep 16 '22 19:09 AnilSonix

async function blobToUint8Array(blob) {
  const arrayBuffer = await new Response(blob).arrayBuffer();
  var uint8View = new Uint8Array(arrayBuffer);
  return uint8View;
}

you may convert blob to Uint8Array to write to ffmpeg fs.

@AnilSonix How do I write Uint8Array to ffmpeg fs?

rajat10cube avatar Sep 16 '22 19:09 rajat10cube

Check API docs in this repo. API

ffmpeg.FS('writeFile', 'image001.png', new Uint8Array(...));

The third param represent binary data. Before you can run any ffmpeg cmd , it must written to its fs so that it's available.

AnilSonix avatar Sep 17 '22 05:09 AnilSonix