@altrepo/ffmpeg-kit
v0.2.0
Published
Known-compatible browser ffmpeg.wasm assets with copy and doctor commands.
Maintainers
Readme
@altrepo/ffmpeg-kit
Known-compatible browser ffmpeg.wasm assets with a small CLI for copying and checking them.
Test the package idea in the MP4 to MP3 Converter web version.
Repository: AltRepoYT/altrepo-ffmpeg-kit
This package starts with the legacy browser API because many static apps still expect:
window.FFmpeg.createFFmpeg
window.FFmpeg.fetchFileThe included bundle pins compatible files together:
@ffmpeg/[email protected]@ffmpeg/[email protected]
Install
npm install @altrepo/ffmpeg-kitCopy Assets
npx altrepo-ffmpeg init public/vendor/ffmpegOptions:
--bundle modern-0.12-mt(Multi-threaded v0.12, fastest but requires COOP/COEP headers)--bundle modern-0.12-st(Single-threaded v0.12, works everywhere)--bundle legacy-0.11(Default)--forceto replace existing files.--typesto also copy a TypeScript definition file (ffmpeg-legacy.d.ts) when using the legacy bundle.
Check Assets
npx altrepo-ffmpeg doctor public/vendor/ffmpeg [--bundle modern-0.12-mt]The doctor command checks that required files exist, are plausible sizes, and that the wrapper/core expose the expected symbols.
Local Development Server
Testing multi-threaded ffmpeg.wasm requires strict Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy headers. You can spin up a local server that automatically injects these headers:
npx altrepo-ffmpeg serve public/ --port 8080Bundler Configuration
If your bundler (like Vite or Webpack) is trying to bundle the ffmpeg files and breaking them, you can view config snippets to exclude them:
npx altrepo-ffmpeg config vitePlain HTML
Load the wrapper before your app code:
<script src="/vendor/ffmpeg/ffmpeg.min.js" defer></script>
<script src="/js/app.js" defer></script>Then initialize with local core files:
const { createFFmpeg, fetchFile } = window.FFmpeg;
const ffmpeg = createFFmpeg({
log: true,
corePath: "/vendor/ffmpeg/ffmpeg-core.js"
});Why This Exists
ffmpeg.wasm is powerful, but browser setup is easy to get wrong. The wrapper, core JS, WASM binary, worker, companion chunks, and API version all have to match. This package makes that boring on purpose.
