In many situations we want to convert Audio format. So the question arises in our mind how to do that? The user of windows operating system found it very simple download a mp3 converter and its simple But open source users of CentOs get stuck for few seconds. So guys I tell you you don’t even need a software to do it you can convert a .wav format file in mp3 in seconds this is the power of open source not even this by using that script you can convert all .wav files inside the folder and its sub folders in one go and you can use this script on your Projects too. So lets follow the simple steps to do this magic
First you need to configure the environment for Lame and I am using centOS 5.4
Step 1. Download Lame from http://sourceforge.net/projects/lame/files/lame/3.99/ and place it in /opt/ folder and then cd /opt/
Step 2. The downloaded file is lame-3.99.5.tar.gz now first gunzip the file using #gunzip lame-3.99.5.tar.gz after unzippiing it you will get lame-3.99.5.tar now you need to untar this file using command #tar -cvf lame-3.99.5.tar and then #cd lame-3.99.5
Step 3. Then you need to configure it using 1. # ./configure 2. # make 3. #make install now your lame is installed in you machine. Now you want to change .wav files in to mp3 files. We will write a simple shell script to convert wav format to mp3.
$ cat > wav2mp3.sh #!/bin/sh # wav to mp3 for i in *.wav; do if [ -e "$i" ]; then file=`basename "$i" .wav` lame -h -b 192 "$i" "$file.mp3" fi done $ chmod u+x wav2mp3.sh $ sh wav2mp3.sh Now look in your the folder you will get.mp3 files with same names.