FFmpeg-WASI compiles FFmpeg to WASM. Unlike ffmpeg.wasm the WASM binary is standalone and required no JavaScript glue.
To get started you can clone the repository and its submodules.
git clone --recursive https://github.com/SebastiaanYN/FFmpeg-WASI.gitBuilding the project requires several dependencies and steps to be executed. To make it easier to build the project a Dockerfile is provided to build ffmpeg.wasm and ffprobe.wasm.
DOCKER_BUILDKIT=1 docker build -t ffmpeg-wasi --output . .
# or
./build.shOn Apple M1/M2 machines it might be necessary to set DOCKER_DEFAULT_PLATFORM=linux/amd64.
DOCKER_DEFAULT_PLATFORM=linux/amd64 DOCKER_BUILDKIT=1 docker build -t ffmpeg-wasi --output . .
# or
DOCKER_DEFAULT_PLATFORM=linux/amd64 ./build.shYou can use any WASI compatible WASM runtime, like wasmtime and wasmer, to run the binary.
Generating a thumbnail from a video.
wasmtime --dir videos ffmpeg.wasm -- -i videos/video-1080p-60fps-2s.mp4 -ss 1 -vframes 1 videos/out.pngConverting from one video format to another.
wasmtime --dir videos ffmpeg.wasm -- -i videos/video-15s.avi -c:v libx264 videos/out.mp4Currently only zlib and x264 are included in the build, but adding more should be fairly straightforward.
Some codecs require multiple iterations over the input/output (like mp4), which means you cannot pipe the input/output. Instead you need to write the file to disk so FFmpeg can read it from there. Depending on where you're running your code this may not be possible.
Additionally, WASI is still a very young technology so some FFmpeg features, like threading and networking, have to be disabled. In the future it might be possible to enable these features.
This project is licensed under MIT. Be aware that the licenses of FFmpeg and other dependencies may still apply.