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.

Saturday, June 16, 2007

The Reinstall

I have moved the MythTV box and extra monitor into the office. Somehow, as I was fiddling with it, I ended up disabling the automatic login and running of MythTV. I was at the point I knew I would reach eventually -- reinstalling and starting over. I really didn't want to open up the box to attach the CD-ROM drive again, though, so I endeavored to find a way to boot off a USB stick. The iMedia MythTV distro is only 68MB (give or take), and I had a 256MB USB key handy.

Just making a USB stick bootable is no easy task. I ended up going with HP's utility for making a boot key, which installed their custom Linux-based distro for upgrading certain servers' firmwares. Once I got that done, I copied the contents of the iMedia ISO to the key, renamed certain boot files as appropriate, and I was good to go.

The BIOS of the Jetway motherboard has as boot devices certain USB devices, like a USB floppy or USB ZIP drive. Following the suggestions I found on various web sites trying to deal with the problem of booting from USB keys, I tried all of those devices, but none worked. It turned out, though, when you set Hard Drive as the boot device and look under "Hard Drive Options" (or similar; I'm typing this from memory so I don't recall the exact text), one of the hard drives listed was in fact the very USB key from which I was trying to boot.

The only hiccup I had in booting from the key is the distro tried to mount /dev/cdrom to do the install; but even I knew enough to switch to another terminal, manually mount the key as /mnt/cdrom, and switch back and continue the process.

Yeah, I was feeling like pretty hot stuff at that point. I just booted and installed from a USB key.

The one thing that really concerns me is how hot this little box gets. It's not quite too hot to touch, but it does get close. Do I really want this thing in the same cabinet as two Xboxes (an original and a 360)?

Wednesday, June 13, 2007

The Assembly

As luck would have it, everything arrived on my wife's birthday. So, for better or worse, I spent most of the night putting the thing together. I got to experience a whole new world of trying to make things fit. It turns out I was lucky I went with the 2.5" drive; I'm not sure I could've squeezed a 3.5" drive in with the tuner card. One neat feature is that the case came with a CF-to-IDE module, so it would be possible to use a CF card as a hard drive, further reducing power consumption (assuming you could spin down the data drive when not in use). However, again, the tuner card was big enough that it blocked the pins where the IDE cable would connect to the CF adapter. Just as well; I don't have a CF card big enough from which to boot, anyway.

I had already downloaded the iMedia MythTV ISO and burned it to a CD. I took the box to the basement, where I had an extra monitor, hooked up a CD-ROM drive (full-size IDE drive, which of course didn't fit in the case -- fortunately, DVD playback was not a requirement) and ran through the installer. All in all, that procedure was fairly painless.

I then took the box upstairs, finished closing it, and hooked it up to the TV. Unfortunately, there was no display. I brought the extra monitor up from the basement and rebooted several times. Eventually, I found the option in the BIOS to direct video to the TV (buried under "AGP Timings" of all places). The monitor stayed nearby, though, just in case.

Unfortunately, not all was puppies and roses. Although the iMedia distribution included drivers for the LCD, it did not in fact have it hooked up to MythTV, so although the display showed me CPU usage, it didn't show anything having to do with the PVR, nor could I use the keypad to control the system. Can't pull the keyboard yet.

Another puzzler was that, once the system booted up and launched X, all terminal screens were garbage. It's like it set the text mode to some bizzare resolution or frequency, because I couldn't read anything. The monitor would also start in with a high-pitched whine. I decided to pull the plug on it for the night.

Thursday, June 7, 2007

The System

BYOPVR.com was all talk about this new (to me) concept of a Mini-ITX form-factor. The concept was very promising. These systems promised to be low-power, small (good for fitting into an entertainment center), but with enough features to successfully run as a PVR.

I began looking at parts. Unfortunately, it wasn't long before I discovered I was in over my head. Although some ran on standard ATX power supplies, those didn't have the benefits for which I was looking; it was when I started looking at DC/DC power conversion modules that I realized I had no clue what I was doing. If I had attempted to put it together part by part, any money I might have saved in the long run would've been far eclipsed by the frustration and possible danger of getting the wrong parts.

Fortunately, I found my solution. Mini-Box.com had a few complete systems for sale. What's more, they also had a Linux distribution for free download, called iMedia MythTV, that was specially made for this type of system (i.e. low power). I decided to splurge a bit and spring for the M300-LCD, partly because it was big enough to support a full PCI card (which I would need for the tuner card), and partly because of the nifty LCD on the front.

Once I had the system all spec'ed out, I compared the components' prices with NewEgg.com. Mini-Box did not offer a SATA hard drive (at least, their drive options did not specify PATA or SATA, or even 2.5" vs. 3.5" -- I wanted the 2.5" again for the power consumption, although my experience with 2.5" hard drives may have me kicking myself for that decision), so I decided to order the hard drive from NewEgg instead. Mini-Box actually had a better deal on memory, so they got my business there.

My order from Mini-Box consisted of:

  • M300-LCD case, $109.95
  • picoPSU-120 DC-DC power supply, $49.95
  • 12v/5A AC-DC power adapter, $24.95
  • Jetway Hybrid Mini-ITX motherboard w/VIA C7 1.5GHz CPU, $149.95
  • 1GB DDR2 memory (single stick), $47.00
  • Shipping, $8.09
  • Total: $389.89

NewEgg.com had the best price for the tuner card I wanted -- a Hauppauge WinTV-PVR 500. Although fairly expensive, I wanted its dual tuners on the single card, because one card is all the room I'd have, and I didn't want this project to be a disappointment the first time my wife wanted to record two shows that happened to be on at the same time. Luckily for me, they also had a sale on a 2.5" SATA hard drive. $139.99 for the card, $49.99 for the 60GB drive, and $7.24 for shipping brought my total to $197.22.

Total price: $587.11