Learn how to run FFmpeg directly in the browser using WebAssembly. This guide covers setup, performance tips, and practical examples for video and audio processing without server-side dependencies.
ffmpeg / Main options ffmpeg.orgffmpeg has been compiled to web assembley via emscripten a number of times typically it will run in a worker thread since by its nature it is very computationally heavy and will tie up the main thread
emscripten : Module object emscripten.org
there are two variants, both are
ffmpeg version 2.2.1 Copyright (c) 2000-2014 the FFmpeg developers
ffmpeg.js -- https://github.com/bgrins/videoconverter.js/blob/master/build/ffmpeg.js 22.5 MB
ffmpeg-all-codecs.js -- https://github.com/bgrins/videoconverter.js/blob/master/build/ffmpeg-all-codecs.js 26.3 MB
the files themselves are available from ( right click save as )
ffmpeg.js -- https://raw.githubusercontent.combgrins/videoconverter.js/master/build/ffmpeg.js
ffmpeg-all-codecs.js -- https://raw.githubusercontent.com/bgrins/videoconverter.js/master/build/ffmpeg-all-codecs.js
in my testing the all-codecs version is about 4 times slower
they are just javascript files, so you can use them by incuding a single, albeit quite large, file
it exposes a single function ffmpeg_run
note. there was mention of
muaz-khan / Ffmpeg.js
github.com
it does offer some additional exmaple code, but as far as i can tell its simply a varaiant of ffmpeg.js from videoconverter.js
tl;dr
tl;dr
i came across this to day, so thought i would include it also
https://www.npmjs.com/package/ffprobe-wasm
when working with audio / video its often helpful to determine the mime types of the codecs in use
Codecs in Common Media Types developer.mozilla.org this only works for mp4WebCodecs API developer.mozilla.org
VideoDecoder developer.mozilla.org VideoEncoder developer.mozilla.org If you only need to take an H.264 keyframe (IDR) and the next frames and turn a single decoded frame into a JPEG, the most “minimal” modern approach in the browser is WebCodecs. It lets you feed compressed H.264 bytes, get decoded VideoFrames, draw them to a canvas, and export as JPEG—no heavy libraries required. Key detail: you must provide the AVCDecoderConfigRecord (SPS/PPS) in the decoder config or immediately after configure, otherwise decoding will fail.
If you truly need a codec that runs without relying on the browser’s built-in decoders, Broadway is a project that compiled Android’s
H.264 decoder to JavaScript via Emscripten. It can decode frames directly in JS, but expect significantly lower performance and more
complex integration compared to WebCodecs. It’s mainly of historical/educational interest today.
LongJohnCoder / Broadway264
github.com