Friday, February 27, 2009

I may write a MythTV Plasmoid

Instead of running MythWelcome, I think it would be really cool to have a MythTV plasmoid on my KDE-4.2 desktop that fills the same role. I'm surprised no one has written one yet. There is a MythTV dataengine in SVN, but nothing's been done with it AFAICT.

The Plasmoid would show basically what you see in MythWelcome: Current activity ("recording Program X", "gathering EPG data", "flagging commercials", "idle", etc), and the next scheduled recording. In addition, I might show the date of the last successful mythfilldatabase. Finally, there would be buttons to start/override the idle shutdown timer, launch the frontend, start/stop the backend, and run mythfilldatabase.

On a mostly-unrelated note, I need to figure out why mythfilldatabase is not running automatically. I noticed this morning that it hadn't run in 12 days! It's supposed to run daily.

Sunday, February 22, 2009

Tweaking MythTV settings


  • MythBuntu's MythTV did not set the bookmark when exiting playback by default, so if I returned to a program, it would always start at the beginning. Fixed the setting in the frontend setup, Playback, page 2: On exit (change from "Just Exit" to "Save position and exit").

  • De-interlacing: displaying an interlaced signal on a progressive-scan display creates really distracting horizontal artifacts in scenes with a lot of motion. To fix this, I went to the Utilities/Setup menu in the frontend, under Setup, TV Settings, Playback. Then go to Page 3.

    There you will see a combobox labeled Current Video Playback Profile; set it to Normal (it was "CPU+" by default on my machine). The Normal profile includes reasonable de-interlacing algorithms which work fine for me. You can also hand-edit any of the profiles, including at least half a dozen different de-interlacing options. Ah, Linux!

Friday, February 20, 2009

Adding metadata to orphaned video files

I have a bunch of videos that no longer exist in my mythtv DB, and so I don't have title/series information for these files. I want to find a way to add metadata to these files easily.


This looks pretty interesting.


Well, I gave up looking. I'm just renaming my video files manually now, which is pretty cumbersome, but not too bad.

Linkstation Redux

When I switched from Knoppmyth to Mythbuntu, one of the casualties was that my awesome Linkstation NAS stopped working. Specifically, mythbuntu wouldn't mount it. After some googling and experimenting, I arrived at a solution. On Ubuntu, you have to use the "Samba" format for specifying the server name. i.e., instead of 192.168.1.127:/share, you have to use //192.168.1.127/share. Note that this doesn't imply that you use smbfs for the filesystem type; it's still cifs. I don't claim to understand these things, dear reader...


So, now a command like this mounts my NAS:

mount -t cifs -o user=admin //192.168.1.127/share /mnt/netdisk


And the /etc/fstab to auto-mount the disk on boot looks like:
//192.168.1.127/share /mnt/netdisk cifs user=admin,rw,defaults 0 0


The big mystery in this change is that specifying credentials=/root/.creds instead of user=admin doesn't work! So why is my Linkstation mounting without a password? Who knows. Luckily, I don't care that much (sorry crypto-geeks!)

Installing KDE-4.2 on Mythbuntu

I'm new to the whole *buntu scene, having recently abandoned planet Gentoo. So I'm not hip to all the package management tools yet.


The command-line tool I've been using to install packages is aptitude. I'm comfortable with its operational similarity to Gentoo's emerge, but I haven't learned all the ins and outs yet.


Anyway, I want to get KDE-4.2 going on my mythbox, so (with full realization of the futility of such naive ambition), I simply executed the command aptitude install -t experimental kde. And...it worked!


Ha, only kidding. Well, it did work, but it installed KDE-4.1. So I started looking around for instructions on how to get the New Hotness, and found this page. The most useful info there is (a) how to add a third-party repo, including GPG keys; and (b), that I should install "kubuntu-desktop" instead of "kde".


My first attempt to install the 4.2 packages failed due to conflicts with the 4.1 packages that I didn't mean to install. So, I next did sudo aptitude remove kde to wipe the 4.1 KDE packages off my disk, and then I did sudo aptitude install kubuntu-desktop. I'm unclear on the operational difference between kde and kubuntu-desktop as a metapackage name, but I suspect kubuntu-desktop pulls in non-KDE things like Open Office.


Anyway, things seemed to go fine installing kubuntu-desktop...until I tried to use it. First of all, aptitude had asked me if I want to use KDM as my login manager instead of gdm, and I said yes. But when I logged out of my XFCE session and restarted X (Ctrl+Alt+Backspace!), I was presented with gdm, not kdm. Worse, KDE was not present in the Sessions menu!


So, to fix this I simply repeated the installation command: sudo aptitude install kubuntu-desktop, hoping that it would find a couple of errors. To my amazement, it told me that over 100 packages needed to be installed! Whoa, that first install didn't go too well, yet it didn't complain. After that process finished, I repeated it again because this time I did notice that about seven packages had errors. After the third iteration of the installation command, it finally reported no errors. This was on a system that was ostensibly clean of any KDE packages.


Ok, all KDE packages are now installed. No errors reported. Log out, restart X...and we get KDM! Awesome, full steam ahead, right? Ah, sweet naive optimism...


Logging in, I get the gorgeous KDE 4.2 desktop. But when I try to open an application, I discover that there is no window manager running (i.e., the application window has no frame, and it won't accept keyboard focus. The usual googling producs no solutions for this problem, so I jump onto #kubuntu on IRC where Slartibartfast points me to the solution:
the command sudo aptitude install kubuntu-desktop installs all of the KDE-related packages, and there are well over 100 of these. It does NOT, however, install the library libkdecorations.so, on which kwin is critically dependent. This is the kind of bug that really should have been caught by the packagers, and I'm sure it will be fixed soon. For now, if you install KDE-4.2 on *buntu, make sure you also do sudo aptitude install libkdecorations.


After that last hoop-jump, I was at last released into the beautiful garden that is a fully functional KDE-4.2 desktop. It's very nice, but there's still some plasma fragility (e.g., I don't recommend attempting to increase the height of the panel!). What's he lesson in all of this? We have some incredibly cool Free Software available these days, and I am truly grateful to all of those who contribute their time to not only develop these programs, but to attempt to package them into an easy, user friendly system. We've made great strides on usability, but it seems we are not quite there, because I keep hitting these walls that require quite a bit of hackery to get around. Now, I will admit that I am usually trying to "push the envelope" when I hit these walls, so if I simply accepted what the packagers gave me by default, I wouldn't have half of my problems (i.e., if I had accepted KDE-4.1 instead of demanding the latest-and-greatest). Anyway, kudos to the KDE developers and the Kubuntu packagers alike.

Wednesday, February 18, 2009

Mythbuntu: Awesomeness and Annoyances

I recently switched distros on my Mythbox from Knoppmyth to Mythbuntu, because I couldn't get my new wireless keyboard/mouse combo to work under Knoppmyth. I'm generally quite pleased with Mythbuntu, and find it to be much more polished than Knoppmyth. There are some weirdnesses, though. This post collects some of my experiences in setting up my Mythbuntu box. Note that not all of these are directly related to Mythbuntu.

Transferring my LVM disk



My mythbox uses LVM to glob three separate partitions into one 600 GB monster mounted as /myth, which holds all of my recordings and other media. It's an ugly solution, but it works for now. The problem is, you can't simply reinstall Linux and hope that an LVM partition will "just work" like a normal partition would. Fortunately, it's pretty straightforward to do the transfer (the following instructions assume the LVM partition is named "vg", and that it is mounted at /myth):


  • Backup all of the data in the LVM partition!
  • Prior to reinstalling the system!, unmount the /myth partition, and "deactivate" the LVM partition by typing vgchange -an vg.
  • "Export" the LVM partition by typing vgexport vg. This allows the new linux system to recognize that the physical partitions are part of a LVM group.
  • Install your new linux system
  • Verify that the partitions are recognized as part of an LVM group with the command pvscan. You should see your partitions listed as "inactive" and "part of EXPORTED VG 'vg'". Note the partition names listed (e.g., /dev/sda1).
  • "Import" the LVM partition using the command vgimport vg /dev/sda1 ... (where instead of /dev/sda1 ..., you put a space-separated list of the partitions).
  • "Activate the LVM partition: vgchange -ay vg.
  • Mount the partition: mkdir /myth; mount /dev/vg /myth and verify that your data are intact.
  • Add a line to your fstab so that the partition will auto-mount in the future.



No TV signal



This problem actually also happened on KnoppMyth, right after I hooked up my Comcast Digital STB via Firewire. The STB was automatically detected by mythtv-setup, but when I set the starting channel to "2", I got no signal when watching TV. Same story after switching to Mythbuntu. In both cases, I modified the starting channel to "9" (our local PBS station), and then it "just worked". Channel 2 is a valid channel that I can tune now with no problem. *shrug*


Sound stopped working



Sound worked out-of-the-box at first, but then it inexplicably stopped after a few days. I eventually ran alsamixer and saw that the problem was that the master channel had been muted somehow. I have no idea how that happened, but it's pretty annoying; what if I was a new Linux user who didn't know about alsamixer and didn't care to find out about it? Wouldn't it be nice if sound didn't spontaneously mute itself and require a command-line tool to fix it?


Auto-shutdown from MythWelcome didn't work



With system idling in MythWelcome, the shutdown timer would count down to zero, and then reset to 300 sec, rather than shutting down the system. By starting mythwelcome from an xterm on the desktop, I was able to figure out the problem from the console output: sudo was asking for the mythtv user's password. This was resolved by adding the mythtv user to the "sudo" group with sudo usermod -G sudo mythtv, and changing the /etc/sudoers file so that it wouldn't prompt for a password. Worked like a charm after that (but wouldn't it be nice if it worked this way out of the box?)


mythtv user can't access the MySQL database



I never figured out why, but mysql does not allow access by the mythtv user. I changed my setup so that my "normal" user does the access instead. It would definitely be nice if I didn't have to muck about with the database like this (although, to be fair, this may have happened because I imported my DB from my previous KnoppMyth installation...)


MythTV doesn't auto-start by default



This is easily solved in the nice Mythbuntu Myth-config tool accessible from the desktop menu. However, one annoyance is that it auto-starts Mythfrontend rather than Mythwelcome, so auto-shutdown will not work. I had to go into the normal settings GUI, in the Autostart Programs tab, and add Mythwelcome (and remove Mythfrontend) from the list of autostart programs. The Myth-config tool did correctly set it up to auto-login my user rather than give a login screen.


HDMI connection to my TV leads to overscan issues




My TV is a 42-inch Panasonic LCD, and my mythbox is connected through an HDMI port, using a DVI-to-HDMI converter I bought at Target. When using my mythbox, it quickly became apparent that the computer display was extending beyond the visible area of my screen, such that I was missing 10-20 pixels along each edge. After much research with the google, I learned that this problem is known as overscan. Basically, TVs routinely crop the displayed image this way. There is a general solution, but it is incredibly obscure: you have to craft a custom "modeline" for your xorg.conf file, which apparently involves understanding not only scan timings and pixel clocks, but also something called the front porch and back porch. This is one of those times that makes me go, "You know what? I don't care what the front porch is, I just want to see all of the pixels on my screen! Why does it havbe to be so difficult?". Then I found out about a tool called xvidtune, which allows you to modify the screen size and position and then spits out the corresponding modeline. Sweet, right? Unfortunately, when I tried to run it, I got an obscure error message (like, "Could not query monitor parameters"), and googling the error didn't yield any leads.


I was about to give up, and just accept that I wasn't going to see the edges of my screen, when I decided to do the unthinkable. I opened the User Manual for my TV. Amazingly, I found an obscure menu option in there called something like "HDMI scaling". Even more amazingly, activating this option did exactly what I was hoping for! The screen is reformatted such that I can now see all the way to each edge. And it isn't done with resampling that destroys image clarity. Sweet.

Update: MythTV Wakeup with kernel >= 2.6.22

In this post, I discussed how to get MythTV to automatically wakeup when it needed to record something, and shutdown when it had finished.


Since writing that post, I switched my setup from KnoppMyth to Mythbuntu, because my wireless keyboard/mouse combo didn't work under Knoppmyth. Anyway, it turns out that the auto-wakeup procedure is a bit different than I described if you are using a linux kernel version 2.6.22 or newer.


The basic differences are that the ACPI timestamp must be placed into /sys/class/rtc/rtc0/wakealarm, instead of /proc/acpi/alarm, and that the timestamp must be expressed in "UNIX time" (i.e., the number of seconds elapsed since 1970/01/01 00:00:00), rather than a "yyyy-MM-dd hh:mm" formatted string. Also, the wakealarm file must first be "flushed" to a value of zero prior to setting the wakeup time. For a detailed discussion of this, see the MythTV Wiki.


You can still follow my previous guide, with the following corrections:


  • In mythwelcome --setup, change Wakeup time format to time_t. Do not change the time format in mythtv-setup! I did that at first...seemed logical, does not work.
  • In mythwelcome --setup, change the Command to Set Wakeup Time to sudo /usr/local/bin/setwakeup.sh
  • Create the file sudo /usr/local/bin/setwakeup.sh. Make it look like this:


    #!/bin/sh
    # $1 is the time, in seconds since 1970/01/01 00:00:00.
    # (a.k.a. the "time_t" format)

    sudo sh -c "echo 0 > /sys/class/rtc/rtc0/wakealarm" # clear the alarm
    sudo sh -c "echo $1 > /sys/class/rtc/rtc0/wakealarm" # write new alarm



That should do it. Don't forget to chmod +x /usr/local/bin/setwakeup.sh.