Adding Commands to mplayer

The computer I use to watch DVDs (and other stuff) with has three sound outputs: via HDMI to the TV, via the built-in analogue sound port to my wireless headphones, and via a USB sound card to external stereo speakers.  Which one I use depends on what I’m watching and what time of day it is.

So it would be nice to be able to change where the sound goes to on the fly. mplayer doesn’t have built-in support for it, but you could do this externally via a PulseAudio or the like, but since mplayer is occupying the screen and getting the commands, it seemed easier to just hack mplayer.

And, besides, each audio sink needs a different video/audio delay. The TV, for instance, delays the picture a bit, so if I’m listening over the headphones, I need to subtract a tenth of a second for the audio delay.  Or something.  I just experimented until I got something where Jon Stewart looked marginally less unhinged.

It turned out that adding commands to mplayer is really easy, but digging into the code this big can be pretty bewildering.  So if you ever want to add commands and keystrokes to mplayer, I’ve put the patch on the interwebs. It probably won’t apply cleanly to your specific mplayer version (and you wouldn’t want to, since it hard-codes my specific commands), but it should give you a rough idea of where to poke around.

An Emacs-based PVR

In the continuing story of me trying to push a few of the odds and ends of the code I’ve written for my own use, we’ve now come to the Emacs-based PVR. As usual, it may not actually be very useful code for, like, normal human beans, but why not push it out there?  Perhaps somebody will be inspired to do…  something.

So the story behind this piece of code is that I’ve never really been very fond of watching TV live.  I know, these days nobody does that any more, and everybody uses their cable company supplied (and crappy) PVRs, but back at the start of the millennium, it was a not un-novel idea.

USB TV card

And my implementation of it, based on Emacs, is probably noveller (that should be a word) than most.

So the idea is basically that we pull down the TV programme (thoughtfully provided by the XMLTV project), see what programs we want to record, and then record them.  It’s simple.  Since it’s Emacs-based, I can just ssh in to my machine from anywhere and add new programs to the list of stuff to be recorded from anywhere.  Take that, User Experience people.

The computer is hooked up to an external USB tv card that provides an MPEG stream.  So the actual recording is just “cat /dev/video0 > /tv/file”.

The nice little box running Linux

The cable company calls me sometimes and asks me if I kindly could consider switching over to digital cable, but then my PVR thingie would stop working, so that’s out of the question.  If analogue cable goes, I stop watching TV.

The only problem (for some values of “problem”) with this setup is that I can’t watch TV live easily even if I wanted to.  But I’ve been running stuff this way for a decade, and that hasn’t really tempted me more than a couple of times, so, eh, whatev.

Synology DS409 RAID is Crap

Do you see that thing over there?  The Synology Disk Station DS409?  It’s crap.

It’s not the usual hardware RAID problems that make it so crappy. 

Yes, it’s slow.  Painfully slow. 

Yes, it has a weird Linux kernel that, somehow, manages to do put all NFS clients into

df: `/mirror’: Permission denied

if you change any export permissions.  Any.  Not even on the volume in question. Or

df: `/mirror’: Stale file handle

if you reboot it.  How have they even managed to do that?

No, it’s not that.

It’s that if one of the disks break (as they are wont to do, which is why we have the “R” and “I” in “RAID”), which usually happens at 2am, the thing starts beeping.

Loudly.

Beep.  Beep.  Beep.

And there’s no way to turn the beeping off.  Other than switching the entire thing off.  So you have a redundant disk system, but if one of the disks break, it starts beeping so loud that it’ll wake all the neighbours, so you just have to switch it off until you can find a new disk to replace the old one.

So it’s redundant, but you can’t use it.  Ingenious.

The only thing I can recommend about the Synology DS409 is that it’s less unstable than any of the other commodity hardware RAID devices I’ve used.  Which means that as soon as 4TB disks become available, I’m going to just make a two disk soft RAID device and escape the horrible clutches of hardware RAID makers.

(I should make this blog into an electronic consumer review site, shouldn’t I?)

Running an RSS to NNTP Gateway

If I knew that doing an RSS to NNTP gateway was so easy, I would have done it years ago. I was just waiting for somebody else to pick up this obviously useful idea, but apparently nobody else wanted to.

In comparison to doing the Gwene gateway, the (almost) ten-year-old Gmane mail-to-news project is pretty mammoth, what with all the administration, spam work and web interfaces.  Gwene, on the other hand, is a minuscule collection of Perl scripts (find the source code on GitHub).

The main issue with parsing real-world RSS/Atom files is that, like HTML, they can’t reliably be parsed strictly.  None of the Perl RSS-parsing libraries seem to take this into account, and fail pretty badly on real-world feeds.  So the Gwene scripts have to pre-process the feeds before handing them over to the libraries, and then they have to root around pretty invasively into the Perl libraries’ internal structures to pick out the useful bits.

Somebody should extract the useful bits from the Gwene scripts and whip up a simpler DWIM RSS parsing library.  But I’ll leave that to somebody that actually knows Perl.

Tellstick Redux

I was whinging a lot about the terrible Tellstick range in my last post on the issue.  Deservedly so.  It’s terrible!  However, the Telldus people have released a new version of the device:

The revolutionary new invention is the antenna!  Who would ever have thought that an antenna would give greater range?  Kids these days.

Anyway, it really does work.  I had four separate antenna-less Tellsticks that gave me 90% coverage of my apartment earlier.  With the new Tellstick, a single one gives me 100% coverage.

That’s progress.