Monday, November 24, 2008

burn cd / dvd

CD --

mkisofs -f -U -iso-level 4 -R -x unused_dir 59m/59mh | cdrecord -v -pad speed=1 dev='/dev/scd1' -

In this command, "-f" makes it follow symbolic link. 59m/59mh is the src dir. What will be burnt into the CD everything under this dir recursively. But 59m or 59mh will NOT be in the image. /dev/scd1 is the cdrom device.

DVD --

Unsure if this can be piped. But breaking it down to 2 steps works fine

mkisofs -f -U -iso-level 4 -R -x unused_dir src | growisofs -dvd-compat -Z /dev/scd1=/dev/fd/0

(http://ubuntuforums.org/showthread.php?t=363666)

Wednesday, October 15, 2008

ripping an audio cd on linux

Still in the after shock of losing my Windows system.  This time I need to rip an audio cd.  Well everything can be done on Linux.  No doubt about that.  And can be done in easier ways, and funner.  Just that you need to find it.  Yes, Google made it possible.  Also credits go there...

cdparanoia -wB -d/dev/cdrom
for i in *.wav; do lame -b 192 $i `basename $i .wav`.mp3; done

Power of collective talents!

Thursday, September 11, 2008

the evil CSS, region cod, etc.

Typically technologies are enablers.  DVD is far from being the newest technology, but it makes easy and quality yet at home movies watch experiences possible.  DVDs are affordable, if you don't travel.

There are other "technologies", that are rather blockers.  They are there to make something not working for paid users, in hopes that (abiding) users pay double or multiple.  Among the most evils, is this DVD region + css thing.  Someone decided that DVD buyer only can see a DVD in 1 geographic region by paying once.  If you want to see your favorite movie in Japan while you already purchased a DVD in U.S., you still have to pay for another copy in Japan.  If you travel globally, you better not want to watch different movies, otherwise you have to pay for the same thing 7 times.  And whats worse, you better not buy DVDs outside your region, because your home DVD player is not supposed to be able to play them, after 5 times region switches.  Or you must pay a hefty fee to the player manufacturer to get you addition 5 region switches.  All but you are the winners.  Good deal!

Losers, forced ones, don't get to be good citizens, not voluntarily.

My new toy, that 24" iMac, lovely as it is, has a Matsushita UJ-875 DVD rom in it.  Most late DVD ROMs have region control in firmware.  In this case using a region relaxed player ain't cutting it.  For many of such RPC2 ROMs, http://forum.rpc1.org is a good place to look for upgrade firmware.  Nothing else on earth deserves the word UPGRADE more.  I am unlucky.  Searching with my Matsushita version DB09 gets me no goody.  
I do have another box, a Ubuntu Hardy Heron.  It is headless (no monitor connected to it).  So viewing needs to be on iMac.  Playing directly on Ubuntu via ssh and pipe the raw frames to iMac is not an option.  It takes too much bandwidth than my LAN can handle, 480x720x30(fps)x8x4(32 bit) = ~320 Mbps.  I think my router is the bottle neck, but I am not sure.  Wikipedia tells me full duplex ethernet gets only 200 Mbps.  This would not be enough either.
Sharing Ubuntu DVD ROM seems a natural solution.  But I was unable to find how to share DVD via nfs.  I would certainly guess it is possible, why would it not be?  Sharing via samba made it work, however.  Two plain tricks.  One is I had to install libdvdnav, libdvdread, and libdvdcss on Ubuntu.  I found this surprising.  So the shared DVD ROM is not receive IO commands and then reading the binary out to the remote machine, but receives DVD commands.  Second, the original movie player on iMac does not work with this approach.  No idea why not.  But at least VLC works.  So I am happy.
While googling, I found a software called k9copy.  It is said to work like DVD Shrink on windows.  Just downloaded and made a build.  Will mess with it one day, when my son orders me to make a copy for him.  It won't be long.

Monday, September 1, 2008

svn server set up

Today I set up a svn server on my Ubuntu.   Since I am good at losing my works, thought svn might be a good help.  I don't have a good grasp on cvs, and pretty close to hating it.  svn on the other hand is closer to clearcase that I am most used to.  So that was my choice.  Well, clearcaes would have been nice, just that it surely would be an overkill, and non open source.

To get to the meat, first this very nice site got me a jump start - http://www.section6.net/wiki/index.php/Setting_up_Subversion_in_Linux

I already had svn installed.  But to follow the instructions, I did 

apt-get install subversion-tools python-subversion libsvn-perl
mkdir /svnroot
svnadmin create /svnroot
vi /svnroot/conf/svnserve.conf (set proper configs, commends are explanatory) 
vi /svnroot/conf/authz (to add rw account to /)
vi /svnroot/conf/passwd (to add account / password pairs)
vi /etc/init.d/svnserve (paste in the bash script provided by the above mentioned blog)
chmod +x /etc/init.d/svnserve
update-rc.d svnserve defaults
/etc/init.d/svnserve start

Unless I forgot something, these were all I did.  It was pretty simple and quick, and working (more importantly).  Not bad, eh?

Saturday, August 30, 2008

"find" performance on windows ntfs vs linux ext3

Just for the heck of it, I ran a find command to look for the same file under the same relative path, in (Cygwin over) Windows and in Linux.  The performance is ~50 times difference. Guess who is faster :) .  Add more to the twist, my Windows machine is a Core 2 Duo @ 2.13 Gig (each, of course), with 2.5GB ram; Linux is running on a Pentium-4 @ 2.8 Gig, single core, 2GB ram.

Cygwin over Windows:
ztang@LV017554 /cygdrive/c/same_folder_tree_node 
$ time find . -name b.bat
./b.bat

real 0m9.290s
user 0m1.483s
sys 0m7.796s


Linux
ztang@ubuntu2:~/projects/same_folder_tree_node$ time find . -name b.bat
./b.bat

real 0m0.196s
user 0m0.056s
sys 0m0.136s

sdl, gpac, dss, and others

I should have roughly about 300 gig HDD to fill for my new toy, Ubuntu 8.04.  The smallest of the 4 HDDs is a 40 gig one, where I store the boot, os, and everything the is dependent on it, so that pretty much means all the software.  Then I should have 250+ gigs for data, should be primarily multimedia.  That should be fun.

For now, I am reloading the all software I used and think that I will be using, ffmpeg, mm codecs, mplayer, vlc, etc.  All were kind of smooth, just time consuming.  Here are couple of hurdles that might be worth documenting.

SDL - when configuring and compiling SDL, it does not care if there is no graphic drivers, or devices available.  Don't get why.  So a successful build of it does not mean much.  I ran vlc or mplayer, all were fine with audio, but video could not find any device.  So I had to go apt-get install a bunch of directfb, gtk stuffs.  Easy enough, just don't get why SDL doesn't crap out at config time.

gpac, except for its MP4Box, I never used anything else of it.  But it seems it has a player, a streamer, along with many other cool stuffs.  It seems that it does not compile with OpenGL.  Could also be something of OpenGL is missing on my machine.  I did not dig into it.  It was not recommended to build with OpenGL anyways, for performance risks, as it said in README.

dss, this is an interesting one.  It does not compile.  Something are apparently missing in header files, conditional compiled linux defs, head inclusion path in makefiles, head includes are even spelt wrong (in upper / lower cases).  It does not even have a readme file to tell you how to compile.  Try at your own risk :) .   Tired and frustrated, at 2 am in the morning, I found a patch file by chance, http://freebsd.ntu.edu.tw/FreeBSD/ports/local-distfiles/nork/dss-6.0.3.patch . No description or anything.  I figure it wont hurt to give a try.  Turned out it was one of the few right things I did in my life.  It took me 2+ hours to bust a quarter of all the problems, but 1.5 seconds to resolved the rest with this patch.  And then the build and install went on a smooth sail.

By now I think the re-setup of my Linux box, upgraded with Ubuntu 8.04 Hardy Heron is pretty done.  It is a pretty distro.  When I plugged my cell phone, a mass storage device was automatically mounted.  

Sunday, August 24, 2008

GRUB Loading, Error 15

Loading Ubuntu is a labor job. Then starting with it, I get this on the boot up screen

GRUB Loading Stage1.5

Grub Loading, please wait...
Error 15

I don't remember when was last time I did not hit a wall the first step out of the door. Anyhow, standard procedure is googling with this error. So I did. Unlike most of the other times, did not find something that was close enough. So I played with it myself, and found something. The root cause was as dumb as it could be, the /boot partition did not have bootable flag set.

I have a total of 4 HDDs in the system, 2 previously loaded with fc6, 2 were from my Sony Vaio. While loading Ubuntu, I did not want to lose any data, so I loaded onto a hw that only had fc6 boot partition. That was a 40GB HDD. I loaded the whole Ubuntu 8.04 system on this single HDD. For some reason, bootable flag was not set, or perhaps was not set correctly. I found 2 other partitions were set with this flag, but not the actualy boot. Changing the flag fixed problem.

Today, a year after I posted the above, I was reading something regarding GRUB, where it mentioned that GRUB stage 1.5 is to load a program that understands file systems, ext2, ext3, or rfs. It is located in the first 30 kilobytes of hard disk immediately following the MBR. So guess my original problem was that this program was loaded, but when it tried to parse the boot flag marked partition, which did NOT have GRUB stage 2 to be found and loaded, it hung.

Grub error 17, cannot mount selected partition

I was not done with grub yet.  After grub loaded, it shows all the bootable options, all 4 of them, Ubuntu 8.04, Ubuntu 8.04 (recovery), memory test, and XP (the HDDs from Vaio).  That was nice to see things going fine, until it came to me the another error after hit the first boot option.

Grub error 17

Cannot mount selected partition

It apparently was trying to start Linux OS.  But I did not have guesses better than this.  Google proved to be my friend this time.  Here is a link to some very nice info.

http://ubuntuforums.org/showthread.php?t=442945#9

Briefly, there is misunderstanding between what hd[0 - 3] are on my system, between Ubuntu and BIOS.  The HDD, that has both boot and root on it, was considered hd0 by BIOS, but Ubuntu's guess was hd3.  So when Ubuntu wrote up the menu.lst for grub to find os image, it put hd3.  Modifying menu.list so thta it points to hd0 fixed problem.

Now I am awaiting for the next blocker.

Overtuure - Never ending problems

Been an engineer for so many year, I am led to believe that we are here not just to fix problems, but to also create problems (so that we can then fix).  If there is a quiet period of time when there is no problems to tackle, it itches. 

Lately I killed my Sony Vaio (that I never quite understood how I did it), so bad that, I think the motherboard is gone.  Buying a new 24" iMac as the consequence of it made this rather a celebrative accident than sorrowful, but the engineer part of me took out the 2 hard drives from Vaio and put in my OTHER box, which is a fc6 Linux.  I had a PCI raid card in it from a coupla years ago, so I can have up to a total of 6 (P)ATA HDDs.  Well, now I have 4.  The fc6 finds the PCI card, but NOT the 2 foreign HDDs.  FC6 is kind of old, and every customization I ever tried to have, I had change a lot of things, and many times rebuild the kernel.  So finally I got fed up with it, and decided to load Ubuntu (better forum support) 8.04.  

OK, this is gonna make me busy for the next few months, I am pretty sure.  Since I did that two sleepless nights ago, I have already experienced quite a few problems.  I never used to do this, but age finally put me to where, I believe some documentation might save time.  Now I got myself a fresh start (newly loaded Ubuntu, well, sort of), I will log the problems I experience.