{"id":50660029,"url":"https://github.com/openclaw/ffmpeg-wasm","last_synced_at":"2026-06-13T04:01:08.083Z","repository":{"id":363030719,"uuid":"1261580462","full_name":"openclaw/ffmpeg-wasm","owner":"openclaw","description":"Lightweight FFmpeg and FFprobe for Node, built as modern WebAssembly for local media automation.","archived":false,"fork":false,"pushed_at":"2026-06-12T01:11:02.000Z","size":804,"stargazers_count":28,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-12T03:15:05.347Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openclaw.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["moltbot"]}},"created_at":"2026-06-06T22:08:07.000Z","updated_at":"2026-06-12T01:11:06.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/openclaw/ffmpeg-wasm","commit_stats":null,"previous_names":["openclaw/ffmpeg-wasm"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/openclaw/ffmpeg-wasm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openclaw%2Fffmpeg-wasm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openclaw%2Fffmpeg-wasm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openclaw%2Fffmpeg-wasm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openclaw%2Fffmpeg-wasm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openclaw","download_url":"https://codeload.github.com/openclaw/ffmpeg-wasm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openclaw%2Fffmpeg-wasm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34271500,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-13T02:00:06.617Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-08T02:00:26.135Z","updated_at":"2026-06-13T04:01:08.042Z","avatar_url":"https://github.com/openclaw.png","language":"JavaScript","funding_links":["https://github.com/sponsors/moltbot"],"categories":[],"sub_categories":[],"readme":"# ffmpeg-wasm local\n\n[![CI](https://github.com/openclaw/ffmpeg-wasm/actions/workflows/ci.yml/badge.svg)](https://github.com/openclaw/ffmpeg-wasm/actions/workflows/ci.yml)\n\nLightweight FFmpeg and FFprobe for Node, built as modern WebAssembly for local media automation.\n\nThis repository is intentionally small in scope: one reproducible Emscripten build, one TypeScript wrapper, and enough codecs/protocols for media inspection, audio extraction, thumbnails, pipe I/O, and segmentation.\n\n![Media Bench playground](docs/assets/media-bench.png)\n\n## Why\n\nMany media workflows need predictable FFmpeg and FFprobe behavior without carrying a full native FFmpeg bundle. This package builds a narrow LGPL FFmpeg wasm core and exposes it through:\n\n- `ffmpeg-wasm`, a CLI-compatible FFmpeg entrypoint.\n- `ffprobe-wasm`, a CLI-compatible FFprobe entrypoint.\n- TypeScript APIs for binary-safe buffered or streaming execution.\n\n## License\n\nThe wrapper, scripts, and documentation in this repository are MIT licensed.\n\nGenerated FFmpeg assets in `dist/` are copied from FFmpeg and are LGPL-2.1-or-later. Linked libvpx code is BSD-licensed. The build does not pass `--enable-gpl` or `--enable-nonfree`. FFmpeg and libvpx license files are copied into `dist/` during `pnpm build`.\n\nKeep wrapper code and generated FFmpeg binaries conceptually separate when this moves under OpenClaw packaging. A downstream package can stay MIT for the wrapper while distributing the FFmpeg wasm artifacts under the LGPL terms that apply to FFmpeg.\n\n## Build Surface\n\nDefault refs:\n\n- FFmpeg: `n8.1.1`\n- LAME: `master` from `ffmpegwasm/lame`\n- libvpx: `v1.16.0`\n- Runtime: Node 24+\n- Compiler: Emscripten via `emcc`\n\nEnabled programs:\n\n- `ffmpeg`\n- `ffprobe`\n\nEnabled protocols:\n\n- `data`\n- `fd`\n- `file`\n- `pipe`\n\nEnabled demuxers:\n\n- `aac`\n- `flac`\n- `hls`\n- `image2`\n- `matroska`\n- `mov`\n- `mp3`\n- `mpegts`\n- `ogg`\n- `wav`\n\nEnabled muxers:\n\n- `image2`\n- `mov`\n- `mp4`\n- `mp3`\n- `null`\n- `rawvideo`\n- `segment`\n- `wav`\n- `webm`\n\nEnabled decoders:\n\n- `aac`\n- `flac`\n- `h263`\n- `h264`\n- `hevc`\n- `mpeg4`\n- `mjpeg`\n- `mp3`\n- `opus`\n- `pcm_s16le`\n- `png`\n- `vorbis`\n- `vp8`\n- `vp9`\n- `wrapped_avframe`\n\nEnabled encoders:\n\n- `h263`\n- `libmp3lame`\n- `libvpx` (VP8)\n- `mpeg4`\n- `opus`\n- `pcm_s16le`\n- `png`\n- `rawvideo`\n- `wrapped_avframe`\n\nEnabled filters:\n\n- `aformat`\n- `aresample`\n- `format`\n- `metadata`\n- `null`\n- `scale`\n- `select`\n- `showinfo`\n- `signalstats`\n\nExternal libraries:\n\n- `libmp3lame`\n- `libvpx`\n- `zlib`\n\nEach generated Node or browser FFmpeg/FFprobe bundle is about 8.5 MB on current builds.\n\n## Install\n\n```sh\npnpm install\n```\n\nRequired system tools for a full wasm build:\n\n- Emscripten SDK with `emcc`, `em++`, `emar`, and `emranlib` on `PATH`\n- Autotools for LAME\n- `make`, `pkg-config`, `nasm`, `yasm`\n\nOn macOS:\n\n```sh\nbrew install autoconf automake libtool nasm pkg-config yasm\n```\n\n## Commands\n\n```sh\npnpm build\npnpm docs:build\npnpm playground\npnpm playground:e2e\npnpm verify\npnpm test:e2e\npnpm check\n```\n\n`pnpm build` compiles TypeScript, fetches the configured FFmpeg/LAME/libvpx refs into `.cache/`, builds static LAME and libvpx, builds FFmpeg/FFprobe wasm, and writes generated assets to `dist/`.\n\n`pnpm docs:build` builds the static site into `dist/docs-site`: the media workbench at `/`, its compiled TypeScript client and browser ffmpac worker, the browser wasm bundle, and documentation under `/docs/`.\n\n`pnpm playground` starts a local one-page media bench at `http://127.0.0.1:4173`. It lets you load a video, choose a supported preset, inspect the generated FFmpeg args, render through the wasm wrapper, preview the output inline, and save via the browser file picker or download fallback.\n\n`pnpm playground:e2e` starts the playground on a temporary port, launches Chrome through DevTools, loads the sample video, renders a smaller MP4 and an MP3, and writes `.tmp/playground-e2e-server.png` for visual proof. Set `PLAYGROUND_E2E_STATIC=1` to test the static `dist/docs-site` workbench with `/api/*` blocked and only browser ffmpac available; that mode writes `.tmp/playground-e2e-static.png`.\n\n`pnpm verify` creates a tiny test video through the wasm build with external executable lookup disabled, then exercises FFprobe text and JSON output, API and CLI MP4/MP3 conversions, codec and dimension assertions, stdin pipe input, stdout pipe output, PNG frame output, rawvideo byte equality, segmentation, cwd/dist overrides, API validation failures, and CLI failure paths. Set `FFMPEG_WASM_VERIFY_OUTPUT_DIR` to retain the converted files and JSON manifest.\n\n`pnpm test:e2e` rebuilds the wasm assets from source, then runs the same live verifier against the generated FFmpeg/FFprobe wrappers.\n\n`pnpm check` runs `tsgo`, strict `oxlint`, and `oxfmt --check`.\n\n## CLI\n\nAfter `pnpm build`, use the compiled entrypoints directly:\n\n```sh\nnode lib/src/ffprobe-cli.js -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4\nnode lib/src/cli.js -hide_banner -loglevel error -i input.mp4 -vn -ac 1 -ar 16000 audio.wav\nnode lib/src/ffprobe-cli.js -v error -show_format input.mp4\nnode lib/src/cli.js -hide_banner -i input.mp4 -frames:v 1 frame.png\nnode lib/src/cli.js -hide_banner -ss 0 -i input.mp4 -t 5 -map 0:v:0 -map 0:a? -c copy -movflags +faststart clip.mp4\n```\n\nThe package also declares `ffmpeg-wasm` and `ffprobe-wasm` bin entries for downstream package-manager linking.\n\n## TypeScript API\n\n```ts\nimport { execFfmpeg, runFfmpeg, runFfprobe } from \"@steipete/ffmpeg-wasm-local\";\n\nconst probe = await runFfprobe([\n  \"-v\",\n  \"error\",\n  \"-show_entries\",\n  \"format=duration\",\n  \"-of\",\n  \"default=noprint_wrappers=1:nokey=1\",\n  \"input.mp4\",\n]);\n\nif (probe.exitCode !== 0) throw new Error(probe.stderrText);\n\nconst wav = await runFfmpeg([\n  \"-hide_banner\",\n  \"-loglevel\",\n  \"error\",\n  \"-i\",\n  \"input.mp4\",\n  \"-vn\",\n  \"-ac\",\n  \"1\",\n  \"-ar\",\n  \"16000\",\n  \"-f\",\n  \"wav\",\n  \"-\",\n]);\n\nawait execFfmpeg([\"-hide_banner\", \"-i\", \"input.mp4\", \"audio.mp3\"]);\n```\n\n`runFfmpeg` and `runFfprobe` buffer stdout/stderr and return `Buffer` fields plus UTF-8 text helpers. Use these for probes, small generated files, and tests.\n\n`execFfmpeg` and `execFfprobe` stream stdio and return only the exit code. Use these for CLI-style work or larger outputs.\n\nBoth APIs accept:\n\n- `distDir` to point at a custom generated asset directory.\n- `cwd` and `env` for process isolation.\n- `stdin` for pipe input.\n- `timeoutMs` for opt-in time limits.\n\n`ffmpeg` receives `-nostdin` automatically unless the caller already supplied it. Explicit `-i -` stdin input still works through the wrapper.\n\n## Downstream Wiring\n\nBuild once:\n\n```sh\npnpm build\n```\n\nThen point a downstream tool at the compiled wrappers:\n\n```sh\nFFMPEG_PATH=\"$PWD/lib/src/cli.js\" \\\nFFPROBE_PATH=\"$PWD/lib/src/ffprobe-cli.js\" \\\nyour-tool ...\n```\n\nFor direct package usage, import the TypeScript API and keep `dist/` next to the compiled `lib/` tree.\n\n## Build Tuning\n\nOverride source refs per build:\n\n```sh\nFFMPEG_VERSION=n8.1.1 LAME_REF=master LIBVPX_REF=v1.16.0 pnpm build\n```\n\nTo keep the binary small, only add codecs, demuxers, muxers, filters, or protocols when a real caller needs them. Prefer adding one capability and extending `scripts/verify.ts` with a matching proof.\n\nUseful places:\n\n- `playground/`: one-page local editor assets, TypeScript client, and browser ffmpac worker.\n- `docs/`: Cloudflare Pages source docs and screenshot assets.\n- `scripts/build.ts`: configure flags and Emscripten linker flags.\n- `scripts/build-docs-site.ts`: static docs site builder.\n- `scripts/playground-server.ts`: local editor server and render endpoints.\n- `scripts/verify.ts`: behavioral coverage for the generated wasm.\n- `.oxlintrc.json`: strict lint policy.\n\n## CI\n\nGitHub Actions runs two jobs:\n\n- TypeScript, lint, and format on Node 24.\n- Static docs site build.\n- Full live wasm E2E with Emscripten, explicit API and CLI media conversions, codec/dimension assertions, native executable auditing, server and static browser workbench tests, build caching, and proof artifact uploads.\n\nCI intentionally builds from source instead of trusting checked-in wasm output. `dist/` is ignored and regenerated. The wasm job uploads `dist/`, converted media, a verification manifest, and both browser screenshots for inspection.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenclaw%2Fffmpeg-wasm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenclaw%2Fffmpeg-wasm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenclaw%2Fffmpeg-wasm/lists"}