Uploading a 150 MB video to a remote FFmpeg server just to strip out the soundtrack is slow and expensive.
Modern browsers can demux and decode audio tracks locally using native operating system decoders through the Web Audio API.
Here is the exact audio extraction loop powering Fileo:
async function decodeAudioTrack(file) {
const arrayBuffer = await file.arrayBuffer();
const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
try {
// Decodes MP4, MOV, WebM, and MKV to Float32 PCM in memory
return await audioCtx.decodeAudioData(arrayBuffer);
} finally {
await audioCtx.close();
}
}
Key Engineering Wins:
- Zero-Dependency WAV Encoder: Interleaves raw Float32 PCM samples into a bit-perfect 16-bit signed integer RIFF buffer with zero third-party packages.
-
Event-Loop Yielding: Yields execution to the main thread every 4 chunks (
await new Promise(r => setTimeout(r, 0))) during LameJS MP3 encoding so progress animations stay buttery smooth at 60 FPS. -
The Windows Chromium File Picker Bug: Why mixing
accept="image/*,video/*"hid MP4 files in Windows Explorer (and how removing it fixed file discovery).
Try the converter live:
https://fileo.cc/?utm_source=devto
Read the complete step-by-step case study with full
source code:
https://adilrahman.cc/blog/in-browser-video-to-mp3-web-audio-api?utm_source=devto
Top comments (0)