MythTV/Extras

From Wikibooks, open books for an open world
Jump to navigation Jump to search
MythTV
Introduction | Getting Started | Installing | Extras | Troubleshooting | Conclusion


Once MythTV is mostly running (i.e.: you're able to pause, record and play TV), then you can start tuning your system to do exactly what you want. The possibilities are endless, but there are a couple of things you'll probably want to tweak.

Remote control[edit | edit source]

For your remote control to work, LIRC must be loaded. Thus, in one of your boot scripts, you should have:

/sbin/modprobe lirc_i2c

This loads the lirc_i2c kernel module. Thereafter, you can configure your remote using the "/home/mythtv/.lircrc" file (which is actually a symbolic link for "/home/mythtv/.mythtv/lircrc"). Inside this file, you will find a bunch of statements like:

begin
   prog = mythtv
   button = Power
   config = Esc
end

These statements should be self-explanatory. The "prog = mythtv" tells LIRC that this command should be bound to the MythTV application. The "button = Power" tells LIRC that when the "Power" button on the remote is pressed, this command should be issued. The "config = Esc" tells LIRC what command to pass along to the application. So when I press "Power" MythTV will receive the "Esc" signal (a convenient mapping, since then you can use the power button to exit from MythTV). You can set these mappings up however you like. To find out what names are allowed for your particular remote, go to the documentation provided with LIRC (created when you untarred the LIRC source). For instance:

$ cd /home/mythtv/lirc-0.7.1/remotes/hauppauge/
$ emacs lircd.conf.hauppauge

Obviously you should navigate to the documentation appropriate for your remote. In the end, your lircrc file should have a bunch of begin/end statements (one for each button), which are bound to MythTV functions in a way you like. If your MythTV installation went well, there are probably already some smart defaults loaded.

To make proper use of specialty buttons, you can set key bindings. In MythWeb's settings mode you can set additional key bindings (such as using F2 to launch MythWeather directly, for instance). Then in LIRC you can set a remote button to that same key.

When using MythVideo and MythDVD, mplayer is called to show video. If you want your remote control to work with mplayer, then you can set additional bindings for mplayer. The bindings might look like:

begin
   prog = mplayer
   button = Vol+
   config = volume +1
   repeat = 2
end
begin
   prog = mplayer
   button = Vol-
   config = volume -1
   repeat = 2
end

The program is now "mplayer." The allowed keys are the same as before (find the doc for your remote). The allowed "config =" lines are based on the commands that mplayer knows. Type "mplayer -input cmdlist" for a list of commands that are allowed, and then bind the ones you want. Note that the "repeat = 2" command controls what happens when a button is held down. That is, changing this number will control how quickly the button will repeat when held (a low number repeats fast, a high number is slow). You can play with these settings to suit your fancy. You can also find samples online of other people's settings, for inspiration.

LIRC Config is a free tool that creates custom lircrc's online.

Control set-top box with MyBlaster[edit | edit source]

If you have a set-top box that you want to be able to control from within MythTV, you have several options. Many types of IR blasters (whether purchased or home-built) can be controlled using the LIRC program already described.

If you're using My.Tv's MyBlaster product, then here's what you do. First of all, note that My.TV only guarantees that the serial version of their product will be compatible with linux. You can view their instructions or go to the forum for help. Another user of MythTV has written Perl module that lets us easily interface the MyBlaster product. So first you should download the MyBlaster14.zip file from somewhere. Inside the zip file, you'll find documentation for a variety of devices (TVs, satellite boxes, etc.). Find your device type and brand, and you'll see a bunch of codes that might work for your device. So next let's test to see which code works. Let's put the MyBlaster.pl perl script into "/usr/local/bin" (as root):

# cp MyBlaster.pl /usr/local/bin

Now edit this file in your favorite text editor. Change the "$Device_Type=" to your device type. Now change the "$remote_code=" to one of the codes suggested for your brand. Save the file and exit. Now turn on your set-top box (or TV, or whatever), and point your IR blaster product at the box, and type:

# MyBlaster.pl power

This will tell the product to send the signal for "power on/off". If your box turns off, then obviously the code works for your model. If nothing happens, edit the script again, and try a different code. Eventually you'll find the code that works for your product. Then inside mythtvsetup you can change the "external channel change comamnd" option to be "/usr/local/bin/MyBlaster.pl". Now everytime MythTV wants to change channel (for that video source), it will call MyBlaster.pl, and pass the channel number as an argument. You can restart your lirc module and try it in MythTV. When you change channel, you should indeed see your set-top box change channel (remember to point your IR blaster at the device!). An alternative less expensive option is available from Mythblasterz.

Control other devices[edit | edit source]

You can in fact use your whole setup to control multiple devices, such as your set-top box and your TV (and VCR, etc.). All it takes is some imagination and time modifying the right scripts. A useful option to be aware of is setting "prog = irexec" inside your ".lircrc" file. Here's a trivial example: let's say we modify our "/home/mythtv/.lircrc" file to contain

begin
   prog = irexec
   button = Power
   config = echo "Hello world!"
end 

If you save these changes, and then run "irexec" from a command line, you should see "Hello world!" output to the prompt every time you press the "power" button on your remote control. The irexec program lets us execute arbitrary shell commands using any key on the remote. The only catch is that the irexec program has to be running. You can easily arrange for this to be the case by, for instance, adding "/usr/local/bin/irexec &" to your "/usr/local/bin/start-ivtv" script (the trailing & tells the command to be placed into the background).

Now we can get a little more clever. Let's say our remote buttons are mostly bound to MythTV, and we are using the "MyBlaster.pl" program to control our set-top box. Now say we further want the "power" button on our remote control to turn the television on and off (but not turn off the set-top box!). Here's what we could do. First, let's make a copy of MyBlaster.pl:

# cd /usr/local/bin
# cp MyBlaster.pl MyBlasterTV.pl

Now find the device code for your TV in the MyBlaster documents (figure out which one is the right code, as before, by modifying the file and trying "MyBlasterTV.pl power" until the TV turns off). Once your MyBlasterTV.pl file is controlling the TV, you can edit your .lircrc file and add:

begin
   prog = irexec
   button = Power
   config = MyBlasterTV.pl power
end 

When you press the power button on your remote, the LIRC daemon (lircd) will pass the command to "irexec" which simply executes "MyBlasterTV.pl power" which should send a signal to your IR blaster that fools your TV into turning off. Obviously you can map buttons on your remote to all sorts of different scripts. In this way, you can control a wide variety of AV equipment.

Changing channels faster[edit | edit source]

New users of MythTV are usually quite annoyed with how slowly it changes channels, especially if you're using a set-top box. MythTV is constantly buffering live TV. This is what allows you to pause and rewind at will. However, this also means that you're always 4-5 seconds behind live television. So, if you want to change channel, there's always a delay while buffering of the new channel starts. If you're using an IR blaster to control a set-top box, then there's an additional lag due to that. Can anything be done?

You can (slightly) optimize the channel changing of a set-top box. If you're using the MyBlaster script, you can optimize it. First off, in the "/usr/local/bin/MyBlaster.pl" file you can enable the finalize option by setting "$finalize=1;", which will cause the blaster to send a keystroke to immediately confirm a channel change. For most remote controls there is a "select" or "ok" button that does this, so set that in the "$finalize_key=" section. You can also try editing the "Emit_Time=0.333;" option. This is the time that each keypress IR signal lasts. By reducing this, key entry will be faster. Don't reduce it too much, however, or else keypresses will be lost. You can adjust this value and see what happens. Modern set-top boxes seem to be able to handle "Emit_Time=0.2;" without much trouble. The "$inter_key_delay=1;" option can also be changed. This is the time in between key pulses. As usual, too low a setting and your box will become confused. The default 1 second is safe, but many boxes can handle 0.2 seconds without trouble. These options can make channel switching faster.

Ultimately, however, you won't be able to get rid of that last 4 seconds of buffering delay. This leaves you with two options. First, you could set up your TV so that a live signal from your set-top box goes straight to your TV, and another signal goes to your MythTV. Then you could switch between "live mode" and "myth mode" by changing the input selection on your TV. This requires some user intelligence, however, because you might be changing channels while MythTV is trying to record something, thereby ruining that recording.

Another option is to just adapt! Most users of MythTV find that after awhile they give up the whole "channel surfing" habit, as it is mostly a relic of not being able to find anything interesting on TV at any given moment, or being bored by commercials. With MythTV, you'll hopefully only be watching recorded shows that you like, and you'll watch them when it suits you. When you sit down to watch TV, you'll just look at the listing of recently recorded shows, and watch something that interests you. Not only that, but you'll just use the auto-commercial-skip feature to avoid boredom. Give this new paradigm a chance, and you may find that the need to compulsively change channels will disappear.

MythWeb[edit | edit source]

If your MythTV installation went well, then MythWeb is probably already running perfectly. On your MythTV box, open a web browser and go to "http://localhost/mythweb/" (or "http://127.0.0.1/mythweb/"). Don't forget that trailing slash, or you'll just get a "page not found" error! If you can see your MythWeb, then all is well. Refer to the next section for information on making it accessible worldwide on the internet. If you can't see your MythWeb, then you should probably look into the options for apache, the web server that is running your MythWeb (note that the apache process/service is called httpd or httpd2 depending on your version). To modify the behavior of your MythWeb, you are meant to modify the files:

/var/www/html/mythweb/.htaccess
/var/www/html/mythweb/config/conf.php

These documentation also suggests that you add the option "UseCanonicalName on" to your apache configuration file, located at: "/etc/httpd/conf/httpd2.conf" However, the default is "on" in modern versions of apache, so adding this directive is usually not necessary.

If you have problems seeing your MythWeb page outside of your local network, then it may be that your ISP is blocking the default http port (80). You can work around this by running MythWeb on another port (anything greater than 1024, like, for example, 8050). Remember to adjust any router settings for port forwarding as well. See elsewhere in this document for more help on that.

If you have problems seeing your MythWeb page inside your local network, but can see it outside, then probably your router is not passing internal requests properly. One easy fix is to use your MythTV's internal IP address inside your network (instead of using the domain name that you would use outside of your home network). You may want to set your MythTV to use a static IP address if you do this. You may also be able to fix this by adjusting router settings (but probably not). Alternately, you can buy a router that does port forwarding properly (Cisco routers have been reported as being a good choice in this regard).

Dynamic DNS[edit | edit source]

MythWeb allows you to access your MythTV over the internet. However, to access your MythTV from outside your house (work, vacation, etc.), you need your computer to act as a web server. Linux makes running a web server easy. A program called Apache (which runs as "httpd") will do everything for you. If you've installed MythTV and MythWeb properly, then apache is already running.

However, if you connect to the internet with an ISP that uses DHCP, then you're probably assigned a random IP from a pool. This means that your IP address will change periodically. This is called having a "Dynamic IP address." With your address constantly changing, how will other computer know where to reach your MythWeb?

The solution is to use a DNS service that updates when your IP addres changes. Luckily, there are numerous free subscription services that will let you do this with linux. The most well-known appear to be no-ip.com and DynDNS. An extensive list of options is available. Pick the one that suits you! Most of these services will allow you to pick the domain name from a short list, and then will map your username onto that. So if your username with their service is "user155" then you may end up with a domain like "user155.no-ip.com" or whatever. Then you can get to your MythWeb anywhere. It's address will be: http://user155.no-ip.com/mythweb/

If you have registered your own domain, you can point a custom subdomain to your myth box even if it has a dynamic IP. Once you have established that user155.no-ip.com points to your box. Add a cname record to your "myMostFavoritestDomain.com." DNS zone that points mythtv.myMostFavoritestDomain.com. to user155.no-ip.com. Make sure you end the domains with a dot. Otherwise it appends the name of the dns zone to the name you specify. eg: in the DNS zone entry for myMostFavoritestDomain.com. a record like "mythtv.myMostFavoritestDomain.com cname user155.no-ip.com" actually points "mythtv.myMostFavoritestDomain.com.myMostFavoritestDomain.com" to "user155.no-ip.com.myMostFavoritestDomain.com" which is not desirable.

You may have to play with port options in Apache if your ISP blocks port 80. Refer to other help in this document for details. These services will provide you with a program that runs on your linux box. Whenever its IP address changes, it will update the service, so that DNS lookups always get sent back to your current IP address. It's an easy (and cost-effective) way to get your own (semi-customized) domain name. If you want a full-featured domain name, you can upgrade your service easily.

DVD menus[edit | edit source]

By default, MythTV uses mplayer to play DVDs. However, mplayer doesn't support DVD menus. You could try installing xine instead, and configuring MythTV to call xine instead (see xine man page for command line syntax).