LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxAnswers Discussion
User Name
Password
LinuxAnswers Discussion This forum is to discuss articles posted to LinuxAnswers.

Notices

Reply
 
LinkBack Search this Thread
Old 07-15-2007, 07:25 AM   #61
albertBeach
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

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

Rep: Reputation: 0
Thanks

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

Rep: Reputation: 0
Quote:
Originally Posted by glope
Hi,

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

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

Code:
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
Code:
-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
chrisg67
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: -

[HTML]<pre>#!/bin/bash

#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
</pre>
[/HTML]

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
jcomeau_ictx
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:

Code:
$ 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:
Code:
$ lame --help
LAME 32bits version 3.97 (http://www.mp3dev.org/)

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

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

RECOMMENDED:
    lame -V2 input.wav output.mp3

OPTIONS:
    -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:

Code:
$ cat /usr/bin/wma2mp3
#!/bin/bash
for file in "$@"; do mplayer \
 -vo null \
 -vc dummy \
 -af resample=44100 \
 -ao pcm:file="${file%%.[Ww][Mm][Aa]}.wav" \
 "$file"
 lame -V9 "${file%%.[Ww][Mm][Aa]}.wav" "${file%%.[Ww][Mm][Aa]}.mp3"
 rm -f "${file%%.[Ww][Mm][Aa]}.wav"
done
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:

Code:
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
pibri2
LQ Newbie
 
Registered: Jul 2008
Posts: 2

Rep: Reputation: 0
Help!

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
pibri2
LQ Newbie
 
Registered: Jul 2008
Posts: 2

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

#!/bin/bash

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
acker
Member
 
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
SA_Ron
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 = ""]
then
echo "You need to enter the name of the video file you want to rip. Example: rip_flv.sh filename.flv"
exit
fi

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
SA_Ron
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
cadj
Member
 
Registered: Aug 2003
Location: Melbourne Australia
Distribution: LinuxMint Elyssa
Posts: 373

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
pinballwizard66
Member
 
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
gcclinux
Member
 
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.

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

Rep: Reputation: 0
Talking Thank you

Thanks a lot.

Some modifications - adding spaces again.

Code:
#!/bin/bash

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";
done

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
dopla
Member
 
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 http://mkanyicy.blogspot.com/2009/01...ast-audio.html
 
  


Reply

Tags
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
Trackbacks are Off
Pingbacks are On
Refbacks are 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


All times are GMT -5. The time now is 04:33 PM.

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