Compiling FFmpeg to WebAssembly: Building a Zero-Backend Video & Audio Converter
Converting MOV to MP4 or extracting audio from video has historically required either: Downloading sketchy desktop software bundled with adware. Uploading files to cloud conversion websites with 100MB limits and queue
Converting MOV to MP4 or extracting audio from video has historically required either:
- Downloading sketchy desktop software bundled with adware.
- Uploading files to cloud conversion websites with 100MB limits and queue timers.
By compiling FFmpeg C code to WebAssembly with Emscripten, the entire transcoding pipeline runs directly inside the client's sandboxed browser process.
We built the In-Browser Converter on SolveMyMedia.
In-Memory Media Transcode via FFmpeg WASM
import { createFFmpeg, fetchFile } from '@ffmpeg/ffmpeg';
const ffmpeg = createFFmpeg({ log: false });
export async function convertMediaInMemory(file, targetFormat = 'mp4') {
if (!ffmpeg.isLoaded()) await ffmpeg.load();
ffmpeg.FS('writeFile', 'input_raw', await fetchFile(file));
await ffmpeg.run('-i', 'input_raw', '-c:v', 'libx264', '-preset', 'ultrafast', `output.${targetFormat}`);
const data = ffmpeg.FS('readFile', `output.${targetFormat}`);
return new Blob([data.buffer]);
}
Features:
- Convert MOV, MKV, AVI, WebM to MP4.
- Extract MP3 and WAV audio streams in 0.3 seconds.
- 100% client-side privacy.
Test it live:
👉 Converter: https://solvemymedia.com/convert-video
👉 Extract Audio: https://solvemymedia.com/video-to-audio
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.