$Id: recycled-machine-mythtv.html,v 1.8 2005/12/30 02:03:10 root Exp $
The purpose of this web page is to document how to get MythTV working on a low-end computer. In my case, my brother gave me his old HP Pavillion 4445. I remember bringing this poor computer home. It was a stowaway on the trip home from my parent's house (where this computer is in mothballs). When we got home (a two-hour drive) my wife wasn't amused. Well, now it's serving a good purpose.
Updated (12/8/2005): The last weekend I decommissioned the old Celeron in favor of a 550-MHz P3 I got as a hand-me-down from a co-worker. Thank you, Chad. The experience has made me come to realize that some of the stuff in this guide is desperately out of date. I'm going to try to make some updates over the next couple weeks to bring this document up to speed.
The main page for MythTV is www.mythtv.org
Two documents really get you started with MythTV. The MythTV official documentation primarily consists of Installing and using MythTV. This document is intended to be Linux distribution agnostic. Unfortunately, my experience found that the effort required to get things running using these instructions and compiling everything from scratch is high. At times the documentation makes leaps that are hard to follow for those not completely knowledgeable of the ins and outs of Linux compilation. This especially holds true for getting the ivtv compiled and running. I spent 10 evenings whacking away with these instructions committed to running Debian Linux.
After reading about Jarod Wilson's
Fedora Myth(TV)ology page,
I read part of it. From there I was convinced that this was the way
to go. A downloaded the Fedora Core 2 CDs, burned them, gulped,
and started. That was Friday night. By Sunday night I had everything
running. Here's how I got from Friday night to a working
(and truly fun) MythTV box. The intent is to supplement what Jarod
wrote with what I had to do to get things to work.
This is what I have for hardware. Yes, the machine is really that under powered!
My Hardware
If you decide to go away from the released binaries and begin compiling objects from cvs code, 128 MB of RAM will leave your machine trashing during compiles. I broke down and bought two 128 MB DIMMs to replace the 64s. I'm now at 256 MB and can compile code without listening to the box suffer.
Getting Extra Memory
If you try to load the ivtv and ivtv-fb drivers on a machine
with limited memory, the driver may not load when you modprobe
them. You have to load the driver before memory is consumed.
The error message ivtv gives you doesn't make it all that clear exactly
what happened. The complaint (and I don't have the exact text here)
is something about GSArray.
A couple tricks I used was to kill off a bunch of unneeded services.
# /sbin/chkconfig --level 2345 cups off
# /sbin/chkconfig --level 2345 pcmcia off
In addition, edit /etc/inittab and change the initdefault to
runlevel 2. Doing this kills off NFS and KDE. KDE is completely
inappropriate for a computer like this. Use twm.
/root/.xinitrc
I know, other references say it's a bad idea to run mythtv as root, but this is a simple way to get everything to start and not have to worry about KDE.
twm &
sleep 4
cd /usr/share/mythtv
mythfrontend
/etc/rc.local
To start everything, I updated rc.local and added the following
lines to the bottom:
/sbin/modprobe ivtv
/sbin/modprobe ivtv-fb
/sbin/modprobe lirc_i2c
export HOME=/root
cd /usr/share/mythtv
mythbackend &
startx
/etc/ntp.conf
When I started the system, my ethernet card wasn't working.
As a result, ntpd didn't get started properly. Once everything
was running, I restarted ntpd. Below is the config file I used.
I live in Wisconsin, so the time servers are intended for local access.
A list of servers is available at the Internet Systems Consortium's NTP Web Page.
driftfile /etc/ntp.drift server ntp1.cs.wisc.edu server ns.nts.umn.edu server ntp-1.mcs.anl.gov server ntp3.cs.wisc.edu server ntp2.cs.wisc.eduTo get things running, here you go:
# /sbin/chkconfig ntpd on # /sbin/service ntpd start
Using straight CVS downloads of the code, there are a couple things that
one needs to do. First, before you run configure, I've added the line
PREFIX=/usrto the beginning of settings.pro. If you're
running Fedora Core and Axil Thimm's ATrpms originally, everything's set
to run out of /usr instead of /usr/local. In addition, I had to update
to use lirc and something else. I'll update my notes in the next
release. Other than that, you can do a CVS build to get new code.
I'll write a little more about how to update mythtv without whacking
previous versions later.
Configuring MythTV
Below is a table of how I have MythTV set up and some commentary about why things are the way they are. At this point I'm not through getting this finished. Where this is the case, I'll try to make a point of saying so. The CVS repository can be browsed at cvs.mythtv.org
| Utilities > Setup > General... | ||
| Audio Screen | ||
| Audio output device | /dev/dsp | I don't know if this is the default, but I don't remember why it's set the way it is. Largely, with a PVR-350, audio is streamed with the video stream on the way out. The audio output device is ignored (except perhaps for MythDVD, MythMusic, etc. -- which I haven't played with). |
| Enable AC3 to SPDIF passthrough | unchecked | Assumed the default. |
| Aggressive Soundcard Buffering | unchecked | Assumed the default. |
| Use Internal Volume Controls | checked | Assumed the default. |
| Mixer Device: | /dev/mixer | Used |
| Mixer Controls | PCM | Assumed the default. |
| Master Mixer Volume | 100% | I turned this up because recording were coming out too soft. 100% may be a bit too high though. |
| PCM Mixer Volume | 100% | I turned this up because recording were coming out too soft. 100% may be a bit too high though. This is probably the right place to adjust volume. |
| Independent Muting of Left and Right Channels | unchecked | Assumed the default. |
| General Screen | ||
| System Exit Key | No exit key | Once you get your system configured, remove the system exit key. That way if you hit the red key and you're already at the top (main) menu, MythTV won't prompt you to exit the system. |
| Halt command | halt | Assumed the default. |
| Keypress Application | <blank> | Assumed the default. |
| Use Arrow Key Accelerators | checked | Assumed the default. |
| Require Setup PIN | unchecked | An interesting idea to keep things from getting messed up by my 3 year old, but so far he hasn't messed with it. |
| Setup Pin Code | <blank> | Used for above. |
| Monitor CD/DVD | unchecked | This may be useful. I don't have CD/DVD playing working yet. |
| Enable Xbox Hardware | unchecked | Obviously doesn't apply here. |
| Myth Database Logging | ||
| Log MythTV events to database | checked | This is unchecked by default (I don't know why). Having this checked allows the TBD screen to properly bring up events. Check this. |
| Log Print Threshold | All Messages | I like logs. Suit yourself. |
| Automatic Log Cleaning Enabled | checked | But, I hate to clean things up myself. |
| Log Cleanup Frequency (days) | 7 | My preference. |
| Number of days to keep acknowledged log entries | 14 | My preference. |
| Number of days to keep unacknowledged log entries | 30 | My preference. |
| Maximum Number of Entries per Module | 100 | Assumed the default. I think. |
| Mythfilldatabase | ||
| Automatically run mythfilldatabase | checked | I live in North America and use zap2it. (Thank you zap2it for being generous to the open source community. We appreciate it!) If you don't use zap2it, I don't know if this should be checked. |
| mythfilldatabase Path | mythfilldatabase | Assumed the default. |
| mythfilldatabase Arguments | <blank> | Assumed the default. |
| mythfilldatabase Log Path | <blank> | Assumed the default. |
| mythfilldatabase Run Frequency (Days) | 1 | Assumed the default. |
| mythfilldatabase Execution Start | 2 | Run mythfilldatabase somewhere between Start and End -- here between 2 and 5 AM. This is so zap2it's servers don't get crushed by people looking to fill their databases all at 3:05 AM. Keep this as wide as you can. |
| mythfilldatabase Execution End | 2 | See above. |
| Utilities > Setup > Appearance... | ||
| Theme | ||
| Theme | G.A.N.T. | This is personal preference. |
| Qt Style | Desktop Style | This is personal preference. I'm trying out Bluecurve to see what this does. |
| Font Size | Default | I'm using the default and haven't played with this. |
| Use a randome theme | unchecked | Seems self-explanitory. |
| Menu theme | Default. | I haven't messed with this. |
| Screen settings | ||
| Xinerama screen | 0 | I haven't messed with this. |
| GUI width (px) | 640 | This is a setting that works with the overscan of my Magnavox TV. |
| GUI height (px) | 424 | This is a setting that works with the overscan of my Magnavox TV. |
| GUI X offset | 40 | This is a setting that works with the overscan of my Magnavox TV. |
| GUI Y offset | 0 | This is a setting that works with the overscan of my Magnavox TV. |
| Use GUI size for TV playback | checked | I honestly don't know if I've changed this. |
| Run the frontend in a window | unchecked | I don't know what this does. |
| Localization | ||
| Set these settings to your taste. | ||
| QT | ||
| "Small" font: | 12 | I changed this to help eliminate overscan problems. |
| "Medium" font: | 16 | I changed this to help eliminate overscan problems. |
| "Large" font: | 25 | I changed this to help eliminate overscan problems. |
| Use Transparent Boxes | checked | While this requires more CPU, things seem to work fine here. |
| Popup Background Shading Method | Fill | I haven't messed with this. Trying image. |
| TV Settings | ||
| General | ||
| ...More to come later. | ||
To use native transcoding on a low-end CPU means delays. The time it takes to transcode a half-hour episode of a TV into a SVCD is measured in days (not hours or minutes). Whatever you do, you don't want to reencode video on a low-end box. So, the next thing I wanted to do was to be able to burn things from .nuv files to something that is DVD-compatible (or at least mostly so). This took a couple nights to figure out. The basic approach is outlined in section 21.18 of Installing and using MythTV. There are, however, a couple glitches.
First, the current version of MythTV with published binaries is 0.16. On-screen editing with this version hangs the front end. So, I needed to recompile the version in CVS (this is oh so much fun on a Celeron 367 with 128 MB of RAM...). In addition to that, I wanted to be able to do this from a command line (ssh-ed into the box).
Once everything was set up, here's the process I use to make a DVD of one show/episode/movie from my MythTV box.
There does seem to be some discussion elsewhere that 480x480 videos are not DVD standard compliant. While this may be true, of the three DVD players in the house, they all seem to take the input and run.
After a lot of fiddling around, I've found that the synchronization
with the steps listed above just isn't right. When you're running
mpeg2cut, it's calling lvemux. My version of
lvemux (lvemux-040322)
just doesn't seem to listen to the time shift command line option (-sh).
As a result, I removed both that command and the clean-up line out of
mpeg2cut. Instead, I've created a couple post-
nuvexport
processing scripts.
The first is mux.sh. This script creates an mpeg
file from what the hacked mpeg2cut generates. The way this script
typically works for me is to run nuvexport, then run:
./mux.sh *.mp2 *.m2v mympegfile.mpg
Once the mpeg is created you can run
dvdauthor -o DVD -f mympegfile.mpg followed by:
dvdauthor -o DVD -T
After that, follow the MythTV documents' instructions to create a
DVD found at the end of section 21.18.
To make things a little more automated, I created a script to do it all.
It runs like mux.sh but also does the dvdauthor work and the burning.
See mux+create+burn.sh below.
The above method seems to work pretty well. If, however, you're burning a longer recording, it may make sense to create DVDs that have chapters. This is explained to a limited extent in some of the dvdauthor documentation. I am just now beginning to mess with this. The next level of screwing around involves creating DVD menus. I think I'm halfway understanding the process outlined in the MythTV docs, but I'm having a little difficulty following along. Perhaps once I figure this out, I'll write something on this as well. I suspect if you're somewhat fluent in GIMP, this would be a snap.
Another place that seems to have some really good documentation that isn't seemingly well cross-linked is www.mythtv.info. Two links that seem like they have good content (but that I haven't explored very much) are the ArchiveRecordingsToDvdHowTo/ExternalLinks page and the ArchiveRecordingsToDvdHowTo.
I've been able to build DVD menus. The basis of this comes from section 21.20 of the MythTV docs. Some things I've learned include the fact that with TV overscanning, the main menu image needs to be cropped. On my TV, I've found that while the image I designed is 720 by 480, you can't see all of that. In the x axis, I can see from about 38 to about 664. On the y axis, I can see from about 47 to 446. So in the x axis, you loose about 5 percent on each side. In the y axis, you loose about 10 percent on the top and bottom.
I don't have toolame on my box. As such, creating the audio isn't possible as described. What I did instead was:
dd if=/dev/zero bs=4 count=2000 > zero.raw sox -r 48000 -s -w -c 1 zero.raw zero.wav mp2enc -b128 -r 48000 -o menu.mp2 < zero.wavThat gets you the blank audio you need without using toolame.
#!/bin/sh # # mux.sh # # Mux audio and video after nuvexport runs. # # See http://hawley.homeip.net/recycled-machine-mythtv.html#authoring # for more explanation. # # (c) 2004 Greg Hawley # # This script is derived from the MythTV documents. # # See 21.18 of http://www.mythtv.org/docs/mythtv-HOWTO-21.html # usage: mux.sh mp2file m2vfile mpeg_file START=`date` # The 150 millisecond shift is specific to a PVR-350 running # under MythTV. Your mileage may vary tuning this constant is # up to the user. nice -n 19 mplex -O +150ms -f 8 -V -o $3 $1 $2 END=`date` echo Started at $START. echo Ended at $END.
#!/bin/sh # # Mux audio and video after nuvexport runs. Then create and burn a DVD. # # See http://hawley.homeip.net/recycled-machine-mythtv.html#authoring # for more explanation. # # (c) 2004 Greg Hawley # # This script is derived from the MythTV documents. # # See 21.18 of http://www.mythtv.org/docs/mythtv-HOWTO-21.html # usage: mux+create+burn.sh mp2file m2vfile DVDdir START=`date` mkfifo dvdmpg # negative values shift video in front of audio # positive values shift video behind audio nice -n 19 mplex -O +150ms -f 8 -V -o dvdmpg $1 $2 & nice -n 19 dvdauthor -o $3 -f dvdmpg nice -n 19 dvdauthor -o $3 -T rm dvdmpg growisofs -Z /dev/cdrom -dvd-video $3 END=`date` echo Started at $START. echo Ended at $END.
I went off an figured out the MySQL query that MythWeb submits. As you'll see, it's a little ugly. From there, I created a little shell script that takes the results of the query and make a small web page. With that I created a crontab entry to automatically run the query daily building the web page I see. It's a bit of a hack, but it's also better than manually typing things into MythWeb.
First, below is the query. At the very end, you can see the stuff that really matters. Modify it as you see fit.
SELECT program.chanid, program.starttime, program.title, program.subtitle
FROM program
LEFT JOIN programrating USING (chanid, starttime)
LEFT JOIN record ON (
(record.type = 5 AND program.title = record.title AND
record.chanid = program.chanid AND
record.starttime = SEC_TO_TIME(time_to_sec(program.starttime)) AND
DAYOFWEEK(record.enddate) = DAYOFWEEK(program.endtime))
OR (record.type = 4 AND program.title = record.title)
OR (record.type = 6 AND program.title = record.title)
OR (record.type = 3 AND program.title = record.title AND record.chanid = program.chanid)
OR (record.type IN (7, 8) AND program.title = record.title AND
record.chanid = program.chanid AND
record.starttime = SEC_TO_TIME(TIME_TO_SEC(program.starttime)) AND
record.startdate = FROM_DAYS(TO_DAYS(program.starttime)))
OR (record.type = 2 AND program.title = record.title AND
record.chanid = program.chanid AND
record.starttime = SEC_TO_TIME(TIME_TO_SEC(program.starttime)) AND
record.endtime = SEC_TO_TIME(TIME_TO_SEC(program.endtime)))
OR (record.type = 1 AND program.title = record.title AND
record.chanid = program.chanid AND
record.starttime = SEC_TO_TIME(TIME_TO_SEC(program.starttime)) AND
record.startdate = FROM_DAYS(TO_DAYS(program.starttime))))
LEFT JOIN recordingprofiles ON record.profile=recordingprofiles.id
WHERE
(
(program.title LIKE '%heavy%metal%' OR program.subtitle LIKE '%heavy%metal%')
OR
(program.title LIKE '%buckaroo%' OR program.subtitle LIKE '%buckaroo%')
OR
(program.title LIKE '%cool%hand%' OR program.subtitle LIKE '%cool%hand%')
OR
(program.title LIKE '%shawshank%' OR program.subtitle LIKE '%shawshank%')
OR
(program.title LIKE '%battlestar%' OR program.subtitle LIKE '%battlestar%')
OR
(program.title LIKE '%modern%marvels%' OR program.subtitle LIKE '%modern%marvels%')
OR
(program.title LIKE '%megastructures%' OR program.subtitle LIKE '%megastructures%')
OR
(program.title LIKE '%doctor%who%' OR program.subtitle LIKE '%doctor%who%')
OR
(program.title LIKE '%columbo%' OR program.subtitle LIKE '%columbo%')
OR
(program.title LIKE '%bicycle%racing%' OR program.subtitle LIKE '%bicycle%racing%')
OR
(program.title LIKE '%repo%man%' OR program.subtitle LIKE '%repo%man%')
)
GROUP BY program.title, program.starttime ORDER BY program.title, program.starttime;
In addition, here's a script that runs the query. The -t option in the script makes the
results tabular. Adjust the file paths to whereever you put the script and the query text.
I had to do a lot of manual substitutions to make the less than and greater than signs
turn out in HTML. Be careful with the script below.
#!/bin/sh # # run_query.sh # # Run a manually generated mythtv query and generate a web page # with the results. # # See http://hawley.homeip.net/recycled-machine-mythtv.html#trolling # for more explanation. # # (c) 2005 Greg Hawley FILE=/var/www/html/results.html QUERY=/root/bin/foo2.sql echo "<html>" > $FILE echo "<head>" >> $FILE echo "<title>Quick MythTV Query</title>" >> $FILE echo "</head>" >> $FILE echo "<body>" >> $FILE echo "<h1>Quick MythTV Query</h1>" >> $FILE echo "<h2>Query Runtime</h2>" >> $FILE date >> $FILE echo "<h2>Results</h2>" >> $FILE echo "<pre>" >> $FILE mysql -t -u mythtv -pmythtv mythconverg < $QUERY >> $FILE echo "</pre>" >> $FILE echo "<h2>Query Text</h2> >> $FILE cat $QUERY >> $FILE echo "</body>" >> $FILE echo "</html>" >> $FILEThis whole mess can be automated to run on a daily basis. I chose 7:12 AM to run the script. Run
crontab crontabfile to load the cron entry. Check to
make sure you don't have a crontab already by running crotab -l
# add to cron with: # crontab crontab # check with: # crontab -l crontab 12 07 * * * /root/bin/runquery.sh > /dev/null 2>&1
describe program; to see
all the fields in a program record. Anyway, when I was done here's
how it turned out:
mysql> SELECT title, role, program.chanid, program.starttime
-> FROM program LEFT JOIN credits USING (chanid, starttime)
-> LEFT JOIN people USING (person, person)
-> WHERE name = "John Huston" ORDER BY title;
+--------------------+----------+--------+---------------------+
| title | role | chanid | starttime |
+--------------------+----------+--------+---------------------+
| Annie | director | 1055 | 2006-01-07 16:00:00 |
| Annie | director | 1055 | 2006-01-06 19:00:00 |
| The Asphalt Jungle | director | 1063 | 2005-12-29 05:00:00 |
| The Unforgiven | director | 1061 | 2005-12-28 20:00:00 |
+--------------------+----------+--------+---------------------+
4 rows in set (1.98 sec)
mysql>
Unfortunately, I'd really like to put a query like this into the
canned queries in mythweb (see mythweb/config/cannded_searches.php),
but I'm not sure how to do it. Still, it's an interesting exercise!
ivtvfbctl /dev/fb0 -alpha 0; mplayer -vo ivtv dvd://; ivtvfbctl
/dev/fb0 -alpha 255
Copyright (c) 2004-2005 Greg Hawley
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license can be found at www.gnu.org and is entitled "GNU Free Documentation License".