How to Convert Audio From Wav to MP3 in Node.js Using FFMpeg

Adam Berg
2 min readNov 7, 2021
Uncompressed live music is best

Update: I’ve added a new post describing how to do this client-side.

While working on kaizen.place, a music app that encourages continuous improvement of your music, I found a need to convert wav files to mp3. To keep hosting costs down, I set a limit of 10 MB for the file upload size. But a standard 3 minute song is just over 30 MB. Indirectly, this limit meant that for a full song, artists were required to upload mp3 files.

After hearing about (and seeing first hand) the annoyance of getting ready to upload a new version of a song, I figured it would probably be worth it to allow users to upload larger wav files, but then convert them to mp3. On average an mp3 converted track takes up about one tenth of the space of a wav . This essentially means that wav files up to almost 100 MB can now be accepted without using more than 10 MB of storage space.

This post condenses the info that I picked up from several different sources to hopefully give you enough info for your next audio project.

Install fluent-ffmpeg

--

--

Adam Berg

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