Friday, May 29, 2009

Simple DVD Authoring with videotrans

I used videotrans (Debian package from to author a few DVDs. I'm aware of more versatile packages, but this was the right tool for the job, with almost no learning curve.

Here are simple recipes for creating two types of DVDs:
  1. a single video clip/movie, without a launch menu (the video is played as soon as the disk is inserted to the DVD player):
    movie-to-dvd -m pal -M /path/to/video.mp4
    dvdauthor -t -o /path/to/dvd_directory /path/to/video.vob
    dvdauthor -T -o /path/to/dvd_directory
    mkisofs -dvd-video -udf -volid "SINGLE CLIP" -o /path/to/video.iso /path/to/dvd_directory
    growisofs -dvd-compat -Z /dev/scd0=/path/to/video.iso # /dev/scd0 is the path to my DVD rewriter
    (replace blue and red stuff with your own stuff)
  2. several video clips, with a simple menu showing thumbnails for each video clip, and a background image:
    movie-to-dvd -m pal /path/to/video1.mp4 /path/to/video2.mp4 ...
    movie-make-title-simple -o title -m pal -i /path/to/background-image.jpg -s -b ffffff # background color
    movie-title -o title.vob -t title /path/to/video1.m2v /path/to/video2.m2v ...
    mkisofs -dvd-video -udf -volid "MULTIPLE CLIPS" -o /path/to/video.iso /path/to/dvd_directory
    growisofs -dvd-compat -Z /dev/scd0=/path/to/video.iso

Friday, May 22, 2009

Missinig Disk Space

Lately I started worrying about disk space on my external USB disk, that I use for backups. The output of df -h /dev/sda1 clearly shows that I'm getting low on disk space, but it's not too bad:

Filesystem Size Used Avail Use% Mounted on
/dev/sda1 230G 194G 25G 89% /mnt/elements

But there's something weird going on here - can you spot the problem?

It took me quite a while to notice - I've never done the math, and just assumed that Size=Used+Avail. But (surprise!) it doesn't add up.

I checked the disk for bad blocks, after un-mounting it, like this:
e2fsck -f -v -c -C 0 /dev/sda1

This took a few hours to complete, but showed no problem with the disk. I launched gparted and carefully went over the disk properties, in search for a clue. It insisted that I have more free space than that reported by df. This was reassuring, yet puzzling - where did that precious disk space go?

A quick search later and I found both the cause of the problem and its solution. It turns out that some disk space is always reserved for the OS. The default is 5% - quite a bit if you ask me. I verified that with
dumpe2fs /dev/sda1
and then modified it to 1%, like this:
tune2fs -m 1 /dev/sda1

After that df reports that I gained around 9GB:

Filesystem Size Used Avail Use% Mounted on
/dev/sda1 230G 194G 34G 86% /mnt/elements

One thing less to worry about!

Friday, May 15, 2009

Recursive Kill: Kill a Process Tree

As far as I know, killing a process should also kill its children - the signal is supposed to be propagated from the parent process to its children. But, sometimes this doesn't seem to work.

Here's a script that sends a SIGKILL (9) signal to all the processes with process ids provided as arguments, and to all their child processes, going from child processes up to their parents:


dokill() {
for cpid in $(ps -o pid= --ppid $1)
dokill $cpid
echo "killing: $(ps -p $1 -o cmd=)"
kill -9 $1 > /dev/null 2>&1

if [[ $# == 0 ]]; then
echo "usage: $(basename $0) <top pid to kill>"
exit 1

for pid in $*
dokill $pid

Recursion rules!

(credits: this is based on a script that I found at the newsgroup archive)

Friday, May 8, 2009

HTML Syntax Highlighting of Code Snippets

If you're after a utility for generating colorful syntax-highlighted HTML from code snippets, then I've got just the tool you need: GNU source-highlight by Lorenzo Bettini.

It supports more than 60 source languages, and several output formats. It's highlighting is quite well done, if not as accurate as that of Vim or emacs.

The feature which makes it very useful for this blog, is the fact that, by default, it generates plain HTML fragments, with no CSS. These HTML fragments can be pasted as is into a post that's being edited, while in HTML mode.

source-highlight can also be used as a syntax highlighted pager for the console like this:
source-highlight -o STDOUT -f esc /path/to/file 2>/dev/null | less -R

(you may want to take a look at my previous posts about syntax highlighting for paging and listing of source code at the console).

Friday, May 1, 2009

Running Debian on QEMU PowerPC

All I wanted was to setup a virtual PowerPC machine with Debian installed, so that I can verify that a certain piece of code works on a big-endian machine. It shouldn't be too difficult, right?


It's supposed to be just a matter of installing QEMU:
aptitude install qemu # as root

and then create a disk image, boot a PowerPC emulation system from a Debian PowerPC netinst CD image, and follow the installer instructions...
qemu-img create -f qcow2 debian-ppc.qcow2 10G
qemu-system-ppc -boot d -cdrom debian-testing-powerpc-netinst.iso debian-ppc.qcow2

This will only reward you with the following message
qemu: warning: could not load VGA bios '/usr/share/qemu/video.x'

and nothing else.

So much for theory.

It turns out that the Debian package is missing a binary file, on purpose (no source code). It's mentioned in /usr/share/doc/qemu/README.Debian - the file video.x can be found at the Mac On Linux (MOL) project site:
  1. download the current MOL source package
  2. extract it to some temporary directory
  3. as root copy video.x to /usr/share/qemu:
    cp mol- /usr/share/qemu/video.x
This time I managed to boot the virtual machine and start the installer. It looked fine, until, several hours later (my box is dead slow) the installer simply hanged while installing quik - I just hit Debian bug #513182, which, to put it simply, prevents Debian from being installed as a guest OS on a QEMU PowerPC emulated system.

Well, that's unless you know your way around PowerPC, Debian installer, quik and QEMU, like Aurélien Jarno. He maintains pre-installed QEMU disk images of Debian for several architectures, PowerPC included.

I downloaded the PowerPC disk image for Debian/Lenny, and started the PowerPC emulated system like this:
qemu-system-ppc -hdc debian_lenny_powerpc_small.qcow
works like a charm.

Now back to testing my code.

I found out that if I use the QEMU -vnc command line option, in order to setup QEMU as a VNC server, then QEMU (version 0.10.2) crashes if I try to connect to it with a VNC client using low color levels (I used the RealVNC viewer command line option -LowColourLevel 2). It works fine, with some hiccups when changing display modes, if I don't specify any VNC viewer connection options.

[15 Dec. 2009] UPDATE: with QEMU version 0.11.0 the command line has changed (read: has been fixed) and should be:
qemu-system-ppc debian_lenny_powerpc_small.qcow
(no need for the -hdc command line option - the disk image comes up as disk hda).