LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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
 
Search this Thread
Old 10-05-2005, 11:47 PM   #46
ertmann|CPH
Member
 
Registered: Oct 2003
Location: Copenhagen
Distribution: Debian SID
Posts: 36

Rep: Reputation: 15

I tried doing it with this googled script:

Quote:
#!/bin/bash
#
# Dump wma to mp3

for i in *.wma
do
if [ -f $i ]; then
rm -f "$i.wav"
mkfifo "$i.wav"
mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader "$i" -aofile "$i.wav" &
dest=`echo "$i"|sed -e 's/wma$/mp3/'`
lame -h -b 192 "$i.wav" "$dest"
rm -f "$i.wav"
fi
done
However i get this message:

Quote:
-aofile is deprecated. Use -ao pcm:file=<filename> instead
And i can't for the love of god figure out how to change the script to encompas that... seems like i would be the same with the other script, anyone who could get their head around it for me?
 
Old 10-10-2005, 11:27 PM   #47
mohapi
Member
 
Registered: Mar 2003
Distribution: Debian
Posts: 208

Rep: Reputation: 30
[root@localhost booda]# cp /home/booda/wmamp3 /usr/bin/
cp: omitting directory `/home/booda/wmamp3'

How do I get this to copy to /usr/bin? And can I add .rm to the script as well as .wma? If so, how?
Thanks
 
Old 10-11-2005, 05:46 AM   #48
acker
Member
 
Registered: Apr 2004
Location: Timisoara, Romania
Distribution: Debian
Posts: 90

Rep: Reputation: 15
Quote:
Originally posted by mohapi
[root@localhost booda]# cp /home/booda/wmamp3 /usr/bin/
cp: omitting directory `/home/booda/wmamp3'

How do I get this to copy to /usr/bin? And can I add .rm to the script as well as .wma? If so, how?
Thanks
cp -R /home/booda/wmamp3 /usr/bin/

It is a directory and you have to do it recursively. I haven't read what it was said before but you probably want to copy just the executable file. (Where is it? In the ~/wmamp3/ directory?)

I don't know what script you're talking about so I can't say if you cand change that to .rm.

But please check this: http://seismic.ocean.dal.ca/~leblanc...onversion.html (already posted this info here: http://www.linuxquestions.org/questi...80#post1732680 )

acker
 
Old 10-11-2005, 05:53 AM   #49
acker
Member
 
Registered: Apr 2004
Location: Timisoara, Romania
Distribution: Debian
Posts: 90

Rep: Reputation: 15
Quote:
Originally posted by ertmann|CPH
However i get this message:
[/B]
Managed to fix it? If not, I believe you should do exactly what the program said. Change
mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader "$i" -aofile "$i.wav" &
with
Code:
mplayer -vo null -vc dummy -af resample=44100 -ao pcm:waveheader "$i" -ao pcm:file="$i.wav" &


Haven't tried this, but I think it will work.

Last edited by acker; 10-11-2005 at 06:08 AM.
 
Old 10-11-2005, 07:24 PM   #50
mohapi
Member
 
Registered: Mar 2003
Distribution: Debian
Posts: 208

Rep: Reputation: 30
thanks acker. that did it.
 
Old 12-02-2005, 10:47 AM   #51
Hagen99
LQ Newbie
 
Registered: Dec 2005
Location: MX
Posts: 2

Rep: Reputation: 0
Troubles

Hello grettings from MEX

I have some troubles with the convertion
this what I got

Code:
Ripping 10 Pista 10.wma
MPlayer 1.0pre6-3.3.5 (C) 2000-2004 MPlayer Team
CPU: Intel Pentium 4/Xeon/Celeron Northwood (Family: 8, Stepping: 4)
Detected cache-line size is 64 bytes
CPUflags:  MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled for Debian.


Linux RTC init error in ioctl (rtc_irqp_set 1024): Permiso denegado
Try adding "echo 1024 > /proc/sys/dev/rtc/max-user-freq" to your system startup scripts.
Opening joystick device /dev/input/js0
Can't open joystick device /dev/input/js0 : No existe el fichero o el directorioCan't init input joystick
Setting up LIRC support...
mplayer: could not connect to socket
mplayer: No existe el fichero o el directorio
Failed to open LIRC support.
You will not be able to use your remote control.
Playing 10 Pista 10.wma.
ASF file format detected.
Clip info:
 name: Pista 10
 author: Intérprete desconocido
==========================================================================
Trying to force audio codec driver family libmad...
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
AUDIO: 44100 Hz, 2 ch, 16 bit (0x10), ratio: 8003->176400 (64.0 kbit)
Selected audio codec: [ffwmav2] afm:ffmpeg (DivX audio v2 (ffmpeg))
==========================================================================
This the script I'm using for:

Code:
for i in *.wma
do
        filename=`basename "$i" .wma`
        #Rip with Mplayer / encode with LAME
        echo "Ripping $i"
        mplayer -vo null -vc dummy -af resample=44100:0:1 -ao pcm:waveheader "$i"
        echo "Encoding $i to "$filename".mp3"
        lame -quiet -m s audiodump.wav -o "$filename".mp3
        rm audiodump.wav
done

Any clue???
Tnks!!
 
Old 12-02-2005, 02:32 PM   #52
acker
Member
 
Registered: Apr 2004
Location: Timisoara, Romania
Distribution: Debian
Posts: 90

Rep: Reputation: 15
Re: Troubles

Quote:
Linux RTC init error in ioctl (rtc_irqp_set 1024): Permiso denegado
Try adding "echo 1024 > /proc/sys/dev/rtc/max-user-freq" to your system startup scripts.
Do that. (As root). Now and in a script that will be runned when your computer boots.
Quote:
Opening joystick device /dev/input/js0
Can't open joystick device /dev/input/js0 : No existe el fichero o el directorioCan't init input joystick
You don't need a joystick, do you?

Quote:
Setting up LIRC support...
mplayer: could not connect to socket
mplayer: No existe el fichero o el directorio
Failed to open LIRC support.
You will not be able to use your remote control.
No problem here... LIRC is for infrared remote controls. You don't have it... move along.

Quote:
Code:
Playing 10 Pista 10.wma.
ASF file format detected.
Clip info:
 name: Pista 10
 author: Intérprete desconocido
==========================================================================
Trying to force audio codec driver family libmad...
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
AUDIO: 44100 Hz, 2 ch, 16 bit (0x10), ratio: 8003->176400 (64.0 kbit)
Selected audio codec: [ffwmav2] afm:ffmpeg (DivX audio v2 (ffmpeg))
==========================================================================
This the script I'm using for:

Code:
for i in *.wma
do
        filename=`basename "$i" .wma`
        #Rip with Mplayer / encode with LAME
        echo "Ripping $i"
        mplayer -vo null -vc dummy -af resample=44100:0:1 -ao pcm:waveheader "$i"
        echo "Encoding $i to "$filename".mp3"
        lame -quiet -m s audiodump.wav -o "$filename".mp3
        rm audiodump.wav
done
What is exactly the problem?
Does mplayer crashed on you? If so, try
mplayer -vo null -vc dummy -ao pcm:waveheader "$i
that is without the resample option. Check that your files sound all right before deleteing them. If not, man mplayer and tweak the options.

----
You should definitely check: http://seismic.ocean.dal.ca/~leblanc...onversion.html . Why? Cause it supports some moving of tags while converting from source to destination. And others.
 
Old 12-02-2005, 03:32 PM   #53
Hagen99
LQ Newbie
 
Registered: Dec 2005
Location: MX
Posts: 2

Rep: Reputation: 0
I did the "echo...."

but I think the problem is that i cant play my wma files, I can watch some wmv but no this wma
I installed mplayer with wma support but I cant listen them either
So when I tried to convert them it just give a interference
 
Old 12-02-2005, 04:11 PM   #54
acker
Member
 
Registered: Apr 2004
Location: Timisoara, Romania
Distribution: Debian
Posts: 90

Rep: Reputation: 15
If you can't listen them with mplayer than you probably won't be able to convert them. My suggestions: install other codecs (instead of ffmpeg). You can find win32codecs here: http://www.mplayerhq.hu/MPlayer/releases/codecs/. Try a newer ffmpeg if you can find.
Than you should tell mplayer not to use ffmpeg and use one of those codecs. (and of course try to test the wma's somewhere else, like a windows machine).
 
Old 03-04-2006, 12:05 PM   #55
demerson3
Member
 
Registered: Sep 2004
Location: Los Angeles
Distribution: debian stable
Posts: 43

Rep: Reputation: 15
Just a suggestion for cleaner file-renaming: use the rename command, with the y option (which is equivalent to tr)...

Code:
# convert spaces to underscores, and filenames to all-lowercase

for i in *.[Ww][Mm][Aa]; do
  rename 'y/A-Z /a-z_/' "$i"
done
Of course it's no unreasonable to want to preserve capitalization of artist names, etc., but to want to change only capital WMA's to lowercase wma ... and to eliminate whitespace. Here's a snippet to do just that:

Code:
# convert spaces to underscores, and "WMA" to lowercase

for i in *.[Ww][Mm][Aa]; do
  rename 'y/ /_/; s/wma$/wma/i' "$i"
done
I'd also argue that it's a little sloppy to have lame output to the original wma files. What if something goes wrong? Better to output to new files, and remove the original wma's once you've verified that the mp3's are good. The double quotes around "$i" will protect spaces (and other characters) in file names in case you like having space in your file names.

Code:
#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 "$i.mp3"
 rename 's/.wma.mp3$/.mp3/i' "$i.mp3"
done

rm audiodump.wav
and when you're ready, rm *.wma


Someone out there suggested using the find command to traverse directories. By piping the output of a find command into "while read i" we can effectively deal with filenames containing whitespace and other annoyances. Putting it all together:

Code:
find -iname '*.wma' | while read i; do
  mplayer -vo null -vc dummy -af resample=44100 -ao pcm -waveheader "$i" && lame -m s audiodump.wav -o "$i.mp3"
  rename 'y/ /_/; s/wma$/wma/i; s/.wma.mp3$/.mp3/i' "$i" "$i.mp3"
done
rm audiodump.wav
And then when you want to get rid of those old wma's...
Code:
find -iname '*.wma' -print0 | xargs -0 rm
Note: I previously had a rename command BEFORE the mplayer/lame commands -- this was a bad idea! It would have renamed the files, and then tried to operate on the old filenames. Oops... of course, not a single person seems to have reported a problem, which would indicate the lack of use of these scripts...

It's a little off-topic (okay, it's way off-topic) but does anyone know the difference between semicolon and double-ampersand?

do mplayer && lame
vs.
do mplayer; lame

Cheers!

Last edited by demerson3; 01-19-2007 at 03:57 PM. Reason: fix errors/bugs
 
Old 01-16-2007, 11:41 AM   #56
bospaadje
LQ Newbie
 
Registered: Jan 2007
Location: Netherlands
Distribution: gentoo linux
Posts: 6

Rep: Reputation: 0
Quote:
Originally Posted by demerson3
It's a little off-topic (okay, it's way off-topic) but does anyone know the difference between semicolon and double-ampersand?

do mplayer && lame
vs.
do mplayer; lame

Cheers!
i believe the && requires the first command to exit cleanly to go on to run lame while the ; just goes on to next command even if the first one terminates with an error.
see for yourself:
execute
Code:
sleep 30 && echo "hello world"
in a terminal and terminate the first command within 30 seconds (ctrl-c), do this again with
Code:
sleep 30; echo "hello world"
and note the difference in output :-)

btw, thanks for the summary
 
Old 01-16-2007, 08:27 PM   #57
bospaadje
LQ Newbie
 
Registered: Jan 2007
Location: Netherlands
Distribution: gentoo linux
Posts: 6

Rep: Reputation: 0
Quote:
Originally Posted by cadj
dibblethewrecke has made this a lot easier, by explaining that using quotes removes the need to remove spaces and uppercase, have a look, this may work for you.
Code:
for i in *.wma
do
	filename=`basename "$i" .wma`
	
	#Rip with Mplayer / encode with LAME
	echo "Ripping $i"
	mplayer -quiet -vo null -vc dummy -af volume=0,resample=44100:0:1 -ao pcm:waveheader "$i" 
	echo "Encoding $i to "$filename".mp3"
	lame -quiet -m s audiodump.wav -o "$filename".mp3

	rm audiodump.wav
done
if you have many folders/subfolders with wma's, use this at the top instead
Code:
for i in $(find -iname *.wma); do
this runs the 'find' command and processes the outputs
I ran into some problems using this with the $(find -iname *.wma); first of all, if the wildcard gets expanded by bash and you have filenames with capitalised extensions while others are not, this does not return all files; use $(find -iname '*.wma') instead.

Second, and more importantly, it does not work with filenames containing spaces. The for loop treats filenames with a space as two different filenames (the part before and the part after the space are seen as two different values that $i should assume). I have not found an easy escape from this; if anyone know how to tell a bash for loop to use a newline-separated list of values instead of a (white)space separated one, please tell me

all this led me to the following script:
Code:
#!/bin/bash

#use this if you want your mp3s in a new dir
#target="music_dir/wma_to_mp3"

current_directory=$( pwd )
files="$(find -iname '*.wma')"   #returns a newline-separated list of files
count="$(echo "$files" | wc -l)" #number of files

for j in $(seq 1 "$count"); do
        # get file nr. $j
        filename=$(echo "$files" | sed -n ''$j'p')
        subdir="$(dirname "$filename" | sed -e 's_^./__')"

        #set destination file
        #replace ./ with "$target" if you want your mp3s in a new dir
        dest=./"$subdir"/"$(basename "$filename" | tr A-Z' ' a-z_ | sed -e 's/wma$/mp3/')"

        #creates subdir if necessary 
        #(use if you replace ./ in the above line by "$target")
        #if [ ! -e "$target""$subdir" ]
        #then
        #        mkdir -p "$target""$subdir"
        #        echo "created directory "$target""$subdir""
        #fi

        #rip+encode using mplayer and lame
        echo "["$j"/"$count"] ripping "$filename""
        mplayer -really-quiet -vo null -vc null -af resample=44100 -ao pcm:waveheader "$filename" 
        echo "["$j"/"$count"] encoding "$filename" to "$dest""
        lame -quiet -m s audiodump.wav -o "$dest"
done
rm audiodump.wav
feel free to remove the tr A-Z' ' a-z_ part in the dest= line; it's only there because i want my filenames to be lowercase and space-less. Make sure you handle uppercase extensions well though, if you remove it you should probably replace the sed command that follows it by
Code:
sed -e 's/[Ww][Mm][Aa]$/mp3/'
EDIT: changed the script to more graciously handle subdirectories, and use a for instead of a while loop.

Last edited by bospaadje; 01-17-2007 at 03:49 AM.
 
Old 03-24-2007, 07:13 AM   #58
pdx_linuxnewb
LQ Newbie
 
Registered: Mar 2007
Posts: 1

Rep: Reputation: 0
Cool

This script was bombing bad on me so I tweaked it a little. Here's my rendition of the same script.

Code:
#!/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
Working great so far. Thanks for the example
 
Old 05-04-2007, 06:41 PM   #59
gothicbob
Member
 
Registered: Sep 2005
Location: Birmingham / Bath Uk
Distribution: Kubuntu 8.10, Debain 4.0
Posts: 86

Rep: Reputation: 16
For the recurrsive loop I was getting an annoying problem for some reason which only happened when searching for wma's

find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]


so i changed the following code:

Code:
for i in $(find -iname *.wma); do
to:

Code:
for i in $(find -iname "*.wma"); do
and it seems to work now, although it doenst seem to actually be recurrsive.
 
Old 07-08-2007, 06:50 PM   #60
glope
LQ Newbie
 
Registered: Jul 2007
Posts: 1

Rep: Reputation: 0
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
 
  


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


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 07:17 AM.

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