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. :)

5 Comments

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.

myth1

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?

7 Comments

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:

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

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

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

playlist resume

I wrote about this a little bit a while back, wrt mplayer-resume, that I wanted to work on a way to resume playback from a playlist as well using MPlayer. Well, I finally sat down and figured it out last week. For some reason it took me a good while to figure out the logistics of how to do it rather than the coding. I dunno why. Anyway.

I wanted to wait to bump mplayer-resume until after I added something else, and this is gonna be it. Just gotta clean up the code and package it now, and it’ll be ready to go.

Here’s how it works though: the script, like mplayer-resume, acts as a wrapper to mplayer. In fact, everything is pretty much the same except that it saves both the filename along with the position in the playlist.

The problem I was having a hard time figuring out was that I wanted to easily make two options available: resume playback in the current file I’m in (old mplayer-resume functionality), and resume playback in the position in the playlist I’m in. I just finally mapped two keys on my remote, exit and stop, to take care of both of them.

Hitting Exit on my remote will save the playback of the current file and write that to the playlist position file. Then it also saves the seek time where I left off. Hitting Stop will kill the old entry and just add a line to the playlist saved position file that says what the *next* file should be on playback.

Pretty simple when you consider it, but it took me some time to figure out, mostly so that it seemed intuitive. I figured I’d have a hard time getting used to it, and hit stop accidentally and losing my place where I wanted to be, but so far it’s worked out fine. I’m happy with it.

I’m using it for playback of my TV shows, which is pretty much 95% of what I’ve got ripped on my media setup. I have a few movies, but no AC3 output, so I prefer to just stick those in my DVD player. It is the only way I can watch my Region 2 or 4 DVDs though. For TV, it works great, since I generally want to watch them in general succession of episode order. And if I don’t feel like watching a certain episode, you just hit stop and it’ll skip to the next one. Very nice. I suppose I could map a button to go *back* in the playlist if I screw things up accidentally, but I’m kinda running out of buttons to map on my remote. Besides, vague mappings that I’m supposed to remember usually hurt more than help.

2 Comments

Filed under bend / dvd2mkv, Gentoo, Multimedia, MythTV

pimp my mythvideo: another navigation patch

I’ve been working on a bug all night I noticed the other day that really annoys me in Myth, and I stayed up poking at the code trying to find a way around it. Actually, it’s a little weird how I “discovered” it, since I always perceived in the back of my mind that there was something annoying, but never pinpointed it specifically what it was doing until this week.

The bug is this: when you are using gallery view in MythVideo and you enter a folder, when you exit back to the main root menu, it repositions that folder at the top, regardless of where it was when you entered the folder.

Some pictures will probably make more sense.

Here is a screenshot of what my folder display looks like when I enter MythVideo’s gallery for the first time, and browsing for a folder to select:

 

Now, when I select that directory, I’ll see the files in there. But when I hit Escape or select the previous folder icon, it will return me back to the root menu. However, the folder layout has changed, and the row that the folder is on, originally the bottom, is now at the top.

 

 

Moving around the position of the folder layout throws my brain for a loop every time it happens, because I’m expecting to see the same display as when I was just in there, and since it’s different I have to rescan the layout visually and reprocess where I am and where I want to navigate.

This patch fixes that, and keeps the layout the same when you return to the root window.

I went ahead and added a new ebuild in my personal overlay which will install it for you if you don’t want to patch it manually. The ebuild is mythvideo-0.20.2_p15087-r2.ebuild and it also includes my original navigation patch.

Now then, there’s one small bug in it that I’d like to fix, but I don’t know any Qt or C++, and it’s a miracle in itself that I managed to even get this far on my own. In fact, I’m quite proud of myself actually that I even figured this one out all by myself, go me. :)

I originally patched it so that it would just reposition the parent view around the last folder row you were in … that is, I was doing the same thing, but not specifically for the root menu, just any folder you went into. That worked fine, provided your tree didn’t have more than one level. The second you went into a third directory Home -> Foo -> Bar, the 2nd variable would overwrite the first one so when you returned to the parent it would be whacked. If that makes any sense. Anyway, for someone with Qt knowledge, it shouldn’t be hard to fix so that it always does that no matter which folder you are in, and at what depth level. I have no idea how, though.

It’s actually kinda interesting how I figured this one out. There were two things I noticed from poking around in the code. One, to get videogallery to dump out variables to stdout, I would add this to the code:

VERBOSE(VB_GENERAL, QString(“Some text.”));

VERBOSE(VB_GENERAL, QString(“Some variable: %1″).arg(someVar));

Yah, brilliant hacking on my part, I know, but I managed to kludge my way through it and figure it out.

The second thing I realized was that if I wanted to find out if I was on the parent tree or not, I would have to create a new instance of GenericTree and check to see if getParent() returned the main root or not.

GenericTree *lparent = where_we_are->getParent();

Then, if lparent != video_tree_root you would know you’re not at the top yet.

Anyway, yah, my awesome debugging skillz at work there, but hey — it took a lot of patience and more than a few rebuilds, but it worked, and I’m happy. Woots.

One last thing — the patch will also apply cleanly against current SVN (r18336 as of this writing) since it hasn’t changed in a good while, so you don’t have to use my ebuild if you don’t want, or you could just rename it to the latest snapshot in portage and it’ll still apply.

Leave a comment

Filed under Gentoo, MythTV

pimp my mythvideo: navigation patch

Even though I can’t code in C++, or anything more hardcore than bash (and even that’s pretty sketchy), with a push in the right direction from a noble soul in #mythtv, I managed to mangle a patch together for MythVideo that fixes some annoyances that I’ve had for a very long time. They are:

  • Filenames won’t display underscores, but folders would
  • Getting rid of the “cover image” screen in the gallery
  • No page up, page down support with your remote

The patch is here, which should apply cleanly to media-plugins/mythvideo-0.20.2_p15087. Or you could just try and use my overlay directly. If you look at what I’ve changed, it should be really simple to make the same changes to the most recent version for SVN, since I don’t think the file has changed much between releases. Creating patches is also not my favorite thing to do, and in fact actually took me longer to create the actual diff and apply it correctly then it did to hack the code.

Here’s a complete list of what I changed, if you don’t want to go digging around the code and determining what’s happened for yourself:

First, the issue of page up / page down. Sure it’s nice that you can do that with a keyboard, but if you are using a remote, it’s painful scrolling when you have a lot of folders to look through. I remapped 1 and 7 to emulate Home and End, and 3 and 9 to emulate Page Up and Page Down.

Second, for the display of folder names, if it has an underscore in the title, that is replaced with a space. This is consistent with the naming scheme for the actual files.

Third, and always most annoying to me, is that I got rid of the information screen that displays all the metadata about a movie after you select it in gallery mode. I always thought that was pretty useless, because I already know what I want to watch, and didn’t like having to hit enter twice to start playback. There was a shortcut already, you could just hit the Play button and it would skip the screen, but I think this is more effective and natural.

Finally, I disabled the Menu, Filter and Info options by commenting them out, for the only reason that I never used them and sometimes they would pop up when I was debugging stuff with mplayer and my remote.

Needless to say, I’m much happier now with my user experience, since MythVideo is all I’m using right now. I have a really low tolerance for small tweaks that bug me, and I’m glad I finally got these taken care of. Besides, it’s forced me to start learning some C++ (again) so I don’t have to keep relying on people to help me get started.

Now I can go back to watching Roger Ramjet and Knight Rider in navigation harmony. It’s great. :)

2 Comments

Filed under Gentoo, MythTV