How can I convert MP4 video to MP3 audio with FFmpeg?

ยท 275 words ยท 2 minute read

Sometimes, you need to extract audio or music from a video. Or you need to convert a video into an audio file. The command is simple. Here is the command to convert MP4 to MP3 file.

ffmpeg -i video.mp4 audio.mp3

Alternative commands to convert MP4 to MP3 file

ffmpeg -i video.mp4 -b:a 192K -vn music.mp3

or use this faster command (see benchmarks below).

ffmpeg -i video.mp4 -vn audio.mp3

You can use all of the above three commands to convert mp4 into mp3 on Mac OS or any Linux based operating system, but not on Ubuntu. To use ffmpeg on Ubuntu, read on.

Convert MP4 to MP3 on Ubuntu OS ๐Ÿ”—

But if you are using Ubuntu OS, try to run commands with ffmpeg but if the OS told you ffmpeg: command not found, replace ffmpeg with avconv in the command because Ubuntu was shipping with a fork named libav .

After replacement, the command will be like this.

avconv -i video.mp4 audio.mp3

And the other command on Ubuntu will be. (just replace ffmpeg with avconv)

avconv -i video.mp4 -b:a 192K -vn music.mp3

And the faster command on Ubuntu will be.

avconv -i video.mp4 -vn audio.mp3

Benchmarks : Which command is faster? ๐Ÿ”—

Let’s benchmark those three commands, to know the fastest one.

CommandTime Period
ffmpeg -i video.mp4 -vn audio.mp327.85 secs
ffmpeg -i x.mp4 y.mp328.17 secs
ffmpeg -i x.mp4 -b:a 192K -vn y.mp330.08 secs

So, the fastest command to convert MP4 video to MP3 audio file is ffmpeg -i video.mp4 -vn audio.mp3.

I hope this helps you. You know someone will benefit from this, share it with him/her, a friend or colleage.

Share:
waffarx cash back