Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - General > LinuxAnswers Discussion
User Name
LinuxAnswers Discussion This forum is to discuss articles posted to LinuxAnswers.


  Search this Thread
Old 07-15-2007, 07:25 AM   #61
LQ Newbie
Registered: May 2006
Location: Australia
Distribution: Fedora Core 7,9,12 CentOs 5
Posts: 26

Rep: Reputation: 15
wma to mp3 conversion

Hi and thanks for that works a treat !
I used it running Fedora core 5, I think was a typo? ":" missing in "-ao pcm:-waveheaders "
as I tried it the first time it barfed out depecrated etc..
otherwise all good
Now I can massage it in Audacity

Old 07-18-2007, 01:25 AM   #62
LQ Newbie
Registered: Jul 2007
Posts: 1

Rep: Reputation: 0

Thanks for the script
Old 07-21-2007, 03:33 AM   #63
LQ Newbie
Registered: Jan 2007
Location: Netherlands
Distribution: gentoo linux
Posts: 6

Rep: Reputation: 0
Originally Posted by glope

Ive been using the script submitted by bospaadje above and i dont believe it is running a search on any files that are more than one folder deep

eg if i run the script from /home/glope then /home/glope and /home/glope/1 or /home/glope/2 will be checked however /home/glope/1/1 will not be as its two levels deeper than the original folder the script is run from

Is this assumption correct and if so is there a way around it?

Thanks in advance

It should work (at least, it works for me ). Can you create some .wma files in such a directory, then run

find -iname '*.wma'
from the home directory? On my box this returns every wma file in the directory, no matter how deep in subfolders. If it does so for you too, but the script doesn't rip & encode them, there's a problem with the script. If it doesn't return the files, try adding
-maxdepth <depth>
to the find command, and if that helps, add it in the script as well. (btw, browsing the man page of find gives me a lot of ideas how this script could be better.. shame all my wma's are already converted )
Old 12-19-2007, 09:34 AM   #64
LQ Newbie
Registered: Dec 2007
Posts: 1

Rep: Reputation: 0
Updated Version of script

Thanks for the script - I've just run with the latest version of mplayer and updated your script to rectify a couple of issues: -


#remove uppercase
for i in *.[Ww][Mm][Aa]; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]' | tr ' ' '_'`; done

#Rip with Mplayer / encode with LAME
for i in *.wma ; do mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader $i && lame -m s audiodump.wav -o `basename $i .wma`.mp3 ; done

# Don't remove old wma files - just in case something goes wrong
# rm *.wma

rm audiodump.wav

Major change is I've combined the last two lines and updated the mplayer command as -waveheader is deprecated in the latest version.

I also combined a few lines to fix a couple of other issues.

I hope you find this an improvement :-)
Old 01-14-2008, 07:59 PM   #65
LQ Newbie
Registered: Aug 2004
Location: Petaluma, CA, US
Distribution: Debian GNU/Linux squeeze/sid
Posts: 28

Rep: Reputation: 17
lame-3.97 and MPlayer-1.0rc2 under Cygwin

Yes, I know this is a Linux forum not Windows/Cygwin, but since the scripter asked for improvements, here are some bashisms which you might want to incorporate into your script. I wrote it to call with args, such as:

$ wma2mp3 *.[Ww][Mm][Aa]
And thus can possibly used with a 'find' command to traverse directories (I haven't tried that).

The main difference between this and the Unix script is the syntax for lame:
$ lame --help
LAME 32bits version 3.97 (

usage: lame [options] <infile> [outfile]

    <infile> and/or <outfile> can be "-", which means stdin/stdout.

    lame -V2 input.wav output.mp3

    -b bitrate      set the bitrate, default 128 kbps
    -h              higher quality, but a little slower.  Recommended.
    -f              fast mode (lower quality)
    -V n            quality setting for VBR.  default n=4
                    0=high quality,bigger files. 9=smaller files
    --preset type   type must be "medium", "standard", "extreme", "insane",
                    or a value for an average desired bitrate and depending
                    on the value specified, appropriate quality settings will
                    be used.
                    "--preset help" gives more info on these

    --longhelp      full list of options
Also I set it for minimum quality (and thus file size); you might want to leave that option out if reducing disk space isn't an issue:

$ cat /usr/bin/wma2mp3
for file in "$@"; do mplayer \
 -vo null \
 -vc dummy \
 -af resample=44100 \
 -ao pcm:file="${file%%.[Ww][Mm][Aa]}.wav" \
 lame -V9 "${file%%.[Ww][Mm][Aa]}.wav" "${file%%.[Ww][Mm][Aa]}.mp3"
 rm -f "${file%%.[Ww][Mm][Aa]}.wav"
And, it doesn't muck with the file name, it leaves mixed case and spaces as they are; it just changes the extension. As you can see, I will have roughly halved the space my WMA files were taking once I delete the originals:

jcomeau@intrepid ~/docs/My Music/Unknown Artist/Unknown Album (10-17-2007 7-14-54 PM)
$ wc -c *
 2496288 01 Track 1.mp3
 4917675 01 Track 1.wma
 2839008 02 Track 2.mp3
 5270259 02 Track 2.wma
  210048 03 Track 3.mp3
  471531 03 Track 3.wma
 2571984 04 Track 4.mp3
 5120859 04 Track 4.wma
  712032 05 Track 5.mp3
 1487451 05 Track 5.wma
 2887944 06 Track 6.mp3
 5264283 06 Track 6.wma
 2246136 07 Track 7.mp3
 4881819 07 Track 7.wma
 3238296 08 Track 8.mp3
 6011283 08 Track 8.wma
50626896 total
Old 07-07-2008, 03:53 PM   #66
LQ Newbie
Registered: Jul 2008
Posts: 2

Rep: Reputation: 0

I have tried the above procedure with the MPLAYER code using the file wmamp3.

The files change to mp3's and are described as such in their properties, but they still dont play.

I dont have a clue how to install the codecs that i might need, can some kind soul please give me a step guide?

The above links to the mplayer site have changed.
Old 07-07-2008, 04:11 PM   #67
LQ Newbie
Registered: Jul 2008
Posts: 2

Rep: Reputation: 0
I have just used the following posted by pdxlinuxnewb on page 4


current_directory=$( pwd )

#remove spaces
for i in *.wma; do mv "$i" `echo $i | tr ' ' '_'`; done

#remove uppercase
for i in *.[Ww][Mm][Aa]; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done

#Rip with Mplayer / encode with LAME
for i in *.wma ; do
mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader $i && lame -m s -h -V0 --vbr-new audiodump.wav -o $i; done

#convert file names
for i in *.wma; do mv "$i" "`basename "$i" .wma`.mp3"; done

rm audiodump.wav

The files took about 5 secs each then i got the following for each one:

Playing 11_ring_ring.wma.
ASF file format detected.
[asfheader] Audio stream found, -aid 1
Clip info:
name: Ring Ring
author: Mika
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
AUDIO: 44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (ratio: 16002->176400)
Selected audio codec: [ffwmav2] afm: ffmpeg (DivX audio v2 (FFmpeg))
[AO PCM] File: audiodump.wav (WAVE)
PCM: Samplerate: 44100Hz Channels: Stereo Format s16le
[AO PCM] Info: Faster dumping is achieved with -vc null -vo null -ao pcm:fast
[AO PCM] Info: To write WAVE files use -ao pcm:waveheader (default).
AO: [pcm] 44100Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...
A: 169.7 (02:49.6) of 170.0 (02:50.0) 0.9%

Exiting... (End of file)
/bin/wmamp3: line 13: lame: command not found
[root@localhost 01]#

The files had .mp3 extensions but still wont play on either Rythmbox or Banshee
Old 07-07-2008, 05:28 PM   #68
Registered: Apr 2004
Location: Timisoara, Romania
Distribution: Debian
Posts: 90

Rep: Reputation: 15
/bin/wmamp3: line 13: lame: command not found

Install lame.
Old 10-06-2008, 11:04 PM   #69
LQ Newbie
Registered: Mar 2004
Location: Mid-Atlantic region -- U.S.
Distribution: Multiple. Depends on my mood.
Posts: 9

Rep: Reputation: 1
This is a few years late, but thanks to you folks for the code.
With a few very minor modifications, I can now rip audio from youtube vids (.flv files).
I just changed "wma" to "flv", took out the loop (I don't generally do batch, just a single file or two at a time.) and I'm set. Eventually, I'll tweak it to strip audio from other files.

Thanks again!

if [ $1 = ""]
echo "You need to enter the name of the video file you want to rip. Example: filename.flv"

filename=`basename "$1" .flv`

echo "Ripping $1"

mplayer -quiet -vo null -vc dummy -af volume=0,resample=44100:0:1 -ao pcm:waveheader "$1"

echo "Encoding $1 to "$filename".mp3"

lame -quiet -m s audiodump.wav -o "$filename".mp3

rm audiodump.wav
Old 10-06-2008, 11:06 PM   #70
LQ Newbie
Registered: Mar 2004
Location: Mid-Atlantic region -- U.S.
Distribution: Multiple. Depends on my mood.
Posts: 9

Rep: Reputation: 1
Sorry. I meant "months late" not years.
Old 10-08-2008, 03:45 AM   #71
Registered: Aug 2003
Location: Melbourne Australia
Distribution: LinuxMint Elyssa
Posts: 374

Original Poster
Rep: Reputation: 32
Smile Fantastic

WOW, i didn't imagine that this tutorial would still be helping people years later. I dont jump on the forums much any more but i might get started again.
Old 10-08-2008, 06:22 AM   #72
Registered: Oct 2008
Posts: 42

Rep: Reputation: 15
people find nice usage for this script and change it for their needs, very nice job.

Debian Development

Last edited by pinballwizard66; 10-22-2008 at 12:31 PM.
Old 10-15-2008, 05:29 AM   #73
Registered: Oct 2004
Location: London, UK
Distribution: Suse 12.1
Posts: 79

Rep: Reputation: 15
Lightbulb pcm -waveheader

This script works perfectly, just wanted to add that with the new mplayer you have to change the script where it says pcm -waveheader to pcm:waveheader

Enjoy it.

Old 01-26-2009, 10:32 PM   #74
LQ Newbie
Registered: Jan 2009
Posts: 1

Rep: Reputation: 0
Talking Thank you

Thanks a lot.

Some modifications - adding spaces again.


current_directory=$( pwd )

#remove uppercase
for i in *.WMA; do mv "$i" "`basename "$i" .WMA`.wma"; done
#for i in *.[Ww][Mm][Aa]; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done

#remove spaces
for i in *.wma; do mv "$i" `echo $i | tr ' ' '_'`; done

#Rip with Mplayer / encode with LAME
for i in *.wma ; do mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader $i && lame -b 256 -m s audiodump.wav -o $i; done

#remove underline
#convert file names
for i in *.wma; do
		neuer_name=`echo $i | tr -s '_' '\ '`
		mv "$i" "`basename "$neuer_name" .wma`.mp3";

rm audiodump.wav
... My car and me hate WMA

Last edited by Be123; 01-26-2009 at 10:37 PM.
Old 02-13-2009, 08:25 AM   #75
Registered: Aug 2008
Location: Beacon Bay, East London, South Africa
Distribution: Ubuntu
Posts: 30

Rep: Reputation: 16
I wrote a script that transcodes audio even to and from WMA while preserving meta data information. Check this link


amarok, convert, mp3, wma

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert wma to ogg lixy Linux - Software 20 10-12-2011 05:58 PM
convert wma > mp3? andrewlkho Linux - Software 31 08-20-2007 12:26 AM
wma to mp3 pulsez Linux - Newbie 5 10-27-2005 07:17 PM
Any program that can convert mp3 files to wma? josh_hd_new Linux - Newbie 1 01-21-2005 02:03 AM
how to convert a wma to mp3?? yenonn Linux - General 2 04-26-2004 07:25 PM > Forums > Linux Forums > Linux - General > LinuxAnswers Discussion

All times are GMT -5. The time now is 05:32 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration