Friday, April 30, 2010

Busted Laptop

My 8 year old laptop's LCD backlight is busted - it just suddenly turned off on Monday morning. It stays off during a reboot. If I shut down the box and turn it on again, the backlight does turn on, but after a short (and random) period of time it turns off again.

I'm pretty sure that it's the backlight that's busted because, under the right lighting conditions, I can still see the stuff displayed on the screen, but it's very faint.

I've tried to manually control the screen power saving mode by blindly typing
vbetool dpms on
at the console, but this has no visible effect.

The box is otherwise just fine, and it still functions as a backup server, web server, firewall, printer server etc. It's just that I can't use it as a desktop.

What a bummer.

I'm still considering my options. I've been thinking of getting a new laptop for my wife for quite a while, since the (extended) warranty on her current, 4 year old, laptop expired, and she does need a lighter machine (2.7kg is pretty heavy...). But a new laptop would cost more than fixing my box.

Decisions, decisions.

To be continued.

Friday, April 23, 2010

Concatenating AVI Files with MEncoder

Suppose you have a bunch of AVI files, named part_01.avi, part_02.avi, etc. Suppose, furthermore, that you want to concatenate them into a single AVI file named concatenated.avi. Here's how to do it with MEncoder:
mencoder part_*.avi -o concatenated.avi -ovc copy -oac copy
This should work nicely as long as all parts have been encoded with the same video and audio encoders, using similar encoding parameters.

Now, suppose that you've downloaded a bunch of MP4 video files from, say, youtube.com using a command line tool like get-flash-videos (highly recommended!), and you want to concatenate them into a single AVI file. But some of these files have different encoding parameters than the rest, so we need to re-encode the files such that their parameters match:
ls -1 part_*.mp4 | \
while read f ; do \
 mencoder $f -o ${f/.mp4/.avi} -oac mp3lame -lameopts mode=2:cbr:br=128 \
 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=1200 \
   -vf scale=720:480 -af volnorm=1 -ffourcc XVID -ofps 29.917; \
done
where the parameters can be determined by examining the console output of MPlayer during playback of each file and selecting the parameters that match most files, in order to reduce quality loss as much as possible (you may find this script helpful).

Re-encoding is a time consuming process, so unless you absolutely need these files concatenated (e.g. for playback using your DivX DVD player), you may just want to playback the files in order...
mplayer -fs part_*.mp4

Friday, April 9, 2010

Installing Perl Modules on Debian

Disclaimer: I know next to nothing about Perl - I'd appreciate any comments.

Many CPAN hosted Perl modules are already packaged in Debian, so all one needs to do is the following:
  1. install dh-make-perl:
    aptitude install dh-make-perl
  2. find the Debian package that contains the wanted Perl module:
    dh-make-perl locate Chocolate::Belgian
  3. if the module has a matching Debian package, you should install it the usual way:
    aptitude install libchocolate-belgian-perl
  4. otherwise, you have two options - read on
One option is to to do it the Perl way, i.e. install the package using the CPAN core module:
perl -MCPAN -e 'install Chocolate::Belgian'
Another approach is to use dh-make-perl to automatically Debianize the module, and then install the resulting .deb package, like this:
cd /tmp
dh-make-perl make --build --cpan Chocolate::Belgian # or: cpan2deb Chocolate::Belgian
dpkg -i libchocolate-belgian-perl_0.01-1_all.deb
You may run into errors due to missing Perl modules that the original missing module depends on. If this happens, you'll need to repeat the installation process for each missing module (again, either from an existing Debian package or using dh-make-perl).

I suppose the latter method makes sense if, like me, you only need a small number of non-Debianized Perl modules installed - I like being able to manage these modules with the usual Debian tools such as aptitude, instead of having to learn to effectively use yet another package maintenance tool.