Covert .mp3 to .wav and .ogg from command
I have a ton of various music files on my machine that are in various states of migrating from .mp3 to different formats. The primary reason for this is because of the issue of licensing between Linux and the MP3 format. And although there are GUI tools to do nearly every job you need, there are times when the command line is still your friend. For instance, say you want to do batch jobs - the command line is good for this. Or say you want to (for whatever reason) secure shell into a remote machine and then convert your files. For whatever reason you need, it's good to know that the tools are available for the job.
The tools I am talking about are mpg123 and mpg321. Although mpg321 claims to be a drop-in replacement for mpg123, I still prefer to use both tools (the former for converting .mp3 to .wav and the latter for converting .mp3 to .ogg). And in this article you will see how simple it is (using the command line) to convert these file types.
Installation
Since we will be using the command line for the conversion, we'll install the tools from the command line. The distribution I am using for example is based on the recent, stable Debian. You will not need to add any repositories to your /etc/apt/sources.list file, because all of the tools are found on the standard repositories. To install these tools, follow these steps:
- Open up a terminal window.
- If needed, su to root (if you use sudo in place of root, just add sudo to the beginning of the installation commands below).
- Issue the command apt-get install mpg123 mpg321 vorbis-tools
That's it. Now let's take a look at how the tools are used.
Convert .mp3 to .wav
The first conversion is to .wav. Why use .wav? First and foremost, the .wav file is not compressed and is lossless, so the sound is better. The only downfall is that the files are much bigger. So, if you have a particular file and you want to retain as much quality as you can, .wav is the format to use. Of course, in this instance we are converting a lossy file type (.mp3) so there is already diminished sound quality. But why diminish it further? To make this conversion, the command looks like this:
mpg123 -w output_file.wav input_file.mp3
Where output_file is the name of the .wav file that will be converted from the mp3 file named input_file. So let's say you want to convert the file Rush_Tom_Sawyer.mp3 to .wav. That command would look like:
mpg123 -w Rush_Tom_Sawyer.wav Rush_Tom_Sawyer.mp3
Convert .mp3 to .ogg
The .ogg format is the open source equivalent to .mp3 and is supported by many players. The .ogg format is a good format to use when creating "mix cd's" (I'm old, I still want to say "mix tapes"), because you can fit more files per CD than if you were using the .wav format. But to convert the .mp3 to .ogg the command looks like:
mpg321 Input_File.mp3 -w raw && oggenc raw -o Output_file.ogg
Let's examine the same file we converted to .wav above. The command to convert to .ogg from .mp3 would look like:
mpg321 Rush_Tom_Sawyer.mp3 -w raw && oggenc raw -o Rush_Tom_Sawyer.ogg
Easy right?
Final thoughts
Now you can get crafty and create batch scripts that will allow you to do batch conversions. Naturally many will think "Why would I go through that, when I can just download a handy GUI tool like Soundconverter to do the job? Why? Because it's always smart to have the command line option around. One day you might need it.
Advertisement
The warning message about AAC streams when you load streams is because you don’t have the free Orban AAC/aacPlus Player Plugin installed.
http://codecpack.co/download/Orban-aacPlus-Player-Plugin.html
Justin, thanks for the information.
does this support AAC ? or only mp3 streaming
I’d say it supports all pls streams but I have not tried that so cannot verify it 100%.
Thank you Martin for a most informative and viable solution (it allowed me to play streams from a Netherland internet radio station in my WMP)! Continued success to you!
Barnabas (USA)
Your steps’ recommendation is still valid until 7th October 2012.. Thank you very much !!
Thank you!
You must convert file.pls to file.m3u
because file.pls open with winamp and file.m3u open with wmp.
Hi
2017 still kicking on Windows 7
Thx a ton
Hey, even i can do it, i stumbled through it and it works great! The only instruction advice i will add as i had to figure this out, when the wmp box opens that says save or open the bar on right says wmp click that drop down and select “open pls in wmp” once you do that it will work . Took me quite some time to discover that as i am no computer expert by any means. Having said that, previously i had downloaded codec packages and something about aac. None did any good. This rocks, i listen to a lot of internet radio and a number of them have dropped flash player and getting wmp to work had been a nightmare. So many thanks for this great solution to another problem that Micro-Hell will not even address. Peace- Out
openplsinwmp came in a zip file. I unpacked it, and didn’t find anything that looks like an executable, and even the files in the “doc” folder were in a format windows didn’t recognize. I’m not stupid. you said it would open effortlessly. It didn’t. This a rabbit hole I don’t want to go down.