ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
i am writing a script to convert wma's to mp3's. its based off a kdeapp i found.
it uses mplayer and lame.
this is what i want to do:
find /mnt/rebel-dat/music/ -type f -name '*.wma' -exec wmatomp3 {} \;
which is cool. but i would like it in a more programable form like this:
===================================================================
#!/bin/sh
find /mnt/rebel-dat/music/New\ Rock/u2/ -type f -name '*.wma' | while read WMA
do
DIR=`dirname "$WMA"` # extract path to file
FILE=`basename "$WMA"` # keep just the name of the file
#do some logging
"Why don't you just put a function in your ~/.bashrc like :"
--becuase i want to do some logging and create more features, such as mp3/ogg conversion settings.
"Your script looks programmatically sound to me"
--- i agree but when run it mplayer gives me a
"no bind for key blah"
yes they are correct.
if i replace the mplayer command with ls "$wmafile" then i get the corect listing.
when i do use the mplayer command i get this:
===================================START=====================================
MPlayer 1.0pre3-3.2.2 (C) 2000-2003 MPlayer Team
CPU: Intel Pentium 4/Xeon/Celeron Northwood 2394 MHz (Family: 8, Stepping: 7)
Detected cache-line size is 64 bytes
CPUflags: MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled for x86 CPU with extensions: MMX MMX2 SSE SSE2
Reading config file /usr/local/etc/mplayer/mplayer.conf: No such file or directory
Reading config file /root/.mplayer/config
Reading /root/.mplayer/codecs.conf: Can't open '/root/.mplayer/codecs.conf': No such file or directory
Reading /usr/local/etc/mplayer/codecs.conf: Can't open '/usr/local/etc/mplayer/codecs.conf': No such file or di
rectory
Using built-in default codecs.conf.
font: can't open file: /root/.mplayer/font/font.desc
Font /usr/local/share/mplayer/font/font.desc loaded successfully! (206 chars)
Using Linux hardware RTC timing (1024Hz).
Can't open input config file /root/.mplayer/input.conf: No such file or directory
Can't open input config file /usr/local/etc/mplayer/input.conf: No such file or directory
Falling back on default (hardcoded) input config
Playing /mnt/rebel-dat/music/Jazz/The Motet/Live/01 w.o.w. drums.wma.
ASF file format detected.
============ ASF Stream group == START ===
object size = 32
stream count=[0x1][1]
stream id=[0x1][1]
max bitrate=[0x1f67f][128639]
============ ASF Stream group == END ===
Clip info:
name: w.o.w. drums
author: The Motet
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
AUDIO: 44100 Hz, 2 ch, 16 bit (0x10), ratio: 16002->176400 (128.0 kbit)
Selected audio codec: [ffwmav2] afm:ffmpeg (DivX audio v2 (ffmpeg))
==========================================================================
Checking audio filter chain for 44100Hz/2ch/16bit -> 44100Hz/2ch/16bit...
AF_pre: af format: 2 bps, 2 ch, 44100 hz, little endian signed int
AF_pre: 44100Hz 2ch Signed 16-bit (Little-Endian)
AO: [oss] 44100Hz 2ch Signed 16-bit (Little-Endian) (2 bps)
Building audio filter chain for 44100Hz/2ch/16bit -> 44100Hz/2ch/16bit...
Video: no video
Starting playback...
No bind found for key b
No bind found for key J
A: 0.4 0.0% 0%
No bind found for key M
No bind found for key L
A: 0.8 0.6% 0%
A: 1.2 0.6% 0%
No bind found for key .
No bind found for key b
No bind found for key J
A: 1.6 0.6% 0%
No bind found for key M
No bind found for key L
A: 2.0 0.5% 0%
No bind found for key
.
.----------------continues
.
No bind found for key M
No bind found for key L
A: 8.8 0.7% 0%
===== PAUSE =====
Exiting... (Quit)
-dat/music/Jazz/The Motet/Live/10 belly.wma does not exits
then from here no it is messed up. the names are all missing pieces.
the only thing i can think of is that its a bug in mplayer??
I wrote this script a few days ago. Works flawlessly for me. Gives you plenty of options such as scanning entire computer, scanning current directory and subdirectories, or just current directory. Hope you enjoy.
#!/bin/sh
dialog --title "WmaToMp3" --msgbox "Welcome to Wma to Mp3 Converter!!" 9 28
dialog --msgbox "Lets take a minute to setup some options..." 9 28
dialog --title "Pick One" --menu "Step one: Where would like for me to search for files?" 10 60 3 1 "Entire Computer" 2 "Current Directory and all subdirectories" 3 "Current Directory Only" 2>_1.txt
DIR_OPT=$(cat _1.txt)
dialog --title "Pick One" --menu "Step two: What would like for me to convert them to?" 10 60 2 1 "Mp3" 2 "Leave as wav" 2>_1.txt
CONVERT_OPT=$(cat _1.txt)
if [ $CONVERT_OPT = 1 ];
then
dialog --title "Pick One" --menu "Step three: What bitrate would you like to use?" 10 60 4 1 "64 - Poor" 2 "128 - Better" 3 "192 - Recommended" 4 "320 - Insane" 2>_1.txt
BIT_OPT=$(cat _1.txt)
fi
dialog --title "Pick One" --yesno "Step four: Would You like for me to remove the wma files after converting?" 10 40
DEL_OPT=$?
dialog --title "Converting" --infobox "Converting...
This usually takes a while. Just put on another pot of coffee." 10 60
if [ $BIT_OPT = 1 ]; then
BIT_OPT=64
elif [ $BIT_OPT = 2 ]; then
BIT_OPT=128
elif [ $BIT_OPT = 3 ]; then
BIT_OPT=192
elif [ $BIT_OPT = 4 ]; then
BIT_OPT=320
fi
if [ $DIR_OPT = 1 ]; then
find / -name *.wma > wmalist.dat
elif [ $DIR_OPT = 2 ]; then
find . -name *.wma > wmalist.dat
elif [ $DIR_OPT = 3 ]; then
ls *.wma > wmalist.dat
fi
This script didn't work for me. I'm using MEPIS 3.3 . . the script ran, got the list of questions and everything, but there was no .mp3 output (nor wave). Got some errors that I could read fast enough to actually see.
No, it shouldn't require any libs. Do you have the latest bash? When you execute `mplayer` does it give you any errors? How about `lame` It will only give you errors and not work properly if bash isn't the latest or mplayer and/or lame doesn't work correctly.
For some reason I can't get this script to work I put it into my /usr/bin dir and I have the latest versions of bash, mplayer, and lame when I run the script I get an
For some reason I can't get this script to work I put it into my /usr/bin dir and I have the latest versions of bash, mplayer, and lame when I run the script I get an (snip)
Yeah, this happens when there are non-printable characters before the shebang at the top of the script. Sometimes this happens with cutting and pasting, or moving from windows to unix text formats. Try looking at it in a hex editor (emacs hexl-mode works great) and make sure there's nothing before the #!.
Alrighty man I will check that out tonight when I get home. Thanks for the advice it is prob the move from win to linux because I copied it off my work comptuer which is win. thanks
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.