Complete guide to MythTV
1st May 2011 | 11:00
How to install, set up and use MythTV
Guide to MythTV: Installation and setup
MythTV is a little involved to set up, but worth the effort. It's more than a TV recorder - its plug-ins add plenty of extra functions, and the scripting interface means that you can do all sorts of clever things with it.
We'll look at installing and setting up MythTV, as well as how to use the various functions. We'll also deal with a number of the common questions that arise.
Let's start with the hardware. You'll need a computer, a means of receiving TV programmes and some storage. MythTV uses a server/client model. The server is known as the back-end and handles scheduling recordings, transcoding, advert flagging and so forth, while the front-end is the user interface. The front- and back-ends can be the same computer, but they do have different hardware requirements.
The back-end needs plenty of storage (once you get into MythTV, you'll find a terabyte to be a small amount of space), room for one or more TV cards and a reasonably powerful processor. In other words, a typical desktop computer - not the most attractive or silent addition to your living room.
The front-end needs a decent network connection and the ability to output video and sound to the TV. I use an Acer Aspire Revo nettop fixed to the back of my TV as a front-end, while all of the grunt work is handled by the back-end in the loft.
There are other advantages to having separate front- and back-ends. You can have multiple front-ends connected to one back-end, so all of your recorded content is available in each room. You can even start watching a programme downstairs and finish it in bed, because the back-end will remember where you're up to.
The type of TV receiver you need depends on your area. Much of the UK is now 100% digital and I use PCI DVB-T cards. DVB-T is terrestrial digital, known as Freeview in the UK. There are also DVB-S receivers for digital satellite, as well as various analogue cards.
The big advantage of the DVB formats is that they're broadcast as MPEG streams, so no encoding is necessary to record them to the hard drive. This reduces the amount of CPU power needed, which is important if you're running your front- and back-ends on the same machine, or want to make simultaneous recordings.
HD is another matter. While Freeview HD has been available in the UK for well over a year, there are still no DVB-T2 cards - and you can't receive HD on a DVB-T device. There are DVB-S2 cards available, so if you want HD you'll either have to get a dish or be patient. HD places extra loads on everything, so you'll need a lot more storage space, a faster network connection between front- and back-ends and a faster GPU on the front-end.
Installation and setup
There are three main ways of installing MythTV: compile from source, install packages from your distro's repository on to an existing Linux system or install a MythTV-enabled distro. We'll be working with the latter option, although you can still follow the rest of this if you go down one of the other routes.
Mythbuntu is basically Xubuntu with MythTV added and much of the other software removed. As such, it can still be used as the basis for a standard desktop, too, simply by installing a few extra packages.
We won't go through the details of installation, because it's just the familiar Ubuntu installer in a different colour. It will, however, ask you the type of installation you want. Normally, you'd choose a combined front-end/back-end, a primary back-end or a front-end - secondary back-ends involve more complexity than we've got space to deal with here.
Mythbuntu 10.10, the latest version at the time of writing, comes with MythTV 0.23, but we'll be using 0.24 for the rest of this feature, so your first step is to upgrade. Once you've booted into Mythbuntu, press Esc to exit MythTV, point your browser at www.mythbuntu.org/auto-builds and install the mythbuntu-repos package. The update manager will then install 0.24.
Once you have MythTV 0.24 installed, you need to set up the back-end by running mythtv-setup on it. In Mythbuntu, you can find this in Applications > System > MythTV Backend Setup. If you're using a separate back-end tucked away out of sight, you can use VNC to connect and run mythtv-setup - which means that the back-end will still need a desktop.
You can also use the following SSH command, which will run the setup program on the back-end, but display its window on your desktop:
ssh -Y user@mythbe mythtv-setup
1. Configure main options
Work through the seven MythTV sections one by one. The mouse won't be visible, but you can use the Up and Down keys to move between options and the Left and Right keys to change them. The help text for each item will be shown at the bottom of the screen.
2. Set your frequency
The most important items in the General settings are on the Locale page, where you set the TV standard and frequency table. These should be PAL-I and Europe West in the UK. If you don't know your region's settings, check MythTV's wiki.
3. Add capture cards
In the Capture Card Setup section, set the card type at the top - if you have multiple cards, repeat this, picking a different device each time. DVB cards appear under /dev/dvb, whereas most other types appear under /dev/video*.
4. Source video streams
You now need to set up a video source type - if there isn't already a DVB source present, create one. Attach each of your capture cards to a video source. You can also set up listings grabbing here, which may involve setting up an XMLTV file.
5. Scan for channels
The Channel Editor is where you grab the list of available channels. Select Channel Scan, make sure it's set to the correct region and leave it for a couple of minutes to do its stuff. You can edit the channel list later to remove any you don't want.
6. Direct your saves
Finally, you need to tell MythTV where to save your recordings, so specify one or more directories. If you choose multiple locations, it will use them according to available space and load balancing.
Gudie to MythTV: Basic usage
By now, you've installed MythTV, set up the back-end and should have the front-end displayed in all its glory. What do you do next?
If the front- and back-ends are separate, the first thing to do is tell them where to connect. You should automatically be asked to do this when you start up an unconfigured front-end, but if not, or if you want to change it, the setting is in Setup > General.
You'll need to set the hostname and three MySQL settings - the database name, username and password. The first two are unlikely to be anything other than mythconverg and mythtv. The password, plus the other two items, can be found in /home/mythtv/.mythtv/mysql.txt on the back‑end.
We'll refer to using a keyboard to control MythTV. A remote control is the usual method, but the remote buttons map to keys anyway - and keys are consistent, while each remote is different. We'll look at remote controls later.
Step by step: managing recordings
1. Keep it clear
To make everything stand out, these screenshots use the MythCenter-Wide theme instead of the Mythbuntu theme shown on the previous page. There are several themes available for MythTV, distributed either with the source or in the separate myththemes package. They can have widely differing layouts, but this one has a simple, clear appearance. Another that we like is the Arclight theme.
2. Start recording
We haven't recorded anything yet, so go to Manage Recordings > Schedule Recordings > Programme Guide, which will bring up your listings. The red buttons to the bottom-right of the programme listings indicate their recording status. Use the cursor keys to highlight a programme, then press R to record just that particular showing.
3. Record a series
If you press Enter instead of R, you'll get this following screen, where you can set various recording options. The top option is Record At Any Time On This Channel - in other words, a series record.
There are plenty of other options, including recording on any channel. This helps MythTV with scheduling, because it can record a repeat on, say, a +1 channel. MythTV records one showing of each episode by default, but you can alter this in the Schedule Options section of the screen.
4. Check for conflicts
Go to Manage Recordings > Upcoming Recordings to see what will be recorded. The red highlight and the message at the top-right show any conflicts. If a listing has an L to the right of it, this means that MythTV is recording a later showing of that programme (you can see it further down) to avoid such a conflict.
5. Sort your priorities
The Schedule Options for a recording rule have a priority setting. This won't avoid conflicts, but it does help MythTV to decide which programme to record and which to skip if you find that recording the Champions League game is going to clashwith your EastEnders fix.
6. Make your own rules
You don't have to use the programme guide to set up recordings - you can also use the Custom Recordings screen to create recording rules from scratch. This is useful if you want to record programmes that don't always have the same title, or to record all documentaries on Channel 4 that start between 8pm and 10pm, for example.
Guide to MythTV: Plug-in expansion
MythTV comes with a range of plug-ins and there are some unofficial ones linked from the wiki, too.
Of all the plug-ins, this is the one we use the most. It enables you to watch video files in just about any format from MythTV. All the standard formats are supported, and ISO images, too.
If you copy a complete DVD as an ISO image with cp /dev/dvd somemovie.iso and put this in MythVideo's directory, you can watch the entire DVD with menus and special features. Alternatively, you can use any of the popular transcoding programs to copy the main title to an AVI or MPEG file.
If you have the storage space, this enables you to have your entire movie collection available at the touch of a remote control button. MythVideo can also connect to IMDb to fetch information about the film and even a cover image to display in the browser screen.
MythVideo supports four parental levels and you can set a password for the higher ones, which is good if you have films that you wouldn't want your children to see. I move videos up to level two when I've watched them, so the default view is unwatched videos, with the rest being one button press away.
MythWeb is technically not a plug-in - you don't use it in MythTV. It's a set of PHP scripts to enable you to interact with your MythTV setup through a web browser. It means that you can view programme listings and set recordings from anywhere in the world.
Say you've just heard there's something good on tonight, but you won't be home in time to watch it. Whip out your smartphone, point the browser at your MythWeb setup and set it to record. You'll need a web server set up and running, and then you unpack the MythWeb archive into your Document Root. There's a .htaccess file included to ensure that Apache, or a compatible web server, acts as required.
There's one important change you should make if you intend to make MythWeb accessible from the internet: you must set up a user and password to restrict access. Your collection of Come Dine With Me episodes may not be private, but search engines run web spiders that follow all links on a site and MythWeb's recordings listing includes delete buttons in the form of links. You don't want Google deleting all your recordings inadvertently.
Do you remember those family gatherings as a child, when Uncle Harry would bring out his slide projector and 'entertain' everyone with his latest holiday snaps?
Even if you aren't old enough to have been subjected to such childhood traumas, you can now do the same yourself. A more positive spin is that it's possible for you to share your photos without everyone huddling around a laptop.
MythGallery is a photo gallery plug-in for MythTV. The first stop after installation is Setup > Media Settings > Images Settings, where you set the directory containing your photos. You can also enable various OpenGL-based transitions for slideshows if you have compatible video hardware.
The interface is fairly standard for photo-viewing software, with the emphasis being on the viewing. There are no real facilities for managing your collection; that should be done on your computer with the likes of DigiKam. The first time you enter a directory, there's a delay while MythGallery creates thumbnails of the photos, but these are cached for fast access next time.
The slideshows look good on a large TV screen, especially with some of the OpenGL Compiz-style transitions. If you have a digital camera, don't keep your photos hidden away on your hard drive - show them off with MythGallery.
If you're the sort of person who likes to build up a library of films, or other programmes, for watching in the future, you won't want your enjoyment to be interrupted by commercial breaks. MythTV has a couple of features that help with this.
The first is automated commercial detection. You can set this to run automatically after each recording in Setup > TV Settings > General or on a per-recording basis. You can also run it manually on individual recordings.
The commercial detection routines can be a bit hit and miss on UK channels, so it's worth experimenting with them to see which technique works best for you (bear in mind that some are quite processor intensive). The mythtv‑setup channel editor enables you to set different detection methods for channels, including no detection for the BBC ones.
Once a recording has commercials flagged, you can use the Z and Q keys to skip to the next or previous commercial marker, or set MythTV to skip automatically over commercial breaks (although you need to really trust the detection system for that).
When it comes to programmes that you've recorded for your library, you can manually remove the adverts to ensure you get it right. Start the programme playing and press E to enter edit mode. Press Z to load the detected commercials as a cut list. Check that the cuts are in the right place and adjust them as necessary by moving to where you want to cut and pressing M to call up the menu.
When editing DVB recordings, it's best to cut on a keyframe, and then use the lossless transcoder (you set the transcoder type in Setup > TV Settings > Recording Profiles > Transcoders). This gives fast lossless transcoding because it doesn't have to re-encode any of the file, just leave bits out. DVB uses MPEG-TS (transport stream), but MythTV transcodes to MPEG-PS (programme stream, the method used for DVDs).
The difference is that TS contains more error correction to deal with transmission glitches, so transcoding like this can significantly reduce file sizes. Even transcoding a BBC recording, where you don't need to remove any commercials, but just cut the top and tail while also removing the error bits, can give a useful file-size reduction.
User Jobs are a sort of DIY plug-in system, enabling you to extend the usefulness of MythTV. You can define up to four User Jobs that can be called at the end of a recording, in the same way as transcoding or advert flagging. These can be called for everything by default, or enabled for individual recording rules. User functions can also be run manually - press M while the recording is highlighted in the Watch Recordings list and select the job you wish to run from the Job Options sub-menu.
You can decide what to run when in Setup > TV Settings > General, but the User Jobs themselves are defined in the General section of mythtv-setup. Each User Job calls a command with some arguments relating to the recording in question.
These are explained in the user jobs section of the wiki, but the most common arguments are %FILE%, %TITLE%, %CHANID%, %STARTTIME% and %ENDTIME%.
You could use these to pass the filename to a script that calls MEncoder with suitable arguments to transcode the file to a format appropriate for watching on another device. The script could also put the transcoded file in a Dropbox directory ready for syncing to the device.
You could also use User Jobs to send notification via email or Twitter when recordings start or end, although the System Events added for version 0.24 may be more suitable for some of these tasks. The main difference is that System Events are always run when a particular event occurs, while User Jobs can be controlled per recording or manually.
We've concentrated on MythTV's capabilities as a personal video recorder (PVR), but it can also be used to watch live TV. Going to the Live TV menu option gives you a display of whatever channel you last used. You can pull up programme information (I), change channels (Up/Down), view the programme guide (S), start recording (R) and pause or resume the programme (P).
I know pedants will point out thatonce paused it's no longer live TV, but nonetheless you can pause and resume - say, to answer the phone - then skip through the next commercial break to catch up. Unfortunately, picture-in-picture has been disabled for 0.24,not to return until at least 0.25.
This doesn't refer to the infrared units that you point at the box; MythTV can also be controlled over a network. This is enabled in the General settings by selecting Enable Network Remote Control. This enables other computers to control your MythTV front-end. Telnet into port 6546 on the computer and type help to see the options.
There are programs that make use of this - for example, MythMote turns your Android phone into a touchscreen remote control for MythTV, provided the phone is connected to your wireless network. I've even set up my phone to send a pause command to MythTV when it rings, to save having to search for the remote before answering the phone.
This is probably one of the more arcane features of MythTV, but one that gets the true geek's mind racing with ideas about what they can do with it.
MythTV's user interface can be customised to a great extent. The screenshots so far have shown the difference between the Mythbuntu and MythCenter themes, but there are plenty more. The official themes may be distributed with the basic MythTV package or your distro may have a separate mythtv-themes package containing all but the standard themes.
Once installed, you can use the Theme Chooser in Setup to browse and select themes. If you have multiple front-ends, you can use a different theme on each, although some of the themes only work well on a larger-sized screen.
In addition to the collection of official themes, there are plenty of unofficial ones available. Look in the Themes section of the wiki for some starting points. Themes are generally supplied as a tarball to be unpacked into the system themes directory, which is usually /usr/share/mythtv/themes, or into .mythtv/themes in your home directory. Each theme should appear in its own directory in there, the directory naming the theme. It should then immediately show up in the Theme Chooser.
When installing a third-party theme, always make sure it's suitable for the version of MythTV you're running. As things move around and features get added, you may find that some functions are missing when using a theme for an older version.
In addition to changing the theme, you can alter the menu layouts. There are several to choose from in Setup > Appearance. In Appearance, look under Menu Theme. These don't change the way MythTV looks, just the layout of the menus. Choose one that makes your frequently used functions quickly reachable.
Guide to MythTV: Practical tips
Using MythTV isn't without its setbacks, so we answer some common questions and dispense some handy advice.
Q: Can I reduce the channels displayed in the programme guide so that I'm only shown the ones that I may have some vague interest in?
A: You can, either by deleting channels in the mythtv-setup channel editor or by creating channel groups in MythTV itself. Channel groups are the preferred option and can be found in the TV Settings section.
There's a Favourites group defined, and you can either use this or create your own. Enter the group to see its list of channels - by default, they're all selected, so just untick the ones you don't want.
When in the programme guide, press / to switch between channel groups, including the All Channels group. The TV Settings > General section has an option where you can set the default channel group to use, or have it remember whatever you used last time.
The channel groups only limit the channels displayed in the programme guide, not those used to record from, so you can also reduce clutter by removing the +1 channels without having to lose the flexibility that they offer.
Not enough TV cards?
Q: If I want to record overlapping programmes, do I need multiple TV capture cards, or can I persuade one card to tune into multiple channels?
A: If you're using DVB (either terrestrial or satellite), you're in luck, because these multiplex several channels into one stream. MythTV is able to receive an entire stream from a DVB tuner card, and then split it into individual programmes.
When adding a capture card in mythtv-setup, press the Recorder Options button to see a further screen, which includes a Max Recordings setting. Three is a sensible setting for this, and means that you could record six channels at once if you have two capture cards.
That's the maximum number of channels, though, so you can still only record from two streams with two cards. You could record BBC One, Two and Three and ITV1, 2 and 3 simultaneously, but not BBC One, ITV1 and Film4, because they're all on separate multiplexes - of which there are a total of six on UK Freeview. With six tuners, you could record everything, but you'd probably never have time to watch it all!
Q: I'd prefer to start my recordings a couple of minutes early and end them slightly late. There's nothing worse than watching a programme right through, then missing the conclusion because it started late or over-ran.
A: There are two ways that you can configure this. The first is to go into Setup > TV Settings > Recording Priorities > Set Recording Priorities. From here, you can set Default Start Early/End Late Minutes. These are the default times that appear in every recording rule, and can also be changed for individual rules.
Note that this can cause conflicts if you're trying to record back-to-back programmes, because these times will create an overlap. This isn't a problem if you have enough capture cards, however - especially if you also use multiplexing.
The other place is in Setup > TV Settings > General. The fourth page features settings to start recording early and end late, given in seconds. This option doesn't cause conflicts, because it's ignored when making back-to-back recordings.
There's also an option on this page to record overtime for one category of shows, which is useful for the Sport category and takes care of those inconvenient extra-time sessions and penalty shoot-outs. It's important to bear in mind, though, the extra disk space that all those additional minutes can take up.
Q: My hardware is somewhat on the esoteric side; what screen resolution should I be using in my MythTV setup?
A: If you have a reasonable monitor or TV, you shouldn't need to worry about this. X will detect its capabilities and pick a suitable screen resolution. TVs can often overscan, which is when the picture goes slightly beyond the visible portion of the screen. This is acceptable when watching TV, because nothing important is at the edges, but can be annoying when using the GUI. Go to Setup > Screen Setup Wizards to fine-tune the display size.
This doesn't affect the screen resolution - just how much of it MythTV uses - and makes sure the display exactly fills the screen with no overspill. There's also an option to use different sizes for the programme and GUI display, but this shouldn't be needed with an LCD TV.
Too late to record it?
Q: I've just turned on the TV and seen the end of what looked like a good programme. Is there anything I can do?
A: Time travel won't be implemented until MythTV 1.0 - by which time we'll probably all have the capabilities for it, anyway - but there's sometimes something you can do, apart from paying more attention to the TV guide.
Many programmes are repeated on a time-shifted +1 channel, or even shown again later in the week (the BBC does this quite often), so find the programme in MythTV's programme guide and set it to Record One Showing Of This Title.
If there's a repeat later in the week, MythTV will schedule itself to record this for you. Otherwise, it will wait patiently until the programme does appear again, even if it does so on a completely different channel.
This also works with films: when someone asks, 'Did you see that brilliant film last night?' you can go back into the guide and set it to record the next time it's shown.
Q: I don't want to watch TV with a keyboard on my lap. How do I add a remote control?
A: The easiest, and probably best, option is to get hold of an infrared cordless keyboard and a universal remote control with learning capabilities. Put the remote in learning mode, point it at the keyboard and assign keys to the various buttons, such as P for Play.
You can find a comprehensive list of all keyboard commands on the MythTV site.
This method has two advantages: you're sending key commands directly to the computer as if you were using a keyboard, so there's no need for a translation layer, such as LIRC (Linux Infrared Remote Control), and you can still pick up the keyboard and use that if you want to do anything that involves typing more than a few characters.
The most common approach, though, is to use LIRC, which Mythbuntu installs by default. It lets you pick a controller during installation, or you can do this later from the Mythbuntu Control Centre. Pick your remote control and away you go.
You'll need some means of receiving the signals, so either choose a media centre remote with a USB receiver or there are various serial port receivers available - check lirc.org for details. I've used one of these with the remote from a Hauppauge TV card with great success. The Control Centre has settings for a remote control and an IR transmitter - the latter is used to control an external input, such as a cable box.
If you're not using Mythbuntu and want to set up a remote manually, there are two aspects to the configuration (once you've installed LIRC). You need a configuration file at /etc/lircd.conf that contains the details needed to translate the infrared codes into readable commands. The LIRC package installs many configuration files in /usr/share/lirc/remotes and there are many more available at lirc.org. Find the one for your remote and copy it to /etc/lircd.conf.
The next step is to configure how MythTV reacts to commands from the remote, which is defined in /.mythtv/lircrc. This file contains stanzas like this:
prog = mythtv
button = ArrowDown
repeat = 3
config = Down
The command sent by the remote is specified in button, and config is the key that LIRC sends to the computer, so this code tells LIRC to send a cursor down when you press the down key on the remote. Our repeat setting means it only works on every third event, otherwise you may find the remote sends commands too fast. All you need now is to know the command that each button sends - run irw in a terminal and each time you press a button, the command will show in the terminal.
It's also possible to use a PS3 Blu-ray remote with MythTV. This uses Bluetooth, so it doesn't need a line of sight link to the computer. You can find details at the MythTV site.
First published in Linux Format Issue 144
Liked this? Then check out How to build the ultimate MythTV box
Sign up for TechRadar's free Week in Tech newsletter
Get the hottest tech stories of the week, plus the most popular reviews delivered straight to your inbox. Sign up at http://www.techradar.com/register