Yahweasel / libav.js

This is a compilation of the libraries associated with handling audio and video in ffmpeg—libavformat, libavcodec, libavfilter, libavutil, libswresample, and libswscale—for emscripten, and thus the web.
Other
347 stars 27 forks source link

Loading with webpack #70

Closed stepancar closed 3 hours ago

stepancar commented 3 hours ago

Hi! I'm trying to use libav.js in a project that I'm building with webpack. I've followed the instructions in this section, but I’m running into some strange issues even after specifying the base parameter. It seems like libav.js is calling require() under the hood.

When I used the emscripten build of SKIA, I didn’t have this issue: https://github.com/google/skia/tree/main/modules/canvaskit/npm_build.

I'm sure I’ll find a solution, but I wanted to check if you have any examples of projects where this library is used and successfully built with webpack.

Thank you!

stepancar commented 3 hours ago

The solution

import LibAVJs from '@libav.js/variant-webcodecs';

const libav = await LibAVJs.LibAV({
      noworker: true,
      noes6: true, // this is important, so it would not call `import` which is replaced with webpack's own implementation
      base: 'https://cdn.jsdelivr.net/npm/@libav.js/variant-webcodecs@6.3.7/dist',
});