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.
What it solves
Web applications often need to process audio or video files—converting formats, extracting frames, or applying filters. Doing this in the browser traditionally requires server-side assistance or native plugins. libav.js brings the power of FFmpeg, the leading open-source multimedia framework, to pure JavaScript and WebAssembly. It lets you encode, decode, mux, demux, and filter audio and video directly in the browser (or Node.js), without any native code, by compiling FFmpeg's core libraries (libavformat, libavcodec, libavfilter, libavutil, libswresample) to WebAssembly and asm.js.
How it works
libav.js uses Emscripten to compile FFmpeg's libraries into WebAssembly and asm.js. You load a JavaScript file that exposes a global LibAV object; calling LibAV.LibAV() returns a promise that resolves to a ready-to-use instance. The instance provides functions like writeFile, ff_init_demuxer_file, ff_init_decoder, ff_read_multi, and ff_decode_multi to handle media operations. It supports asynchronous I/O through virtual devices, which avoids the limitations of FFmpeg's in-memory filesystem. The project is highly customizable: you can choose from pre-built variants (e.g., default, opus, flac, webm, aac) that include specific codecs and containers, or create your own using configuration fragments. Each variant can be built with or without the ffmpeg and ffprobe CLI tools, and optional debug versions are available. Licensing is carefully handled: FFmpeg is LGPL, so source code is included; the wrapper code uses the permissive 0-clause BSD license.
Who it’s for
This is for web developers who need to handle audio or video in the browser—for example, building a media editor, a converter, or a streaming application. It's also useful if you want to guarantee a specific set of codecs regardless of browser support (especially when combined with WebCodecs, which lacks muxing/demuxing and has inconsistent codec coverage). The library works in browsers and Node.js, though Node.js users are advised to use native FFmpeg instead. TypeScript type definitions are provided for integration into TypeScript projects.
Highlights
- Pure JavaScript and WebAssembly — no plugins or server needed.
- Based on the full FFmpeg libraries: libavformat, libavcodec, libavfilter, libavutil, libswresample.
- Includes the
ffmpegandffprobeCLIs (in certain variants) as JavaScript functions. - Modular variants: separate build for each demuxer or decoder, enabling on-demand loading via companion tools like AVGuesser and TransAVormer.
- Asynchronous I/O through virtual devices, so file sizes are only limited by JavaScript's number type.
- Works with WebCodecs through companion polyfill and bridge projects.
- Clear licensing: source code provided (LGPL) and wrapper code under 0-clause BSD.
- Highly customizable: build against different FFmpeg versions or create custom variants.
- Published on NPM and GitHub, with a CDN option for quick use.
Related
- Project
- Project
- Project
- Project