Unexpected Exception when using ffmpeg.wasm in Chrome extension

I'm trying to implement a chrome extension which allows me to play flv videos by transcoding them to mp4 and then inserting a video player as it's done on the transcode example from ffmpeg.wasm.

As chrome extensions don't support the execution of downloaded code, I need to use a downloaded version of ffmpeg-core. I've downloaded the 0.8.4 version and included the folder on the manifest under web_accessible_resources, so that on the javascript file for trancoding the code is:

const { createFFmpeg, fetchFile } = FFmpeg;
const ffmpeg = createFFmpeg({
  log: true,
  corePath: chrome.runtime.getURL('ffmpeg-core/ffmpeg-core.js'),
});

const transcode = async (file) => {
  const { name } = file;
  console.log('Loading ffmpeg-core.js. Transcode URL.');
  await ffmpeg.load();
  console.log('ffmpeg-core loaded.');

  let blob = await fetch(file).then(r => r.blob());
  console.log('blob downloaded');

  ffmpeg.FS('writeFile', name, blob);
  console.log('Start transcoding');
  await ffmpeg.run('-i', name,  'output.mp4');
  console.log('Complete transcoding');
  const data = ffmpeg.FS('readFile', 'output.mp4');

  const video = document.getElementById('output-video');
  video.src = URL.createObjectURL(new Blob([data.buffer], { type: 'video/mp4' }));
}

Once the transcode function is executed, I get the following exception:

ffmpeg.min.js:1 Uncaught (in promise) TypeError: t is not a function
    at ffmpeg.min.js:1
    at f (ffmpeg.min.js:1)
    at Generator._invoke (ffmpeg.min.js:1)
    at Generator.next (ffmpeg.min.js:1)
    at i (ffmpeg.min.js:1)
    at c (ffmpeg.min.js:1)

Does somebody have any idea of why could this be happening?

Thanks a lot!



Read more here: https://stackoverflow.com/questions/64890793/unexpected-exception-when-using-ffmpeg-wasm-in-chrome-extension

Content Attribution

This content was originally published by Javierd98 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: