Skip to content

ffmpegwasm/libav.wasm

Repository files navigation

libav.wasm

stability-wip Build libav.wasm GitHub commit activity

libav WebAssembly port.

Background

libav (incl. libavcodec, libavformat, …) is the library behind FFmpeg to record, convert and stream audio and video. This repository aims to port libav to WebAssembly to allow users edit video and audio directly inside the browser.

Why not ffmpeg.wasm?

ffmpeg.wasm ports FFmpeg to WebAssembly using a more coarse-grained approach (you can imagine ffmpeg.wasm as an extremely large function, once it starts to run, there isn't much you can control.), it works but also suffers from the isolation of C and JavaScript world which makes it hard to develop and improve.

The ultimate goal of libav.wasm is to enable a ffmpeg.wasm with better developer experience (DX) and potentially be the foundation to fix issues like performance and more.

Get Started

We use docker to achieve a (hopefully) cached and reproducible build, so it is required to install docker 19.03 or above before you run any build script.

  • Install dependencies & build assets
npx lerna run bootstrap
npx lerna run build
  • Build libav.wasm
# build `dev` version
$ make

# build `prod` version (slower, optimized with -O3 -msimd128)
$ make prd

If nothing went wrong, you should find libav assets in dist/.

Try it

A few examples can be found in apps/node-ts, feel free to try and see how it works in action.

As these examples use video files in testdata/, you need to do a git submodule update --init first

  • metadata: use libav.wasm to extra video metadata
npm run metadata
  • transcode: use libav.wasm to transcode mp4 to a gop fixed mp4
npm run transcode

Configuration

libav.wasm is built using tools/libraries with version:

Name Version
emsdk 3.1.18
FFmpeg n5.1
x264 0.164.x (num of cpu fixed to 4)

Similar Projects