James' Tech Blog

Tag: mythtv

How to update Mythvideo file titles

by on Sep.13, 2010, under Uncategorized

The title of the post is a little confusing, I’ll admit that straight away. Here is the problem. I had a bunch of series AVI files name as such: 101.avi 102.avi 103.avi … ad nauseum. This was great, but episode titles make it easier to pick out which one I really want to watch. Especially when I’m using UPNP. So I renamed all my files to be like 101.Rose.avi. Great, super easy to tell what the episode is about!

Good thing mythtv is smart and made hashes of all the files. Now it knows that 101.Rose.avi might as well be 101.avi. Awesome! If I had trailers, poster-art, and other metadata it would be right there with the files with new names. Unfortunately, what it didn’t change was the title. So when I look at my videos in mythfrontend 101.Rose.avi is called 101. The titles didn’t update. Well, this is good behavior. If we’re going to track which file is which by hashes, then we don’t want to change the title just because the filename changed (or path I’m presuming).

This is not the behavior I wanted though. I searched a little bit, but couldn’t find anything. I did find out the structure of videometadata though. That gave me the clue to just write a script to update the titles based on the filenames. Here we go, in glorious PHP:


//replace master_IP with your MySQL IP address and password with whatever your password is
$con = mysql_connect("master_IP","mythtv","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("mythconverg", $con);
//if you want all the files the next line is good. Otherwise see line after that
$myquery = "SELECT intid,title,filename FROM videometadata";
//I did it for a subset of files which is why I used LIKE to match part of the path in the filename field
//$myquery = "SELECT intid,title,filename FROM videometadata WHERE filename ". 'LIKE "%who%"';
$myquery_rows = mysql_query($myquery);
while ($myrow = mysql_fetch_array($myquery_rows)) {
//update query
$new_title = substr(basename($myrow['filename']), 0, strrpos(basename($myrow['filename']), '.'));
$up_query = "UPDATE videometadata SET title = '" . $new_title . "' WHERE intid = '" . $myrow['intid'] . "'";
print $up_query;
//mysql_query($up_query); //uncomment this after you're satisfied with the output
}
mysql_close($con);

To protect the innocent I have it just print what it would change the titles to. All you have to do is uncomment the mysql_query line. Sorry the code plugin I have squashed my tabs. Not a deal breaker, but it would be easier to read. Also, the code plugin doesn’t like php tags you’ll have to add them. The next script is probably the one you want to run first. It just prints the intid, title, and filename (which in my case included path) for each file. This is handy to see if the filenames/titles match. Also, to see if your update went well.


$con = mysql_connect("master_IP","mythtv","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("mythconverg", $con);

//if you want all the files the next line is good. Otherwise see line after that
$myquery = "SELECT intid,title,filename FROM videometadata";
//I did it for a subset of files which is why I used LIKE to match part of the path in the filename field
//$myquery = "SELECT intid,title,filename FROM videometadata WHERE filename ". 'LIKE "%who%"';
$myquery_rows = mysql_query($myquery);
while ($myrow = mysql_fetch_array($myquery_rows)) {
  print $myrow['intid'] . " | " . $myrow['title'] . " | " . $myrow['filename'] ."\n";
  }
mysql_close($con);

Please don’t go running amok in your database and blame me for it getting screwed. Use mysqldump before running the update script. Although it should be pretty innocuous because you can always use mythfrontend to rebuild the videometadata database. Though you would lose any metadata you had input for your files. Happy hunting! Maybe I’ll port this to a proper scripting language like PERL or python. Or maybe someone’s nice enough to do it for the rest of us???

Leave a Comment :, more...

Mythvideo now compiled

by on Mar.14, 2010, under Uncategorized

So, I switched to myth-0.22 awhile back because I finally got a sane database. No thanks to the mythtv guys, many thanks to the Gentoo guys for pointing out the bad behavior of mythtv not checking encoding formats and just assuming. I had been trying out the SVN version because 0.22 was broken in Portage. Long story short I haven’t been able to build mythvideo for months. Today I finally tried looking at the build log and internet searching. For reference here are the first few errors in the log file:
In file included from metadata.cpp:8:
/usr/local/include/mythtv/mythcontext.h:9:22: error: qptrlist.h: No such file or directory
In file included from main.cpp:18:
/usr/local/include/mythtv/mythcontext.h:9:22: error: qptrlist.h: No such file or directory
/usr/local/include/mythtv/mythcontext.h:13:23: error: qnetwork.h: No such file or directory
/usr/local/include/mythtv/mythcontext.h:13:23: error: qnetwork.h: No such file or directory
I stumbled upon someone else who couldn’t build that was getting similar errors to mine http://mythtv.org/pipermail/mythtv-users/2008-November/238546.html The problem was that the prefix for SVN is /usr/local/ whereas the ebuild prefix is /usr/ The quick and dirty solution:


mv /usr/local/include/mythtv /usr/local/include/mythtv-old
ln -snf /usr/include/mythtv /usr/local/include/mythtv

That solved the problem immediately, but I think the real problem is the ebuild. I checked the mythtv ebuild and the prefix is defined as /usr/, but the mythvideo ebuild does not have a prefix defined. I believe the solution is to define the prefix in the ebuild or make the symlink in the ebuild for mythtv.

Either way, I’m super-stoked! Now I can get back to encoding everything to something besides MPEG2 and watching it with mythtv instead of xine or mplayer.

Leave a Comment :, more...

Live TV Working

by on Jul.20, 2009, under Uncategorized

Searching continued for watching Live TV with Hauppauge HVR950Q and mythtv… Found mythtv mail-list post, from yesterday, about xc5000 and not being able to watch Live TV. My initial suspicions were correct. Firmware was taking way too long to load, supposedly about 7 seconds! That causes time-out and Live TV fails. I guess the timeout for recording is high enough that recordings work. When I set up the card initially I ticked the box to “Open DVB card on demand”. This means that when the backend isn’t using it the card is in “power off”, the tuner is not on, amber light is off, device is free for any program to grab it. Sounds great then if I want I can use mplayer to watch streams and the card will be off most of the time. So the solution is to untick the box. This loads the firmware when mythbackend starts and the card is left “power on” so that the firmware is only loaded once and not every time the backend wants to use the card. Good fix for now, but I might try tweaking the timeout settings so that I can retick the box. I’ll add an update for what I find out. Other good news, I successfully recorded 2 streams on the one device the other day. It seems like comcast has a large amount (over 10) of streams at 83.X so I should be able to record a lot of streams at once. Awesome!

On a separate note I was doing some updates and my xorg got screwy. At first it wasn’t working at all, after reinstalling ati-drivers and rebuilding xorg, banging my head on the wall, it worked. QT is messed up though, when I start mythfrontend fullscreen the screen is totally corrupted video playback is corrupted. Tried rebuilding mythtv to no avail. If I “mythfrontend –geometry 1438×898” it is almost fullscreen and not corrupted at all. Again, I’ll update when I find something out.

1 Comment :, more...

Hauppauge 950Q

by on Jun.28, 2009, under Uncategorized

So I got a Hauppauge HVR 950Q cause Comcast is supposed to be switching to all digital in the very near future. That means my wonderful PVR 500 will become horrible obsolete, though it has served me very well and I wish I would have gotten it sooner. I had made sure that it was supported in Linux before I bought it. It wasn’t horribly difficult to setup, but I’ll add some links here and some tips.

It is a DVB (digital video broadcast) device though it has an analog tuner. A quick look at linuxtv.org shows that it is supported as of kernel 2.6.26. Furthermore, there are nice instructions on their wiki. All I had to do was enable dvb and the xc5000 in the kernel, I made them modules cause then I didn’t have to reboot, extract some firmware and voila! Not! It turns out that the kernel version of the xc5000 I was running complained about the firmware version. Specifically, dmesg was spitting out errors close to:

xc5000: waiting for firmware upload (dvb-fe-xc5000-1.6.114.fw)…

And then complaining that the file could not be found. Bummer, where was I supposed to get firmware 1.6.114? Shouldn’t the linuxtv wiki have a link to the newest firmware? Maybe steventoth has it on his website in the xc5000-untested directory? The answer to all of these is No. Well, except the first one and the answer is: http://www.kernellabs.com/firmware/xc5000/dvb-fe-xc5000-1.6.114.fw Apparently, the guys at Xceive says it’s okay to distribute the binary firmware! Awesome, no more extraction scripts.

Next step, scanning channels and configuring mythtv. Sidenote, my database is still screwed up so I’m still running 0.21, thanks Gentoo! So, I went to their wiki and searched for Comcast. It seems that somebody has hashed all this out already here. Download the scte65scan tool and follow the instructions. Namely, do the scan and look at the output. I had 2 VCT_IDs 3013 and 0. 3013 seems right according to the wiki page and 0 just sounds weird. This should give you an idea of what channels you have available. Next go to schedulesdirect.org and setup a new lineup or edit your current one if you have been using a digital box/analog capture device. Using the output from scte65scan select the correct channels. Now, I could be wrong about the exact order here, but you need to know the sourceid for the new lineup. So, setup the 950Q in mythtv-setup and select your new lineup as the source. Don’t worry about channels we do that next. You need the sourceid because the scte65scan outputs sql code that includes the sourceid so if you set it incorrectly you could screw up your analog channels, from a different “source”.

Drop into mysql:

~# mysql -u mythtv -p

use mythconverg;

select * from videosource;

If you have given your new source a nice name like “comcast-digital” it’s easy to see that the new sourceid=2

Next rerun the scte65scan using your VCTID and -f3,2 because my sourceid=2 if yours is 5 use -f3,5. The README file that comes with scte65scan explains most of this. Oh, right you did “mysqldump -u mythtv -p mythconverg > myth.backup” right? Good. Now we have an sql file that has all of the channel info we need. Following the instructions bring it into your database. That should be it, run mythfilldatabase and all should be well.

I have no problem recording channels, but when I try to “Watch TV” it doesn’t tune. I think it might be that it is trying to tune a frequency that doesn’t have a channel, but I have tried after I recorded something so the frequency should be right. Mythtv kinda remembers what frequency/channelĀ  it was last set to or more likely the hardware is still set to that frequency. Anyway, mplayer can play the dvb stream no problem so I can watch “live-tv”. I guess I’ll save that mystery for another day.

Updated link for 1.6.114 firmware. Thanks Devin!

1 Comment :, , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Blogroll

A few highly recommended websites...