mattdesl / mp4-wasm

[proof-of-concept] fast MP4 mux / demux using WASM
MIT License
276 stars 23 forks source link

Cannot be used by bundlers #7

Open marcofugaro opened 2 years ago

marcofugaro commented 2 years ago

Currently, it's hard using this library directly from node_modules without copying over mp4.wasm.

I am using esbuild for context.

One easy solution would be to build with the emscripten flag -s SINGLE_FILE=1, that way the wasm binary code is encoded in the .js file. This results in a little bit filesize increase, but negligible overall.

Another solution would be like ffmpeg.wasm which host the .wasm file by themselves.

ffdead commented 2 years ago

Currently, it's hard using this library directly from node_modules without copying over mp4.wasm.

@marcofugaro may I ask how you solved the mp4.wasm import?

marcofugaro commented 2 years ago

@ffdead you have to copy the mp4.wasm over your public folder.

ffdead commented 2 years ago

Got it, thanks! Had to copy it to public/node_modules/mp4-wasm/build/mp4.wasm for future reference

ouch1985 commented 2 years ago

const resp = await fetch('yourPathToWasm/mp4.wasm') const wasmBinary = await resp.arrayBuffer() const MP4 = await loadMP4Module({ wasmBinary })