Software Engineer's Blog

How to Convert WAV (MP4) to MP3 Using FFmpeg

How to Convert WAV (MP4) to MP3 Using FFmpeg

You have a WAV recording or an MP4 and you just want an MP3. FFmpeg does it in one command — the only real decisions are the bitrate and whether you’re re-encoding or just lifting out the audio that’s already there.

Basic Conversion

To convert a WAV file to MP3, use the following command:

  • -i is the input file option, which specifies the file that you want to convert. In this case, input.wav is the name of the WAV file you want to convert.
  $ ffmpeg -i input.wav output.mp3

Setting the Bitrate

You can specify the bitrate of the output MP3 file using the -b:a option. For example, to convert the file with a bitrate of 192kbps, use:

  • -b:a 192k specifies that the audio bitrate should be set to 192 kilobits per second (kbps). Common bitrates for MP3 files range from 128kbps (standard quality) to 320kbps (high quality).
$ ffmpeg -i input.wav -b:a 192k output.mp3

CBR vs VBR

-b:a 192k sets a constant bitrate. For most audio, variable bitrate (VBR) gives better quality for the same file size — it spends bits where the sound is complex and saves them on silence. Use -q:a instead, where 0 is highest quality and 9 is smallest:

$ ffmpeg -i input.wav -q:a 2 output.mp3   # ~190 kbps VBR, transparent to most ears

Extracting MP3 from MP4

The same command extracts the audio from an MP4 and saves it as MP3:

$ ffmpeg -i video.mp4 -vn -b:a 192k audio.mp3

-vn drops the video stream explicitly (ffmpeg does this anyway for an .mp3 output, but it’s clearer). One thing to know: this re-encodes. An MP4’s audio is usually AAC, so AAC → MP3 stacks a second lossy step on an already-lossy source. If the audio is AAC (check with ffprobe) and you only need the sound, copy it out untouched into an .m4a — no re-encode, no quality loss, and instant:

$ ffmpeg -i video.mp4 -vn -c:a copy audio.m4a

Stream copy only works when the target container accepts that codec, so if ffprobe shows something the .m4a muxer won’t take, you’ll have to re-encode. Reach for MP3 when you need broad compatibility; copy to .m4a when the codec allows and you want to keep the original quality. To convert a whole folder of videos at once, see batch converting video to MP3.