Sheeva Plug as a MythTV master backend
MythTV is an open source DVR program that is, I think, every bit as good as TIVO. After I heard about the Sheeva Plug, I have been thinking of ways to incorporate it with my MythTV machine. Now that I had the Sheeva Plug for a while and had a chance to determine what it can and cannot do, I came up with the best way of splitting MythTV into different tasks. The way I split the MythTV is base on my personal use pattern and how I have everything wired up in my home so this may not be the best setup for you.
Here's my original setup:
+-------------------+ | Shuttle C2D T7700 | | (Mythbackend) | <-- HDMI/VGA --> [Big TV] | (Mythfrontend) | | (Mythweb) | | (Samba/NFS) | <-- 1G Ethernet --> [PC] <--> [Bedroom TV] | (Mysql) | +-------------------+
That is the most likely setup for people starting out with MythTV. Another popular setup is to have a separate Mythfrontend connected to the TV and hide the Mythbackend somewhere else. As you can see from the diagram, I separated out 5 different functions you need to run MythTV. You could, potentially, run all 5 functions on different machines connected over the Internet and it will still work.
- The recorder daemon that takes the video stream from the TV tuner card and store it on a storage device. Mythbackend communicates with mysql to figure out when to start recording and needs access to a storage device (local disk or network shared disk).
- The user interface that plays the video on the screen or a TV. Mythfrontend communicates with mysql to get the video's information such as name, showtime, channel information. It also need to access the same storage device used by the Mythbackend to store the video.
- Web interface that allows you to set recording time over the Internet. It has other functions such as channel listing, delete recordings, Stream video. Mythweb needs to run on a computer that has apache installed and also need access to mysql, mythbackend and the video storage.
- Network storage server accessed by Mythbackend, Mythfrontend and Mythweb. You don't need to have this service if all three Myth functions are on the same computer and used the local storage.
- Database that holds channel information, video information and recording times.
Sheeva Plug and MythTV
The Sheeva Plug's low power, silent, always on capability is a perfect fit for a MythTV device. This chart shows the original setup draws 8 times more power on idle than the Sheeva Plug could possibly draw with everything running. So with the goal of reducing power consumption without sacrificing functionality, the question really is how to best run MythTV on the Sheeva Plug. Here are two ideas most often seen on the forums.
Sheeva Plug as the frontend
Using the Sheeva Plug as the frontend sounds like a good idea. After all, it's fanless and therefore quiet. However, you need to add a USB video out and a USB audio out to make the frontend work. Both functions "should" work but I have not heard confirmed reports of someone actually doing it. Also, the SheevaPlug is too slow to decode high resolution video and you can forget about x264. If you want a separate Mythfrontend, I suggest a netbook or any of the other Atom base computers. Those computer usually come equip with video and audio output and are very quiet. It is a little more expensive than the Sheeva Plug but not much more especially if you add in the extra USB video/audio outs you'll have to buy.
Given enough time and effort, the Sheeva Plug may be an ok frontend for SDTV. There are better options like fitPC2 that has build in HDMI and audio out. I can't see a very good reason of using the Sheeva Plug in this manner.
Sheeva Plug as the backend
Sheeva Plug as the backend is a more attractive option. There are only a few things stopping me from running the entire Mythbackend on the Sheeva Plug.
The first problem is the kirkwood CPU. It does not have hardware floating point and is too slow to handle software encoding. This means that any TV tuner (and it must be USB) must do hardware encoding AND it must be supported by MythTV. That is not very easy to find. For the adventurous, here is the list of TV tuners supported by MythTV in some fashion.
The second problem is the MythTV package is broken in the repository. If you tried to
You will get
Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: mythtv: Depends: mythtv-frontend (= 0.21.0+fixes19961-0ubuntu8) but it is not installable Depends: mythtv-backend (= 0.21.0+fixes19961-0ubuntu8) but it is not installable E: Broken packages
So you will need to compile your own until the repository is fixed. It is not very difficult but it is time consuming.
Finally, I already have an external harddrive connected to the only USB connector available. I do not want to hook up a USB hub, which likely have to be powered, to the Sheeva Plug so that I could plug in both the external harddrive and the USB tuner. This only affects the look of the Sheeva Plug, and might not matter to other people.
To be fair, none of the things I've listed are show stopper problems. The Sheeva Plug will do software encoding on some level of video resolution. Also there are USB tuners with hardware encoders like this from Hauppauge. The problem with the HVR1950 is that it doesn't look like it is currently supported by MythTV. But that will change, and eventually the HVR1950 will be supported. Same thing with the mythtv package in the repository. It will only be a matter of time before it is fix and all one needs to do is
So I think the Sheeva Plug will make a great Mythbackend. The pieces are not there now, but it will be there soon.
Sheeva Plug as the alarm clock
Back to the goal of reducing power consumption. You can save a lot of power if the MythTV box turned itself on whenever it needs to record something instead of being on all the time. MythTV itself already have build in functions to do that. The first is to use the ACPI wakeup function to wake itself at a time specify by MythTV. This method writes an alarm time to the BIO's ACPI real time clock. I don't like this option because not all BIOS supports the standard alarm time. The second method is to use the MythShutdown program in conjunction with wake-on-lan. For that to work, you need another computer that is always on (like the Sheeva Plug!) and MythShutdown will send the wake up time to the always on computer expecting that the always on computer will send the wake-on-lan magic packet when the alarm expires.
I've used the alarm clock method successfully for some time now with openWrt and a Linksys WRT54G in this configuration:
+-------------------+ | Shuttle C2D T7700 | | (Mythbackend) | <-- HDMI/VGA --> [Big TV] | (Mythfrontend) | | (Mythweb) | <-- 1G Ethernet --> [PC] <--> [Bedroom TV] | (Samba/NFS) | | | (Mysql) | +-> [Linksys running openWrt] +-------------------+
At night, the MythTV box sends the wake up time to the Linksys router and then powers off. When the alarm expires, the Linksys router sends a wake-on-lan command to the MythTV box to wake it up. The MythTV box then updates the database with new listing information. That system worked well enough, and I was able to port the wake up function of the Linksys to the Sheeva Plug easily.
Now that I have the Sheeva Plug working as an alarm clock, it is time to move more functions from the MythTV box onto the Sheeva Plug. I was never able to do this before because the Linksys WRT54G is very limited in terms of hardware. But with the Sheeva Plug, it was time to try something new.
Sheeva Plug as the master backend
The purpose of all this is to reduce power consumption while not sacrificing functionality. It that respect, the alarm clock method failed on several accounts:
- Mythfilldatabase may not run for a long stretch of time. The only time it runs is when the MythTV box is powered on. It is possible to miss changes to the channel listing because it was not able to get the updated data.
- No easy access to MythWeb. You need to turn on the MythTV box remotely whenever you want access to MythWeb to schedule new recordings from the Internet.
- Separate MythFrontends attached to the local network cannot access recorded shows unless the MythTV box is powered on.
To address those problems, I restructured the setup as follows:
+-------------------+ | Shuttle C2D T7700 | <-- HDMI/VGA --> [Big TV] | (Slave backend) | | (Mythfrontend) | <-- 1G Ethernet --+--> [PC] <--> [Bedroom TV] +-------------------+ | | +-------------------+ | | Sheeva Plug | | | (Master backend) | | | (Mythweb) | <-- 1G Ethernet --+ | (Samba/NFS) | | (Mysql) | +-------------------+
The new setup has the Sheeva Plug as the master backend with the recording functions done on the slave backend. Since the backend is running all the time, all Myth functions can be access by separate frontends as well as Mythweb. The Sheeva Plug must still act as an alarm clock to the slave backend because the Sheeva Plug does not have a capture card attached.
Setup MythTV database on the Sheeva Plug
First install mysql on the Sheeva Plug with
apt-get install mysql-server mysql-client
Make sure you remember the root account's password as you'll need it to create user accounts. Edit /etc/mysql/my.cnf and change the line that say:
bind-address = 127.0.0.1
bind-address = <Sheeva Plugs's IP address>
so that mysql is binded to local network address instead of just itself. Restart mysql with
mysql -u root -p < mc.sql
The command will ask for your mysql root password, if you didn't create a root password, leave out the -p argument. The mc.sql script will create the database mythconverg and grant access to mythtv@localhost. You will need to create the mythtv database user, log in to mysql as root:
mysql -u root -p
at the mysql prompt, type:
mysql> use mysql; mysql> insert into user (host,user) value('%','mythtv'); mysql> set password for 'mythtv'@'localhost' = password('newpassword'); mysql> flush privileges; mysql> quit
We should test the setup, log in to mysql locally as mythtv and verify that you can access the mythconverg database:
$ mysql -u mythtv -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 496 Server version: 5.0.75-0ubuntu10 (Ubuntu) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> use mythconverg Database changed mysql> show tables; Empty set (0.00 sec) mysql> quit Bye
The mythconverg database is empty, which is what we expect. The mc.sql script only allow localhost access to the database, so we need to change that. I will allow access to mythconverg from my local network (192.168.1.xxx), you may need to tighten or loosen the restrictions base on your usage.
$ mysql -u root -p mythconverg mysql> grant all on mythconverg.* to mythtv@'192.168.1.%' identified by 'same_password_as_before'; mysql flush privileges;
Test the remote connection and verify that you can connect to the database. From the remote computer, type:
$ mysql -h <SheevaPlug's IP> -u mythtv -p mythconverg mysql> show tables
The result should be the same as the local test. If instead you get something like:
ERROR 1045 (28000): Access denied for user 'mythtv'@'192.168.1.2' (using password: YES)
Then there is a setup error. It could be you didn't enable mysql network in /etc/mysql/my.cnf or that you didn't setup the privileges correctly for the mythconverg database. In any case, remote access must work before you continue.
Setup the network storage
I suggest using NFS as the protocol for the network storage, it is the fastest network method I found and very easy to set up. The down side is that you'll need to recompile the kernel with NFS support. In my case, I store all my recordings in /public/recordings so that is my export point. Here is my /etc/exports file.
# /etc/exports: the access control list for filesystems which may be exported # to NFS clients. See exports(5). # # Example for NFSv2 and NFSv3: # /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check) # # Example for NFSv4: # /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check) # /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check) # /public/recordings 192.168.1.0/255.255.255.0(rw,sync,no_subtree_check,root_squash)
The trick to make this work is to make sure that the slave backend mounts the Sheeva Plug's /pubic/recordings at the same point in its local storage. So that from the point of view of the slave backend, /public/recordings is an NFS mount of the Sheeva Plug's /public/recordings. This way, the slave backend will store recordings in the network share storage. You likely want to make the slave backend mount the /public/recordings directory during boot up in /etc/fstab.
Compiling MythTV for the Sheeva Plug
Getting the Myth backend running on the Sheeva Plug is the hardest part of the guide. The problem is that the repository does not have a working backend. This is due in part to the hacks needed to compile MythTV-0.21 correctly. I have a separate page dedicated to compiling MythTV for the Sheeva Plug. Please follow it and come here when you have the backend running.
Setup the slave backend to use Sheeva Plug
I have the master backend running on the Sheeva Plug and the slave backend running on the Shuttle box. Normally, a master backend would have its own tuner attach and MythTV would use the master backend's tuner first before it invokes the slave backend. In my case, the only tuner I have is attached to the slave backend. So MythTV has to use the slave backend as its only recording device. MythTV supports such a configuration and it is describe in their advance backend configurations.
To create the setup that I have, you need to set up all the details of the master backend except the capture cards and input connections. Next, run mythtv-setup on the slave backend and set the Local Backend to the slave backend's IP address and the Master Backend to the SheevaPlug(running the master backend) IP address. Next setup the capture card and the input connections from the slave backend so that the master backend knows that the capture card is attached to the slave. Then exit and restart the slave backend. If done successfully, the slave backend should identify itself as such and connect to the master backend. You can check by looking at /var/log/mythtv/mythbackend.log, it should look like this:
2009-05-15 11:24:12.801 Using runtime prefix = /usr 2009-05-15 11:24:12.814 Empty LocalHostName. 2009-05-15 11:24:12.815 Using localhost value of hobbes 2009-05-15 11:24:12.820 New DB connection, total: 1 2009-05-15 11:24:12.839 Connected to database 'mythconverg' at host: 192.168.1.30 2009-05-15 11:24:12.841 Closing DB connection named 'DBManager0' 2009-05-15 11:24:12.964 Connected to database 'mythconverg' at host: 192.168.1.30 2009-05-15 11:24:12.966 New DB connection, total: 2 2009-05-15 11:24:12.982 Connected to database 'mythconverg' at host: 192.168.1.30 2009-05-15 11:24:12.988 Current Schema Version: 1214 Running as a slave backend. 2009-05-15 11:24:13.003 New DB connection, total: 3 2009-05-15 11:24:13.126 Connected to database 'mythconverg' at host: 192.168.1.30 2009-05-15 11:24:13.911 Main::Registering HttpStatus Extension 2009-05-15 11:24:13.913 mythbackend version: 0.21.20080304-1 www.mythtv.org 2009-05-15 11:24:13.914 Enabled verbose msgs: important general 2009-05-15 11:24:14.923 Connecting to master server: 192.168.1.30:6543 2009-05-15 11:24:14.925 Connected successfully
Setup a separate Mythfrontend
The frontend uses the same ~/.mythtv/mysql.txt file as the backend to locate the mysql database on the network. In my case, my slave backend and frontend is on the same machine so the frontend "just worked". If you have a separate frontend, make sure to edit the file ~/.mythtv/mysql.txt on the frontend to point to the Sheeva Plug. Also make sure to create the nfs mount /public/recordings on the frontend if it is separate.
After that, configure the frontend like you would normally and everything should work. Test out your new setup by looking at the channel listing and schedule a few recordings. Things should work as they should.
Setup Mythweb on the Sheeva Plug
Thankfully, Mythweb is part of the official repository and it actually works. To install Mythweb, simply:
apt-get install mythweb
There should not be any more setup require because Mythweb is running on the SheevaPlug as the database. In my case, Mythweb installed and I could log in and see all my listings and recordings without making any changes. One thing that troubled me was how Mythweb could have known my mythconverg password. After some digging, I found that Mythweb is smart enough to pull the database password from /etc/mythtv/mysql.txt. That file is created after you run mythtv-setup from the Sheeva Plug. So if you didn't run mythtv-setup, then you will need to tell Mythweb about your database password in the file /var/www/mythweb.conf.apache.
The last thing to setup is the alarm to wake up the slave backends. There seems to be support on the master backend to wake up slave backends but it is not clear to me when that happens. For example, I like to wake up the slave backend 20 minutes before the schedule recording just in case the slave decides to do a fsck during boot. So I wrote my own alarm clock in python that calls libmyth-python. It is a simple script that figures out the start time of the next schedule recording and sends a WOL magic packet to the slave 20 minutes before show time.
You can get mythalarm here. You will also need libmyth-python.
apt-get install libmyth-python
Here is the help screen for mythalarm:
mythalarm -[vsim] -v: verbose -s: simulate, do not actually send the wake-on-lan magic packet -i: IP address if wake-on-wan (name or xxx.xxx.xxx.xxx) -m: MAC address of the remote machine (xx:xx:xx:xx:xx:xx) -t: number of minutes to set the alarm before the recording time (default 20) ex: mythalarm -m 11:22:33:44:55:66 wake up machine 11:22:33:44:55:66 on local network 20 minutes before the next schedule recording. ex: mythalarm -i computingplugs.com -m 11:22:33:44:55:66 -t 10 wake up machine 11:22:33:44:55:66 via wake on wan on computingplugs.com 10 minutes before the next scheduled recording.
I have mythalarm in a cronjob that runs every 5 minutes.
Did you find this page useful?