Learning never exhausts the mind
Home >  Technology > Linux > How to Convert WAV to MP3 in Linux

Published 9th August 2013 by

I've been recording some audio tracks as uncompressed WAV files, but they are too large for sending over the internet or storing on mobile devices. Here's how to convert WAV to MP3 which will compress the audio and make them more usable.

As with photo compression, there are two types of audio media file formats - "lossy" and "lossless." Among most popular lossless formats stands WAV (Waveform Audio File Format), while MP3 is the most common lossy format.

Lossy files are called so because they lose some data after compression to make its size smaller. WAV file is a completely uncompressed media file and takes up quite a bit of space.

ALAC and FLAC are both lossless formats of audio files that contain the same data as a WAV, but they use compression to produce smaller files. FLAC and ALAC formats don't lose any data - they keep all of it and compress it brilliantly, as ZIP files do. ALAC and FLAC player support is much less than MP3 so you may have difficulty finding something that will play these files, and they are not supported on iPod and iPhone.

How to Compress WAV to MP3 on the Command Line

These commands do not alter the original, which you can back up to CD-ROM or similar, instead they write out a new file which is typically 70-80% smaller than the original.

You can install ffmpeg using this command:

sudo apt-get install ffmpeg

Update: Some of the newer distros do not have this package so you may need to add the repository if the above command does not work.

sudo add-apt-repository ppa:kirillshkrogalev/ffmpeg-next
sudo apt-get update
sudo apt-get install ffmpeg

The commands to Convert WAV to MP3 in Linux using ffmpeg is:

ffmpeg -i track01.wav -acodec mp3 track01.mp3

You can also specify the bitrate of the MP3 with the -ab flag.

ffmpeg -i track01.wav -acodec mp3 -ab 64k track01.mp3

That is all you need to do to convert WAV to MP3 in the Linux shell. You can also specify wildcards to process multiple files at the same time.

6 thoughts on “How to Convert WAV to MP3 in Linux
  • 6th May 2021 at 8:34 pm

    Thank you!

  • 29th October 2020 at 3:29 pm

    thank you !!

  • 23rd August 2020 at 12:41 pm

    Thank you so much - very helpful.

  • 12th March 2020 at 2:17 am

    how to convert all the wav file to mp3 in one query?

    • 12th March 2020 at 9:18 am

      for i in *.wav; do ffmpeg -i "$i" -acodec mp3 -ab 64k "$(basename "$i" .wav)".mp3 ; done

  • 28th January 2020 at 10:03 pm

    Thank you!


Leave a Reply

Fields marked with * are mandatory.

We respect your privacy, and will not make your email public. Hashed email address may be checked against Gravatar service to retrieve avatars. This site uses Akismet to reduce spam. Learn how your comment data is processed.