Computing.Net > Forums > Linux > script .wma > .mp3

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

script .wma > .mp3

Reply to Message Icon

Name: USAma Hashimi
Date: April 3, 2006 at 05:13:34 Pacific
OS: Gentoo/Ubuntu
CPU/Ram: 1.7 GHz Intel Celeron/512
Comment:

Hi
You can use the following script to convert your .wma files into .mp3 files.

#!/bin/sh
mplayer $1 -ao pcm:file=$1.wav; lame $1.wav $1.mp3

After convertion, the converted file has name like this;
<filename>.wma.mp3
you can rename it to;
<filename>.mp3
I have tested this script and it suerly is working.
NOTE: mplayer and lame are prerequisite for this script.
Thanks



Linux's Boy Friend.
If you want to mail me please remove "hotdog" from my mail address.



Sponsored Link
Ads by Google

Response Number 1
Name: 3Dave
Date: April 3, 2006 at 07:45:14 Pacific
Reply:

Can you not just pipe the mplayer output to lame and encode it on the fly rather than having to write a big wav file? I used to use a similar command using sox, play and lame when recording my vinyl records straight to mp3.

Thinking about it, if you have mplayer installed can you not just use mencoder to convert the files?


0

Response Number 2
Name: USAma Hashimi
Date: April 3, 2006 at 08:21:06 Pacific
Reply:

Hi 3Dave
I tried a lot of things (scripts) and found this script working so I thought to share it with you.
Thanks


Linux's Boy Friend.
If you want to mail me please remove "hotdog" from my mail address.


0

Response Number 3
Name: 3Dave
Date: April 3, 2006 at 11:09:55 Pacific
Reply:

Sharing things is good...that's why I like open source! If I can did out my old sox/play/lame command then I will post that too.

Note that you are recompressing and already compressed file....sound quality will not be the best.

Here are some more ideas:

In one command:
$ for i in *.wma ;do mplayer -ao pcm -aofile "${i%.wma}.wav" "$i"; oggenc "${i%.wma}.wav";rm "${i%.wma}.wav"; done


And a script:
#!/bin/bash
DATE=$(date '+%m-%d-%Y')
TIME=$(date '+%H:%M:%S')
STARTLOCATION="$1"

# Start a new file
echo "Start converting at $DATE $TIME with PID $$" > /tmp/wma2mp3.$$
echo "OGG is better and free (SCNR)">> /tmp/wma2mp3.$$

# For encoding wma to mp3 (but ogg is much better ;-) )
for i in "`find "${STARTLOCATION}" -name *.wma -print`"
do
mplayer -ao pcm -aofile "${i%.wma}.wav" "$i" && lame -h "${i%.wma}.wav" "${i%.wma}.mp3"

# Use this for ogg:
#mplayer -ao pcm -aofile "${i%.wma}.wav" "$i" && oggenc "${i%.wma}.wav"

# If returncode == 0
if [ $? -eq 0 ];then
echo "\"${i}\" convertet to \"${i}.mp3\"" >> /tmp/wma2mp3.$$
rm "${i%.wma}.wav" && rm "${i}"
else
echo "failed decoding \"${i}\"" >> /tmp/wma2mp3.$$
fi
done

echo "Finished converting at $DATE $TIME with PID $$" >> /tmp/wma2mp3.$$
cat /tmp/wma2mp3.$$|mail -s "Files converted on ${DATE}" root


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Linux Forum Home


Sponsored links

Ads by Google


Results for: script .wma > .mp3

Mp3 play script www.computing.net/answers/linux/mp3-play-script/22275.html

mp3 script www.computing.net/answers/linux/mp3-script/30270.html

Shell scripting help www.computing.net/answers/linux/shell-scripting-help/19723.html