Linux Convert an MP3 File to WAV Format

by on November 3, 2009 · 12 comments· LAST UPDATED November 3, 2009

in , ,

How do I convert an MP3 file to WAV format under Linux using a shell prompt?

There are plenty of tools that to convert an MP3 file into WAV format. I recommend mpg321 which is a free command-line mp3 player, which uses the mad audio decoding library.

Install mpg321 or mpg123

Type the following command under Debian / Ubuntu Linux, enter:

sudo apt-get install mpg321


sudo apt-get install mpg123

I recommend using mpg123 as it is updated frequently.

Install mpg123 under CentOS / RHEL / Fedora Linux

Turn on rpmforge repo and type the following command:

yum install mpg123

Convert an MP3 to WAV

The -w option will convert an .mp3 file to .wav file. The syntax is:

mpg123 -w output.wav input.mp3


mpg321 -w output.wav input.mp3

A Sample Shell Script Helper Function

Add the following to your ~/.bashrc startup file (tested with bash v3.x+):

	[[ $# -eq 0 ]] && { echo "mp3wav mp3file"; exit 1; }
	for i in "$@"
		# create .wav file name
		local out="${i%/*}.wav"
		[[ -f "$i" ]] && { echo -n "Processing ${i}..."; mpg123 -w "${out}" "$i" &>/dev/null  && echo "done." || echo "failed."; }

Use it as follows:

mp3towav *.mp3
mp3towav "this is a test.mp3"
ls *.wav
Tweet itFacebook itG+ itDownload PDF versionFound an error/typo on this page?

{ 12 comments… read them below or add one }

1 Metalx1000 November 3, 2009 at 11:35 pm

Sorry, I meant:
ffmpeg -i input.mp3 output.wav


2 nixCraft November 4, 2009 at 5:26 am

@Metalx1000, nice, I’ve deleted your old post and kept only correct one.


3 sanjay November 5, 2009 at 5:59 am


Is there any tool/command in Fedora to convert mp4 files to avi ?
Or above command will also work for mp4 file.



4 nixCraft November 5, 2009 at 6:16 am

Command line tools:

  1. mencoder
  2. ffmpeg

Gui tools:

  1. avidemux


5 gemuet November 5, 2009 at 8:07 am

is there a tool tool to convert .wmv/wma to mp3/mp4 or any other format which totem can easily play?


6 yoander (sedlav) November 5, 2009 at 3:41 pm

Another gui tool SoundConverter


7 gemuet November 5, 2009 at 4:57 pm

Thanks man.
I appreciate.


8 Metalx1000 November 5, 2009 at 7:24 pm

Thanks Vivek Gite.

ffmpeg -i input.wmv output.mp4
That will convert the wmv to mp4 with default settings, which may not be the best quality.
For more option on converting to mp4 with ffmpeg check out this post:


9 gemuet November 6, 2009 at 8:08 am

I appreciate your help man.


10 Jesper January 2, 2012 at 4:48 pm

Very nice – except you cant SIGHUP the script :)


11 Romanenko Bogdan January 25, 2013 at 6:02 pm

Thank’s. Use your article to convert mp3 to wav.


12 Roland August 27, 2014 at 2:45 pm

Don’t put ‘exit’ in a bash function! I ran ‘mp3towav’ with no options, and my terminal window vanished.


Leave a Comment

Tagged as: , , , , , , , , , , , , , , , , ,

Previous Faq:

Next Faq: