Friday, July 6, 2007

The Control Problem

Major stuck point here. If I use the picoLCD's usblcd utility program, I can see that the keypresses and IR signals are heard by the hardware. By examining the LCDd.conf file, I can see that lcdproc does have the ability to read keypresses. (Looking at the source code for the picoLCD driver for lcdproc, it only supports keypresses at the moment, not IR signals.) But for whatever reason, the keypresses are not getting through mythlcdserver to MythTV.

I'm not entirely sure who's to blame, but at the moment I'm suspecting the problem is with mythlcdserver attempting to bind to key events 'A', 'B', 'C', 'D', 'E', and 'F' where lcdproc (with the picoLCD driver) reports key events of 'Plus', 'Minus', 'F1', 'F2', 'F3', 'F4', 'F5', 'Left', 'Right', 'Up', 'Down', and 'Enter'. mythlcdserver also seems rather intent on using single-character keys only. I think I'll see what I can do about that.

If I'm right, then there may be an issue with trying to map LCD keys to MythTV commands. I really don't want the F1 key on the keypad to bring up Help. But one step at a time...

Monday, July 2, 2007

The Bling

The Mini-Box M300-LCD, as its name would imply, has an LCD module on its front -- specifically, a picoLCD module. The iMedia distribution already had the required drivers, but the KnoppMyth distribution did not. I installed the lcd4linux package through aptitude, but it did not have the picoLCD driver. I did download the source and was able to compile it with the picoLCD driver, and it worked great.

Of course, when I researched how to get MythTV to talk to it, I found that it already has a convenient application, mythlcdserver, to make good use of the display. And, it didn't work with lcd4linux, but lcdproc. I was avoiding using lcdproc, because the first hits I found searching for lcdproc and picoLCD indicated I would have to get the source code and patch it to use the picoLCD. The lcdproc hardware page had no sign of picoLCD. However, when I found the project page on freshmeat.net, the picoLCD driver was recently included. (Indeed, the lcdproc.org home page also has picoLCD in the text description of the most recent release; but I had missed that.)

I compiled and installed the LCDp daemon (which, for some reason, installs its configuration files to /usr/local/etc instead of /etc). With the curses driver active, I started the LCDp daemon, then tried running mythlcdserver. And nothing happened. I tried googling, but I couldn't find anyone else with this problem. Heck with it, I figured I'd reboot.

Interesting thing about LCDp. If the curses driver is active, then running it starts the server and locks the display, and apparently it doesn't daemonize. This is a problem when you have it running from init.d -- the boot process gets to that step, starts the curses display, and goes no farther. Unfortunately, I started it pretty early in the process (lcd4linux put its startup scripts at S20, so I mimicked this with my LCDp scripts), and sshd had not started yet. Oops. Curses, indeed. I went upstairs (since the MythTV box is now at home in the entertainment center) and grabbed a keyboard and that bootable USB key, booted, mounted the hard drive, edited the config file to use the picoLCD driver instead of the curses driver, and rebooted.

Since I had the keyboard attached at this point, instead of trying to run mythlcdserver from a command line, I went through MythTV's setup menu and enabled LCD there. And it worked just fine.

So now, MythTV talks to the picoLCD just fine. The next major steps are to get it to go the other way -- for the picoLCD to relate its keypresses, and hopefully the IR receiver, back to MythTV. Google hasn't helped so far...

Friday, June 29, 2007

The Contest, Part 2

One thing I should've noticed in reading that Ubuntu Forum post, as well as the comments in the configuration file, is that noise reduction slows things down. I'm now running both transcodings with noise reduction (and de-interlacing) off, single-pass, quality level 6 (the default). Let's try this again.

Xvid: 2:25:18, 116MB
DivX: 1:47:44, 145MB

Good thing; any bigger, and I would've been out of space:

Filesystem   1K-blocks      Used Available Use% Mounted on
/dev/sda1      4925528   4672876      2444 100% /

Guess I should've been doing this on my data drive. Oops.

Finally, we are within the realm of possibility. But how, ultimately, is the quality? Well, the answer was pretty clear. XviD was pretty bad, very blocky, in both the two-pass version (which I set at a pretty unfair low quality, I admit) and at the Q6 one-pass version. DIVX was very watchable (on the 14" monitor; hopefully it does as well when it's hooked up to the 36" TV). Although, curiously, Media Player Classic on the XP workstation refused to play the 2-pass XviD and the no-noise-reduction DIVX files. Since they will be played on the MythTV box almost exclusively, I'm not too worried.

By the way, here's a fun fact I discovered while moving files around from machine to machine. scp over my 100Mbps home network transfers up to 10MBps, transferring the 2.2GB source file in 3½ minutes. For some reason, I could not get PSCP (PuTTY's SCP utility) to make the transfer to my Windows machine (curiously, even with the trailing slash, it treated the target directory as a filename and was unable to write), so I started with FileZilla, which can connect over SFTP. It estimated over 3 hours to transfer the file. I gave up on that and used PuTTY's SFTP client (PSFTP), which was able to complete the transfer in a "mere" one hour.

Wednesday, June 27, 2007

The Contest

The XviD compression completed in an estimated 12 hours, taking a one-hour episode of Star Trek Voyager (The Q and the Grey, if you're curious) from 2.2GB to 68MB.

To try and keep all things equal, the XviD preferences were copied to the DIVX section, and the same file was set up for transcoding (this time, running in a screen session, so it can be detached without losing the output this time).

Curiously, thie DIVX option ended up bombing the first time. Maybe it doesn't like running in screen. Alas. One more try before I call it quits...

Nope. Another 9-hour task down the drain.

ffmpeg had critical errors:
Error while opening codec for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height

Because I have other things to do, I might as well give the machine something to do while waiting for me. The Ubuntu forums have a suggestion on settings that I'll try using. In particular, the poster seems to prefer one-pass instead of two-pass encoding, which may help in this case, as the error seems to occur when setting up for pass 2.

And so it did. Divx completed in about 8 hours, with a final file size of 268MB. Not quite the space savings as XviD, but a fair increase in overall speed (well, sure, since it only made one pass).

Tuesday, June 26, 2007

The Web

Before I turned off the machine last, I checked out the MythWiki page on ACPI Wakeup and followed the configuration suggested there. Sure enough, the machine woke itself up to record the next scheduled show (although it missed a minute or two; I might have to figure out how to pull the time back a couple minutes to give it time to boot). Pretty cool, except I happened to notice that the "next scheduled mythfilldatabase time" was long since elapsed. Does MythTV not know enough to correct this when it sleeps through its appointed time? Hmm, what would happen if the next instance of a show was outside of the downloaded schedule; would MythTV ever wake up to do a mythfilldatabase? Might have to investigate this.

Anywho, I decided my next project would be to get the MythWeb interface working. I tried connecting to the PVR, but I got an authentication dialog. Annoyingly, it wouldn't accept any usernames or passwords -- not mythtv, root, or the user account I created on install. This would not be acceptable.

A little searching revealed that you can override the authentication of an Apache subdirectory by including Satisfy Any in the <Directory> element. Better, but I wanted it even simpler. I wanted to be able to just type the machine name into the browser and get it, without having to append /mythweb. After unsuccessful trials with Alias and Redirect, I noticed a commented-out line that was there to redirect / to /apache2-default/, "to have apache2's default start page in /apache2-default/, but still have / go to the right place". I un-commented that line, but changed /apache2-default/ to /mythweb/. I also removed authentication on / as well, to make things even simpler. (I hope that decision doesn't bite me in the butt someday.)

I am noticing that the files saved on the hard drive so far are rather large (1.1GB per half hour). For how little TV we watch, 25 hours should be plenty of recording time. But I don't think that's good enough. The next step is to follow this HOWTO from the Ubuntu forums: HOWTO: Auto transcode MYTHTV recorded shows to DVD, XVID, or DIVX cutting out the commercials. I'm first running a test of the XviD export, which I'll follow up with a DIVX run. However, I don't know how useful it will be. It's currently showing an ETA on a 1-hour Star Trek Voyager episode of 11h 33m. (I would use a Simpsons episode as my test instead, but I want to check the quality of the results, and I don't think a cartoon will be a fair enough test of quality.) I have it recording all Star Trek and Simpsons episodes, and in the next 24 hours, it is scheduled to record 5½ hours of TV. At the estimated rate, that equates to 2¾ days of transcoding time, by which point another 8½ hours of TV will have been recorded. Sounds like a losing battle.


Update: The good news is it finished before 11 hours — it actually finished in about 8. The bad news is, that was the first pass. Pass 2 has started, and it's estimating another 11½ hours.


Update 2: My kids closed the lid of my laptop, disconnecting my terminal. The time stamp on the completed file is 11:28, which, if correctly indicating the time it finished, would put the 2nd pass at a mere 4-5 hours. So we're back to 2 hours per day.

The New Player

Since the TV is unplugged while we work on painting the entertainment center, I wasn't going to be playing any Xbox 360 tonight. So, today was the day I installed KnoppMyth. Because of its size (close to a full CD), I wasn't going to get away with a USB key install this time. I had to open the box and hook up the CD-ROM once again.

KnoppMyth tries to be very easy to install, and the creator has done a pretty good job of leading you step-by-step through the install process. It works well, as long as you follow the directions exactly; otherwise it gets a little flaky if even your hard drive partitions are not set up right.

Once I got through the install, I went through the setup process, which, since I had seen MythTV's setup screens plenty of times by this point (and with most of them preconfigured), I knew what it was expecting. Unfortunately, when it got to the step of getting TV listing data, it crashed. I don't know why; I finished the other setup scripts and rebooted, and when I went back into mythtv-setup (helpful hint: if you don't have a mouse, Alt-X in Fluxbox brings up an xterm window), I was able to get it to download listings (after a couple tries; perhaps zap2it was having issues?)

I must say the interface was much more responsive and suffered from no video glitches, unlike the iMedia interface. I was starting to think I should've made the decision to go to KnoppMyth sooner. Even the Picture-in-Picture function was working almost perfectly (minus a strange blue hue on the small picture). Except when I tried to watch TV, I discovered a major disappointment. No sound.

For the next hour and a half, I searched forums and blogs, ran alsaconf and alsamixer, tried to aplay sound files in loops while I tweaked mixer settings... Nothing worked. Then, on a lark, I decided to plug in my microphone. (I was using a headset that had two plugs, one for the headphones and one for the attached mic.) I noticed something strange as I plugged in the mic -- I heard a crackling sound in the earphones. Did this headset need to have both ends plugged in to work? No, I still couldn't hear anything... But wait... Get a closer look at the markings on the plugs...

Yes, I had plugged the microphone into the audio out jack, and the headphones into the microphone jack. Switched the plugs, ran alsaconf one more time to reconfigure (and undo my random tweaks), and lo, there was sound, and it was good. And I went to bed.

Wednesday, June 20, 2007

The End of One Road

Just as a side note, I did figure out the garbled text screen problem, more or less. When I ran xorgconfig to generate my own xorg.config file, the garbled consoles didn't happen. I started changing the generated xorg.config file by inserting settings from the iMedia's installed xorg.config file. I think it was the Option "VBEModes" "true" line that caused the problem, but I didn't spend much time switching back and forth to tell.

I was starting to get fairly frustrated with the iMedia distro by this point. Although it was pretty well configured for my hardware, there were some peculiarities I couldn't figure out. Although it detected both tuners on the PVR-500, it wouldn't activate the Picture-in-Picture function. Kind of a minor annoyance, since our TV has PIP on its own, but it concerned me that something else might be afoot. (Although I did test the recording-while-watching scenario, and as it was recording with one tuner, it did launch the other tuner for TV watching without a hiccup.) Plus, I wanted some of the MythTV plugins, like the web server, and the web stream player. This mini-distro wasn't built for extensibility -- it lacked a compiler, and it didn't support deb or rpm packages (as far as I could figure out). iMedia did have a full Linux distribution available, but at a cost.

Sad to say, I decided to abandon the iMedia MythTV platform. I made a backup of the hard drive (which I had to do by simply tarring it and having the box FTP to my Windows workstation -- one of the times I'm glad for all the insecure servers installed on your run-of-the-mill Windows box), and called it quits.

The Web Links page of MythTV.org lists three distributions for MythTV: KnoppMyth, based on Knoppix (which I've used); MiniMyth, which appears to be Frontend only but made for VIA motherboards (the link appears to be dead), and MythTV-XBOX, made for Xbox hardware (which I might use on my Xbox someday, as a frontend to this box [since the Xbox has no A/V inputs for recording], but not today). KnoppMyth seems like a likely candidate.