28 September, 2007

Linux : converting wma to mp3

It was never this simple !!
The only thing you need is : MPlayer codecs (w32all-codecs). You probably already have them installed if videos (specially avi) are running fine on your distro

Change to the directory where the wma files are stored ....
Type in the following one-by-one in the terminal (a script file will also work .. and probably be much more simpler... but lets use the terminal !!)

Thanks to : http://www.linuxquestions.org/linux/answers/Applications_GUI_Multimedia/Convert_WMA_to_MP3)

//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 audiodump.wav -o $i; done

//convert file names
for i in *.wma; do mv "$i" "`basename "$i" .wma`.mp3"; done rm audiodump.wav



The only change you require is probably in the conversion script... wherein.. the -waveheader option is deprecated..
instead modify it as : -ao pcm:waveheader
and it'll work fine !!

simple and fast... eh !!

18 September, 2007

Etags

Imagine studying the linux kernel (for entirely sane purposes :D) with thousands of files containing thousands of functions... Around 70MB worth of text... And you are told to find a function in this haystack !! (well... don't even try grep.. it takes MONTHS to return a result.. I'd rather search manually :P)

Etags swoops in to ur rescue...
etags is basically a utility which generates tags for each function or data definition.
eg. a function declaration fun() would yeild "fun" as a tag. The corresponding file name and the offset at which the definition can be found is recorded in the file TAGS. TAGS is used by Emacs editor to simulate hyperlinks for tokens.
In simple language, if you come across a function and wonder how it is coded... just move the cursor over the function name and press M-. (M= meta key... usually ALT)... and voila!
The simplest way to browse a code !!
neat... eh!

wanna go back to where you were... no probs... M-* and there you are !!
Linux continues to amaze me!!

For kernel source code :
go to /usr/src/linux-[version]
login as su.. nd type in "make TAGS"...

For your own directory tree:
this is a bit clumsy since etags dosen't support nested directories... etags searches for specified files ONLY in the current directory... so.. the roundabout way is :
go to the root of your directory tree and type in
$ find . -name "*.[chCH]" -print | etags -
and voila!:D

what it does is... the find command returns all the filenames of .c and .h extension and this output is piped to etags command (the hyphen after etags directs etags to use standard output as its input)...

now that i see what linux editors can do... notepad suddenly appears soo lame !!:)

06 September, 2007

uhhh... suse problems !! (and solutions :d)

Yesterday was an eventful day for me. Finally I was prepared to completely dump windows and switch over to linux. As a part of that endeavour, downloaded w32 codecs and got video and all other workable things working on my Suse 9.3 ... and in the excitement of videos running flawlessly on my distro (which is outdated and antic :D), tried running as many as 5 movies on all possible video players !!

Today, I would quit Windows. Little did I know what Linux had in store for me :(
(Btw... this has forced me rethink the "completely" part of dumping windows... I'd rather use Windows to troubleshoot linux when it crashes :D... a worthy use for Windows :) )

The thing is, I have a 10G partition dedicated to Linux, of which only about 5G is currently in use. But, today while I was browsing the internet, a pop-up message showed up saying I was low on disk space and within minutes, all applications ceased and failed to load when I tried to restart them. I looked around for a while, then decided to reboot (the windows way :D)... but, when I rebooted, Suse tells me that I can't even log in because the disk is 100% full !!... Not a byte to spare for the user of the system to log in!!... (may be because XWindows system requires some disk space??) whats suse goin to do without ME :D

Anyways, so here's where windows comes in, a simple google search suggested that I use the du command to check the disk usage and then decide on the further action.
So, booted Linux in failsafe mode, and entered du :
The problem was : the temporary folder (/tmp) was hogging half of the disk with a whopping 4.8G !!

and why's that ??.... well .. apparently when I played the movies yesterday (which were stored on the windows drive), what linux did in the background was :
it copied the movie, realtime, onto the linux /tmp folder and then played the movie. i.e. the entire movie was being copied onto my linux drive in the background. And the responsible application didn't even delete it from the temp folder!! I am still not able to pinpoint whether the erring app is kaffeine, VLC or Mplayer... but once I do, its going to get a beating of a lifetime :D

So, solution ?? ....
$ rm -rv /tmp
(del contents on tmp folder)