How to Convert Audio from wav to mp3 in JavaScript Using ffmpeg.wasm

Adam Berg
4 min readNov 9, 2021

Check out this basic demo at https://convert.devtails.xyz/and keep an eye out for client side audio conversions in https://kaizen.place/ .

I just posted the following article the other day about using fluent-ffmpeg to convert wavs to mp3s in node.

https://devtails.medium.com/how-to-convert-audio-from-wav-to-mp3-in-node-js-using-ffmpeg-e5cb4af2da6

I had initially pondered doing the conversion on the client side, but wasn’t immediately able to find something. An astute Reddit commentor pointed me to ffmpeg.wasm and here we are with a followup for how to make the same conversion, but this time inside the browser.

The ffmpeg.wasm project has a Getting Started page, that was mostly helpful, but it skips a couple critical steps that had me tripped up for a bit.

Create Project With JavaScript Bundler

If you don’t already have a project setup with a bundler, you can quickly spin up your own.

npm initORyarn init

This will make a package.json file. Feel free to just press enter through all the configuration options as the defaults will be just fine.

--

--

Adam Berg

Building https://kaizen.place. writing about C, C++, rust, game development, web development, engineering management. https://devtails.xyz/