March 19, 2010

Shell Script For Converting Between Different Audio Formats

All the media players do not support all audio formats. For this, we may need to convert from one format to another. The following step describe how we can do this, and is applicable to almost all formats.

Using Mencoder

Check out my post at Conversion From One Audio Format To Another Using Mencoder. If this doesn't help, you can follow the steps given below.

Using Shell Script

1. Open the terminal, and type,


varsha@varsha-laptop:~$ cd ~/.gnome2/nautilus-scripts

2. Open a new script,

varsha@varsha-laptop:~/.gnome2/nautilus-scripts$ gedit convert\ any\ to\ mp3.sh

3. Type the following code in the file.

mplayer -ao pcm "$1" -ao pcm:file=temp.wav
OUTNAME="${1%%.wma}.mp3"
lame -b 128 temp.wav "$OUTNAME"
rm temp.wav


4. Comment out rm temp.wav if you do not want to remove the temporary file temp.wav, by prepending the line with a #. So,

#rm temp.wav

5. Save the file and close the editor.

6. To convert any file to mp3, right-click the file and select Scripts-> convert any to mp3.sh.



1 comment:

  1. iomoio is an Open Source community resource dedicated to helping open source projects be as successful as possible. We thrive on community collaboration to help us create a premiere resource for open source software development and distribution.

    ReplyDelete