Creating a MPEG2 file with mencoder

Note to self: This is a reminder and follow up on the previous post of how I managed to reencode an AVC1/AC3 video in a Matroska container to a DVD-ready MPEG2 file with the original AC3 sound in a MPEG container (VOB), just like DVD authoring tools like their files (no sign of players supporting h.264 where I live yet, else…).

mencoder the_darned_movie.mkv -sub subtitles_spa.srt -utf8 -subfont-text-scale 3.3 -subpos 96 -oac copy -ovc lavc -lavcopts vcodec=mpeg2video:vbitrate=5000:mbd=2:trell=yes:gmc=yes:aspect=1.83/1:vpass=1 -of mpeg -mpegopts format=dvd:muxrate=24000:tsaf=yes:interleaving2=yes:vframerate=25 -noskip -o /dev/null

and then the actual encoding (make sure to copy the log file from the first pass somewhere safe just in case):

mencoder the_darned_movie.mkv -sub subtitles_spa.srt -utf8 -subfont-text-scale 3.3 -subpos 96 -oac copy -ovc lavc -lavcopts vcodec=mpeg2video:vbitrate=5000:mbd=2:trell=yes:gmc=yes:aspect=1.83/1:vpass=2 -of mpeg -mpegopts format=dvd:muxrate=24000:tsaf=yes:interleaving2=yes:vframerate=25 -noskip -o the_darned_movie.mpg

I made a couple of fix ups, such as converting the srt file to UTF-8, with gaupol. As well, lavf output doesn’t support VOB output as it was my first idea and to make things worse, it is broken as per program output (MPlayer SVN-r31918 a.k.a MPlayer 1.0.rc4). But, the MPEG muxer supports VOB, yay!

Creating a MPEG4 with subtitles using mencoder

Note to self: This is a reminder of how I managed to reencode an AVC1/AC3 video in a Matroska container to a low-profile MPEG-4 (aka “XViD” or “DivX”) video with the original AC3 sound in an AVI container, just like modern video players like their files (no sign of players supporting h.264 where I live yet).

mencoder the_darned_movie.mkv -sub subtitles.srt -utf8 -subfont-text-scale 3.3 -subpos 96 -aspect 2 -oac copy -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell=yes:v4mv=yes:aspect=16/9:vbitrate=1200:vpass=1 -o /dev/null

and then the actual encoding (make sure to copy the log file from the first pass somewhere safe just in case):

mencoder the_darned_movie.mkv -sub subtitles.srt -utf8 -subfont-text-scale 3.3 -subpos 96 -aspect 2 -oac copy -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell=yes:v4mv=yes:vbitrate=1200:aspect=16/9:vpass=2 -o the_darned_movie.avi

I made a couple of fix ups, such as converting the srt file to UTF-8, with gaupol.

Hacking Debian’s Desktop Default

Changing the desktop default after installing Debian without giving it a second thought is a pain if one is not very familiar with debconf (a.k.a., the spawn from hell, second only to Solaris’ SMF oh, how I loath thee —until I get close to some iron with AIX inside anyways.) You love The Debian Way(tm), and you strive to always use it despite all odds. And what odds! There is no easy and obvious way to change the default desktop in a Debian system[1], just the following:

echo "tasksel tasksel/desktop string xfce" | debconf-set-selections

[1] Yes, I’m bitching too much, but how do you expect a luser to do this without suffering a heart attack? Wait I use Debian, not Ubuntu. Thank you $DEITY!

Installing and dual-booting Debian GNU/kFreeBSD

Now that Debian GNU/kFreeBSD is an official part of Debian, it is time to play around with the new toy. But in order to do such feat there are several issues that have to be resolved on the path to success. Assuming you use Debian GNU/Linux with GRUB2 (as seen in testing and unstable these days) and have a spare partition or two you can try it out on live hardware instead of an emulator.

Installing Debian GNU/kFreeBSD

  1. Use the Debian-Installer (D-I) monolithic images available at http://d-i.debian.org/daily-images/, and make a network install.
  2. The installer image uses GRUB2 instead of syslinux (for obvious reasons), thus you cannot set debconf priority before booting into D-I.
  3. Because Debian GNU/kFreeBSD is broken in testing as of this writing, you’ll need necessarily to set debconf priority to medium in D-I in order to install unstable a.k.a. Sid.
  4. Setting debconf priority is easy. The first installer prompt will ask for the language you want to use for installation. Don’t select a language, instead tab to the “Go Back” button, exit to D-I’s main menu, set debconf priority to medium and start again from the top.
  5. When selecting a mirror, select unstable as the distribution to install.
  6. When partitioning, you may create or use an already existing primary or logical partition, but the FreeBSD kernel will be happier if you use a primary partition.
  7. Do not, I repeat, do not install software. Skip this step. Aptitude is foobar today and perhaps for sometime yet. Read the report to learn how a bug report is written. Use apt-get by hand instead.
  8. Finish the install without installing GRUB2, The package in Sid is somewhat broken (or bug fixed, whichever you choose to believe) and refuses to install on UFS filesystems and will insist on installing on the MBR. Skip it. We will be using the GUB2 installed in the MBR by our Debian GNU/Linux install.

Dual booting Debian GNU/kFreeBSD

This is where all the advice on creating a boot entry for GRUB2 out there in the intarwebs is wrong. Why? Because kFreeBSD has been repackaged to match the packaging of Linux. So in order to boot Debian GNU/kFreeBSD from our main GRUB2 install, we need to add the following to /etc/grub.d/40_custom:

menuentry "Debian GNU/kFreeBSD" {
    insmod ufs2
    set root=(hd0,3)
    kfreebsd /boot/kfreebsd-8-0-1-686.gz
    #kfreebsd_module_elf /lib/modules/8.0-1-686/acpi.ko #not necessary, statically linked
    set kFreeBSD.vfs.root.mountfrom=ufs:/dev/ad0s3
    set kFreeBSD.vfs.root.mountfrom.options=rw

}

And run update-grub. Obviously that’s the set up in my box and it won’t work as is in yours. If you can’t find that information on your own, oh well.

Evolution, Google Calendar and CalDAV

I dunno what’s wrong with GNOME Evolution’s native Google Calendar support, but for me it hasn’t been nothing but a disappointment. A while ago during an speleological expedition in Google’s Help site, I found how to use CalDAV instead of the Google connector. In order to access the main calendar one uses the address:

caldav://www.google.com/calendar/dav/LUSER@gmail.com/events

Unfortunately this doesn’t give access to other calendars one may have in the account. If using Apple’s iCal or Mozilla’s Sunbird/Lightning, or whatever name their calendar has these days, you can use the address:

caldav://www.google.com/calendar/dav/LUSER@gmail.com/user

to retrieve a list of calendars, pick and choose.

Wine and µTorrent can rot an Ext3 filesystem

Note to self: All bittorrent clients are horrid. Some have a bearable stench, others haven’t. And for some reason these days I find all POSIXy clients despicable.

Thus enter µTorrent running under wine. And I start getting these weird filesystem errors that could eventually eat the whole filesystem where there are some really rare and valuable files. I started poking at the problem and discovered that µTorrent has its own disk-cache manager that, of course, enters in conflict with the Linux one. There you have a testament to the design flaws of the Windows NT VM and the NTFS filesystem; you  have to implement your own disk-cache manager if you want something that works. Fortunately you can turn it off.

So I’ve settled on this configuration:

  • Linux: 2.6.30 (yeah, a release candidate for now), makes Ext filesystems work in writeback journaling mode with write safety.
  • Filesystem: Ext3 with write barriers enabled to cover your backside against hardware write cache idiocy.
  • wine: A very recent vintage
  • µTorrent: The latest with all disk cache settings disabled.

How to fix the new MS fonts in POSIXy systems

OK, you’ve got your new computer preinstalled with MS Vista and/or MS Office 2007. You didn’t waste time to install your favorite GNU/Linux distribution or BSD flavor and took the time to comb down that Windows partition for goodies the license and Title 17 of the US Copyright law may warrant you to use. That is, unless George of the Bush hasn’t killed it already with the help of his friends in the US Congress, each and every one of whom make Sarah Palin look like a Nobel Prize Winner, ten years in a row.

You find those nice fonts with names starting with “C”, Calibri, Cambria, Candara, Consolas, Constantia and Corbel. Diligently you copy them into your $HOME/.fonts directory and run the magic command fc-cache -r -v in a terminal emulator window, go to the font settings application for your preferred desktop environment and change the monospaced font to Consolas (new font from MS, several years in development, it has to be the ultimate coding font, right?). Open a new terminal or a text editor and you discover it is hideous! Blocky, blurry and bold although you made a point of not using bold in the settings, Something you learned the hard way after having written The Great American Novel, a thousand pages worth, printed it in Comic Sans Bold 10 points to save paper and sent it to your prospective editor, who answered back thanking you heartily for all the toilet paper supplies you sent along the other day.

The problem is that the MS “C” fonts are hinted in such way that they don’t work well if you don’t use subpixel rendering and as far as I can see there is no real traditional hinting in them worth a cent. Even after you fiddle with the LCD-type settings there is no improvement, because most GNU/Linux distros default to use the patented bytecode interpreter, which works just fine with traditional truetype hints, instead of the patent unencumbered autohinter (in typical “Bite me!” attitude). Even those distros that give you the choice to use one or the other, such as Debian, have for the most part managed to bastardize the code resulting in Freetype working as it shouldn’t. And all downstream distributions, including Ubuntu, receive the same turd.

But don’t fret! There are ways to work around the ugliness. We can create a $HOME/.fonts.conf like this:


<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<!-- Use the Autohinter -->
  <match target="font">
    <test name="family">
        <string>Calibri</string>
        <string>Cambria</string>
        <string>Cambria Math</string>
        <string>Candara</string>
        ;<string>Consolas</string>
        <string>Constantia</string>
        <string>Corbel</string>
     </test>
        <edit name="autohint" mode="assign"><bool>true</bool></edit>
  </match>
</fontconfig>

That ought to fix the ugliness, although results will vary depending on how bastardized is the Freetype library in your system. Of course you can add more configurations to the file as long as you respect the XML syntax. Do be careful if using KDE(3/4) because the KDE font configuration tools love to eat users .fonts.conf files raw and spit them out in pieces.