Category Archives: MythTV

web media frontend

I have always wanted to tweak my HTPC frontend quite a lot to add extra functionality, but the entry barrier to learning a GUI language has been way too high for me.  I’ve had success though, in patching MythFrontend to do some things a little better for me, but I’ve always wanted to get my own going if I could.

Recently, I was thinking about how LIRC can capture IR events and map them to X keyboard events.  Basically, you can control X applications with your remote control.  I started to reason that if that were possible, then I could just use my web development skills and create a webpage frontend for my HTPC that would run on a lightweight browser, and listen for keystrokes.

Just playing around with it tonight, I actually made some really great progress thanks to a combination of a good friend, my humble jQuery beginnings, and my laughable CSS skills.  This is the result so far. :)

I’m really stoked about the implementation so far.  You’ll most likely need Firefox to get that working properly.  It will capture the arrow key presses (up, down, left, right) and use that for navigation.  I realize that the beginnings are rather crude, but the fact that I could throw this together, so quickly, while I’m just barely learning my way around jQuery seems pretty impressive to me.  I’m actually quite proud, though, that I got the navigation to work properly, too, so wrapping around rows and columns works. :)

This is certainly going to be a fun project to hack on.  If I could get this working, this would open up all kinds of possibilities for me for displaying metadata and new options for navigation.

For comparison, here’s a screenshot of what my frontend looks like right now.  As you can see, I’m trying to imitate the style as closely as possible.

There’s a lot of advantages to having it web-based — not that I’m going to serve up anything remotely or anything, this is solely for my LAN.  It’ll just allow me to build out stuff much faster.

The hard part is going to be doing testing on the frontends.  They are both running off of tiny installations, and it’s not easy building and porting software to run on them.  Sounds like a challenge that’s extremely hard, going to take a lot of time, and will have marginal benefit and at the same time increase my workload and opportunity to own more of my software stack when things go wrong.  That’s just right up my alley. :)

1 Comment

Filed under Entertainment, Gentoo, Multimedia, MythTV, Programming

tromping around mythvideo code again

I’m still trying to decide where I wanna go with my media browser/frontend solution — if I’m going to write my own or keep hacking on MythVideo. I only have one really nagging issue left now, and that is that the file structure presented is static once you enter the “Watch Videos” menu. I’d like it to be dynamic (that is, upon entering a new folder, check the contents again) so that I can add stuff like symlinks to series that I’m currently watching, or whatever. Doing that is pretty tricky.

I spent a few hours last night digging through the code, trying to find out exactly how the code is operating and what it’s doing. What I learned was that, well Myth was doing exactly what I thought it was — it builds a file list upon first entering, and then it doesn’t examine it at all until you re-enter the video browser through the main myth menu. (I wish I had a decent screenshot about now, it’s a bit confusing if you don’t know what I’m talking about.)

There’s a couple of problems with this approach, in my mind. First of all, the time it takes to actually load the mythvideo plugin grows in relation to how much media you have that it needs to parse. That is, it iterates over *every* single file that is in your media storage, and adds it to one variable. It’s essentially like running find on your filesystem, saving it into one variable, and then when browsing, just using that snapshot that you took.

The simpler way, in my opinion, would be to just refresh the directory structure and metadata for the directory you are in. While I was poking at it, one thing I tried was to get the directory scan to not go more than one level deep. That reduced the startup time from about 8 seconds to less than one. Nice.

Ideally, I’d like to change it so it just updates the directory scan as it enters a new one, progressively growing the variable as you jump around the directory tree, but I couldn’t figure out how to do that in the code (and if someone wants to help, that’d be awesome). MythVideo calls fetchVideos() only when first entering, and not anytime after that. The real problem is that it in turn calls about eight other levels of functions that eventually get to scanning the directory tree. I could probably hack it together to pass the current directory I’m in and update the directory scan from there, but again, I’m so limited in my C++ skills, at this point it’s just code and guess. So, I can find and explain the problem, but not fix it myself.

Fortunately, it’s a minor wish list item of mine, and so it’s not a show stopper. I can live with not being able to do it, and it’s probably just a matter of me learning how to code a bit more that I could figure it out. On the plus side, I’m learning more about the internals of the code, and each time I go in there, I find a few small inefficiencies that I can cleanup myself, which is fun. Making progress, I suppose. :)


Filed under Gentoo, MythTV

upgrading myth, part two

I’ve almost finished the upgrade process for MythTV.  Last night I ported all my patches towards 0.21 and so far everything is working great.  This time I took it a step further and modified the code so it would look for all cover art in a central directory, instead of locally (filename.jpg for individual files, folder.jpg for directories).  Kind of cool, I think, that I’m starting to make the changes directly in MythVideo for my personal preferences instead of working around Myth’s functionality by creating symlinks and stuff on the filesystem.

Usually I would avoid going into the code, but I’m slowly getting more comfortable doing it.  I think the Qt3 docs could stand being a tad bit more verbose, though.  In a lot of cases where I was confused, it was a matter of not understanding exactly what the function was returning, and I’d have to execute it myself to figure it out.

Aside from that, all the “original” stuff is in, but I found two more bugs that I want to hunt down.  I thought I had this first one licked, but I guess not — if you have a file on the filesystem that is not stored in the database, then it will display the filename sans extension as the title at the top of the page (fex: Mr._Belvedere).   I’ve already fixed it so that it will show the “correct” title (replace _ with spaces) when displaying the grid of all files, but I can’t seem to find the variable where it’s showing the other title and it’s a little hard going through the code trying to figure out what everything is doing.  I haven’t figured *that* much out.  In fact, I know my way around just a few functions in videogallery.cpp and that’s about it.  Once it gets outside of that, I’m back in Wonderland.  I’m lost.

Add on top of that there’s not much documentation, if any, in the code and it makes it a bit of slow going.  Ah well, it’s only a matter of time most likely.

The second bug is really annoying, and it’s interesting in that it’s one of those phantom ones that was always like … “wait a minute, did something just change?”  There was a nagging feeling that something had changed, but I could never pin my finger on it.  I finally found it.  What happens is, when MythVideo has scanned the files and put the metadata into the database, it will do some kind of intelligent sorting based on the titles for display.  That is, titles prefixed with “A”, “And”, “The”, etc. will have the prefix dropped (can’t remember the correct grammatical term for those) and then sorted by the following words in the title.  I only caught it because I had added an MP3 file for the LP of “A View To A Kill” (and yes, there are children’s records that tell the story of the 007 films — how cool is that?) and I was testing some stuff in that folder and actually saw it’s position change before and after it was put into the metadata database.

That one, I have absolutely no idea where it’s getting sorted at all.  I don’t have a clue, and it could be anywhere, since all the MythVideo displays implement that, not just the Gallery view.  I just need to send a note off to the mythtv user’s mailing list and hopefully someone will know.  That would be nice to get rid of, though.  I don’t like the inconsistency.

In fact, I never use the metadata database at all.  Pretty much all I see is the cover image, which I supply manually, and the title.  And I rename all my videos so that the title is part of the filename, including the episode order for the ones that are a part of a series.  I already ripped out the stuff to display the metadata before playback, since I’m not interested in that.  So, I know that it’s somehow related to the metadata database, since the titles *and* the orders are affected once they are in there.  Just gotta figure out where.

Other than that, everything has gone really smooth, and it’s been nice.  One thing I did notice as well was that 0.21 just seems generally snappier and much more responsive.  It could be my imagination, but I don’t think so … there just seems to be less latency and wait when navigating and moving around places.  It’s pretty nice.

Leave a comment

Filed under Gentoo, MythTV

upgrading myth

I started doing something last weekend I always swore I’d never do — upgrade MythTV on my Mini ITX.

Normally, the process wouldn’t be hard, except that I’ve built a custom image that is running on a solid-state flash disk that is only 256 mb in size. And yes, it’s Gentoo. It doesn’t have a full blown Gentoo install, of course, but it’s certainly a very stripped down version of one. I’ve had the image on there for probably a year and a half or more, and have been extremely content to just leave it alone as it works just fine.

As time goes on, though, I’ve been hacking on MythVideo a bit here and there, adding a few tweaks to suit my needs. This weekend I finally got another navigation one hammered out that took me a few hours to figure out due to my lack of C++/Qt programming skills. It was worth it though — it was one annoying UI decision I didn’t like (I won’t go in details, but it’s how the menu position is selected when navigating back and forth through the video gallery).

The problem is that making any kind of changes to the Mini’s image is always a pain for a couple of reasons. For one, if I screw something up badly, it’s a bit difficult to get into the box. I don’t have a USB bootable stick laying around, and in fact I’ve never had much luck getting one to work .. and I don’t think this box will boot off of one anyway. Not sure. That means if something really goes haywire then I have to boot over the network, which is a bit of a pain to setup sometimes. Fortunately, it didn’t come to that this time.

Another issue is that because space is so limited, part of the filesystem is loaded from a read-only squashfs image. That means a bit of tedious testing when it comes to unpacking the image, removing the old files, adding the new ones in place, repacking it, remounting it, and restarting the application each time just to test anything. That adds a lot of time to the process.

This time around, I did something pretty smart, in my opinion. I don’t know why I didn’t think of this before. The squashfs image is loading /usr/lib. This time, I installed Myth to /usr/local so that I could leave the libraries alone and replace MythTV easily. Just create a new image for that one, and drop it in anytime.

Anyway, tonight I just barely got it working with the new install. I went from a very old 0.20 install to the latest 0.21 in portage (0.21_p19961). In fact, one of the reasons I had to upgrade is because I can’t even get 0.20 to compile anymore. Normally I wouldn’t care, but I figure I may want to write more patches, and it’s getting to be painful trying to maintain an older version that I can’t even duplicate in case of a problem.

One other nice thing that’s changed since I last built this is I have my still-somewhat-newish ThinkPad to build it on. So I just build the binaries on my x86 laptop, strip out all the crap I don’t need or want, create a new squash image, and drop it right in. Relatively speaking, it has all gone rather smoothly. I think I’ve probably spent about 20 hours on it since Sunday. I vaguely recall it taking at least two weeks the first time I put it together. And of course, it took me something like three months to even get X, Qt, LIRC and all the other stuff on such a small bootable image. That was a really bumpy ride, but I wouldn’t trade the knowledge to do it for anything.

That’s the other thing — I could *easily* spend less than $20 and get double the harddrive space (512MB) and be able to forego half the problems. Or, I could even spend another $20 and get a 1 or 2 GB drive and have a *lot* of room to play around in. Oddly enough, I’m really going against my normal approach and instead of throwing money at the problem, I’m taking it as a matter of pride that I can endure so much pain and still get it on such a small drive. And really, I don’t need the extra space anyway. Once it’s done, it’s done and done. It’ll be just like before, where I’ll leave it alone for 18 months or more, and I’ll be completely happy with it the whole time.

Just for the record, here’s the harddrive current status. I managed to clean up a lot of cruft this time around and freed up a lot of space:

Filesystem            Size  Used Avail Use% Mounted on
/dev/hda1             238M  184M   42M  82% /
udev                   10M   60K   10M   1% /dev
/usr/usr.lib.img       36M   36M     0 100% /usr/lib
/usr/usr.local.img     18M   18M     0 100% /usr/local
shm                   474M     0  474M   0% /dev/shm
svcdir                2.0M  116K  1.9M   6% /var/lib/init.d
//willy/media         1.4T  624G  726G  47% /var/media

And finally, here’s what the menu currently looks like … still unpatched, and with the default theme. That’s for another day. I’ll cover what the patch changes, too. Someone may find it useful. In the meantime, I think it’s time to try and catch up on sleep.  I’m really tired.


Oh, and those icons are from the gartoon theme set.

Leave a comment

Filed under Gentoo, MythTV

media frontend

One thing I’ve been thinking about more and more lately, is that Myth is way overkill for what I’m using it for — effectively, just MythVideo and that’s it.

The only thing I use it for is a GUI interface to browse folders, display thumbnails of folders and files, and playback whatever I pick.

There’s gotta be something simpler out there, though I imagine I’ll probably just end up writing my own.

Now what’s a good easy GUI development library that wouldn’t be hard to learn?


Filed under Computers, MythTV

pimp my mythvideo: coverfiles made simple

his being my third patch to fix some mythvideo nags, I’m actually starting to get comfortable going in there and trying to find this stuff. It’s still incredibly difficult to try and figure this out, since there’s little documentation and I vaguely understand C++, but it’s fun to attempt and cool to succeed.

This patch fixes an annoying problem I’ve had for a long time — it’s a royal pain setting a cover file for a video. A cover file would be the actual image that shows up in the gallery view for a media file. Without one, you just see a blank little icon which is pretty boring.

Folders are really simple — you just add folder.jpg (or .gif or .png) to the directory, and it will show that. Individual files are a bit tricker. If you were just using the interface, you’d have to first go into the Video Manager to let Myth scan the directory of files, create an entry in the database, then go find the file, edit the entry, and set the coverfile manually.

I originally wrote a script to do that part for me. I would just create a JPEG image for each media file, usually with the same filename, but a different extension, and code in a check to see if both exist, update the videometadata table. All the time, I kept thinking though, it would be so much simpler if Myth would just check to see if the file existed like the folders, and display it. That’s exactly what this patch does.

I pretty much just copied the same code from the part where it looks for the folder icon, and did the same thing. If, for example, you have movie.avi, just create movie.avi.jpg (or .gif, or .png) as the coverfile and you’re done.

Actually, you do have to put the file in the database first, since it still checks to see if there is any metadata for it at all. That is extremely simple, though, either by script or UI navigation. The UI will just add new ones quietly, and you can quickly exit out. The patch will still use your coverfile in the videometadata table too, if there isn’t a similar filename that it can find, so you can apply this and it won’t break your existing setup.

As usual, the ebuild is in my overlay. This one is mythvideo-0.20.2_p15087-r3.ebuild. I’m going to eventually document these a bit better and file bugs with upstream. I know I’m using an “old” version to patch it onto, but the reality is that SVN hasn’t changed at all since that revision, so even the latest version bump is the same code.

I also spent the weekend working out a number of small kinks in my system and setup. I drafted up a new “wishlist” that I have of stuff I’d like to eventually get fixed, and it’s getting smaller all the time. Right on.

As far as mythvideo patches, though, I only have one last small annoyance that, while it doesn’t really bother me, does kind of throw me for a bit of a loop so I’d like to see if I can fix it. The bug is that folder names and file names are sorted differently. I can’t remember which is which off the top of my head, but one of them will ignore prepositions like “The”, and “A” on the front of titles and sort by the second words. So “The A-Team” would show up near the top of the list. Maybe it does that on both file and folder. Anyway, I don’t like it. It’s a bit confusing. I tried looking for where it does that, but I haven’t had much luck yet.

Leave a comment

Filed under Gentoo, MythTV

weekend multimedia notes

I’ve been spending part of the weekend working out small annoyances in my myth setup, trying to get it inching closer to my “perfect” setup.  I’m actually really close now, minor stuff is all that’s left.

Here’s a few things I want to remember as a point of reference, that took me a bit of research to figure out:

Printing options in MPlayer:

mplayer -list-options <command line arguments>

mplayer -input cmdlist <slave mode commands>

mplayer -input keylist <events>

Mapping Page Up and Page Down with my remote in MythTV:

prog = mythtv
button = ch+
repeat = 3
config = PgUp

prog = mythtv
button = ch-
repeat = 3
config = PgDown

Finally, I hit some snag with MPlayer and VobSubs (subtitles that originally come with DVDs).  I’ve got some movies in Matroska format, and with recent (SVN r27719) revisions, it will forcibly display the subtitles on playback, and I have no idea why.  I swear I remember reading something about this on the mailing list a while ago, but I haven’t had much luck finding anything.  Best option so far, go back to an earlier revision (r25993).  Not ideal, but it works.  Every sub, force and vobsub option I’ve tried does nothing.  I’m not passing anything by default like -slang or -sid to mplayer.

Another thing I’ve been working on (I’m really bored) is finding posters for the cover images in my movies folder.  Which got me looking at UK quad posters.  If you haven’t ever seen the posters from across the pond, they are so much better than our American counterparts.  They are a horizontal landscape, which allows for, in my opinion, a much more dramatic picture.  Check out this Star Wars one, for example.

It just looks so much better, in my opinion.  I gotta get some movie posters up on my wall (only two so far: Tron and The Adventures of Milo in the Phantom Tollbooth), and I’d love to hunt down some quads.  The old school Disney ones look even awesomer.

Speaking of cover images for Myth, I have a new patch I cranked out last night, which has an interesting story to it.  I’ll post details later, though.  I’m not in the mood for details right now.  I’m more about hunting down stupid bugs that don’t require too much brain power.

Leave a comment

Filed under Entertainment, MPlayer, MythTV