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.
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
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 )
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.
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:
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:
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
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
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.
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
#!/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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.