LinuxAnswers DiscussionThis forum is to discuss articles posted to LinuxAnswers.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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
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
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.
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
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).
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:
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
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
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.
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
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?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.