Menu

Converting MP4 Audio in the Browser Without Uploading the File
📰

Converting MP4 Audio in the Browser Without Uploading the File

DEV Community: webdev·Hao Yin·about 8 hours ago
#dw5r1YuF
#devtowebdev#devto#dev#track#file
Reading 0:00
15s threshold

Hao Yin

Posted on Oct 27

AI-assisted

Most "convert MP4 to MP3" pages upload the file to a server, run ffmpeg there, and send back an MP3. That works, but it has two costs: the upload time for large videos, and a copy of the file on someone else's machine. For a private rehearsal or an unreleased track, the second cost is the one that matters.

A browser can do the job locally. The MP4 is a container: it holds a video track, one or more audio tracks and sometimes subtitles. The browser reads the container, ignores the video, decodes the audio track and encodes the samples as MP3. The file never leaves the device.

The implementation has three parts:

Demux the container. The browser needs to find the audio track inside the MP4. For common files (MP4, M4A, MOV, WEBM, MKV) this is handled by the media stack; less common codecs may not decode everywhere.

Decode the audio. AAC is the usual codec in an MP4. Web Audio and WebCodecs can decode it to raw samples.

Encode MP3.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.