MythTV is a project that brings analogue and digital television to your Ubuntu-powered PC. It primarily functions as your television and personal video recorder (PVR), but can be made to do many other things (refer to the official MythTV site for more information), however one thing that can catch people is actually building a MythTV box from scratch. Over the years, MythTV has been one of the largest causes of baldness in users who have torn out their hair in frustration.
Nowadays, tailored distributions such as Mythbuntu make the task pretty much trivial, but not everyone likes to use the tailor-made distributions. For one, Mythbuntu has a lot of its own branding across it which I personally don’t really like, and I’d prefer not to have it install all of that plus XFCE as the default desktop and then have to undo it all just to get back to a regular Ubuntu desktop.
Since I recently built a MythTV server for my folks, and on top of that connected it to their aging CRT television rather than the latest in visual technology, this makes for a perfect tutorial on how to take a vanilla Ubuntu Jaunty 9.04 installation and turn it into a simple, functional MythTV server without all the branding. We are going to just install only the components required to get MythTV up and running. Anything else you add is purely up to you.
Note: This tutorial covers installation of MythTV 0.21 as supplied with Ubuntu Jauty 9.04. It does not apply to the forthcoming 0.22 release which will sport a vastly different interface. It is not known yet whether Ubuntu Karmic 9.10 will still have 0.21 supplied or if 0.22 will be ready for release by then.
The system I built for my folks comprised of the following hardware:
- Silverstone LC17 case (just to match the lounge gear, but you can use pretty much any case)
- Gigabyte 500w PSU
- 2GB of Kingston DDR2/800 RAM (should have bought two sticks instead of a single stick, so I could run it in dual-channel mode – ah well, it’s not really a performance killer for MythTV)
- A Gigabyte S-Series EG41M-S2H motherboard (which has built-in optical out and HDMI based on an Intel gfx chipset)
- An MSI NX8400GS (NVidia GeForce 8400GS) PCI-E graphics card (because it’s passively cooled for no noise and has Composite/S-Video output as well as VGA and DVI)
- An Intel E5300 Pentium Dual-Core CPU
- A Seagate 1TB hard-drive
- LG SATA DVD-RW optical drive (for playing DVD movie discs)
- Two Asus MyCinema-U3100-Mini DVB-T digital-only TV tuners
- Digitech “generic” Windows Media Centre Compatible remote control and USB infra-red receiver (cheaper than the real thing and doesn’t have any Windows or Microsoft branding on it)
I won’t detail the hardware build process since it’s an ordinary PC at the end of the day, but here is how it looks in my folks’ AV cabinet (it’s on the bottom shelf):
I performed a vanilla Ubuntu Jaunty 9.04 with the following partition layout:
- 100MB for /boot formatted as EXT2
- 1GB for swap formatted as SWAP
- 8GB for / (root) formatted as EXT4
- Remainder of drive for /home formatted as EXT4
Since I also installed a UPS, I do not foresee any issues with the EXT4 file system and power-loss-related data corruption. I used EXT2 for /boot because, frankly, it doesn’t need journalling there. You’ll only ever write to that partition when you do a kernal update and having as a separate partition will make any future system recovery easier.
My folks are still using an old standard-definition widescreen CRT television. It comes equipped with SCART inputs which can accept Composite, S-Video and Amiga-style RGB signals, but not Component ability. I elected to connect the PC using S-Video, and it looks pretty sharp for what it is – certainly far more readable than Composite.
I came across a strange issue when I started the Ubuntu installation process – it couldn’t start X. Basically put, it cannot detect the “monitor” and thus cannot setup a suitable screenmode. I decided to do the initial installation via a traditional VGA monitor and once the NVidia drivers were installed, I’d switch back to the TV only.
I configured the primary login account, password and machine name to all be “htpc” and set it to auto-login. Once installation was complete and rebooted for the first time, I quickly installed the NVidia Binary driver and updated the system with any outstanding general system updates.
Setting up the TV
Once rebooted for the second time, I physically disconnected the VGA monitor and left only the TV connected. Ubuntu appeared quite cheerfully, though annoyingly it had switched to NTSC 60Hz mode, and I wanted PAL in 50Hz.
I opened up the xorg.conf configuration file into GEdit as follows:
$ sudo gedit /etc/X11/xorg.conf
…and located the “Screen” section which describes what the X screen to be used is. It looks something like this:
Section "Screen" Identifier "Screen0" Device "Device0" Monitor "Monitor0" DefaultDepth 24 Option "TwinView" "0" Option "TwinViewXineramaInfoOrder" "TV-0" Option "metamodes" "nvidia-auto-select +0+0" SubSection "Display" Depth 24 EndSubSection EndSection
I added the following two lines into that section:
Option "TVOutFormat" "SVIDEO" Option "TVStandard" "PAL-B"
…so now the Screen section looked like this:
Section "Screen" Identifier "Screen0" Device "Device0" Monitor "Monitor0" DefaultDepth 24 Option "TwinView" "0" Option "TwinViewXineramaInfoOrder" "TV-0" Option "metamodes" "nvidia-auto-select +0+0" Option "TVOutFormat" "SVIDEO" Option "TVStandard" "PAL-B" SubSection "Display" Depth 24 EndSubSection EndSection
This ultimately outputted a 1024×768 display on the TV, stretched horizontally (a 4:3 screenmode stretched to fit a physical 16:9 display). If your Ubuntu desktop is larger than the screen, just adjust your TV’s picture size until everything fits in. In my case, only the top and bottom panels got slightly chopped off which was fixed with a minor vertical size adjustment on the TV.
First we need to enable the system to access the Multiverse repository. Do this by going to System->Administration->Software Sources and place a check mark against all five boxes, click OK and acknowledge the prompt to reload your package lists.
We now set about installing the extra software I required to turn this box into a MythTV server (which was going to run both Backend and Frontend):
$ sudo apt-get install mythtv
That’s all you need to get the main MythTV stuff working – the “mythtv” metapackage installs the MythTV Frontend, MythTV Backend, MySQL Server, MySQL Client, MythTV database configuration, all the default MythTV themes, etc. In my case, however I also installed the following for extra video/audio codecs (such as MP3 for listening to music files or watching movie rips), Java, Flash, the Microsoft Fonts, the Compiz Configuration manager for doing desktop eye-candy, the SSH server daemon to remote control the box when my folks call for help, and finally the MythWeb add-on that allows you to look at the MythTV server’s TV guide and schedule programs to record using a web browser interface:
$ sudo apt-get install mythtv ubuntu-restricted-extras compizconfig-settings-manager ssh mythweb
…and from the Medibuntu repository, I installed the following for extra codecs and DVD decrypting/playback:
$ sudo apt-get install non-free-codecs libdvdcss2 mplayer mencoder
Note: I did not need to install lirc for the remote control because the Digitech remote is actually a USB keyboard in disguise, not a “proper” infra-red remote.
During the installation of these packages, you will be prompted for a few things, namely:
- Create a password for the root MySQL account. If this MythTV installation is purely for in-house use only, then just go with something simple like “password”. Many suggest leaving it blank, but I’ve personally seen this create authentication problems later on.
- Create the MySQL database. When prompted for the MythTV server address, change the default “localhost” to the IP address of the PC you are installing the Backend on. If the Backend Server has an IP address of 192.168.0.10, then type in 192.168.0.10 in place of “localhost”. If you only intend to run one machine only for everything, then you can leave “localhost” as is.
- When prompted for the name of the MySQL database, leave it as the default “mythconverg”.
- Make note of the password generated for the MythTV database. You will need this to configure your MythTV Frontend.
- Indicate whether or not you intend to have more than one Frontend client connect to your Backend server.
- If you elected to install MythWeb, then you will be asked a question as to whether or not you want your MythWeb site password protected.
- Acknowledge other prompts that tell you about creating the “MythTV” groups etc.
- Your PC now has a user and Home directory called /home/mythtv and we need to ensure that the “mythtv” group can write to it as well as the owner, so at a terminal, type in:
$ sudo chmod -R g+w /home/mythtv
…and hit Enter.
- Finally, if you intend more than one Frontend to access your Backend machine, we need to tell MySQL to allow other PC’s on your network to access the database, or those Frontends (other than the one on the Backend server) will not be able to start. To do this, type the following at the $ prompt. Everyone else can skip to Step 12.
$ mysql mythconverg -u root -p
- When prompted, enter in the root MySQL password you specified earlier.
- You will then be shown a MySQL prompt. If your local network’s IP topology is 192.168.0.x, and the password that was generated for MythTV’s database was “8tSpxGiM” then type the following to grant access to all PC’s on your local network to the MythTV MySQL database, at the “mysql>” prompt:
mysql> grant all on mythconverg.* to mythtv@"192.168.0.%" identified by "8tSpxGiM";
mysql> flush privileges;
…this will allow all PC’s with IP addresses starting with 192.168.0.x to access the MythTV database. If you are paranoid and only want to allow specific PC’s to access the database, then simply issue the “grant all” line for all explicit IP addresses only, by replacing the “%” wildcard character with the explicit IP address you want to allow, ie: to allow just 192.168.0.67 in, replace “192.168.0.%” with “192.168.0.67”.
Repeat for all specific IP’s to allow. You only have to issue the “flush” command once at the end to make your changes take effect.
- Confirm that you can access the MythTV database as the MythTV user at the $ terminal prompt. If you are only using one machine, do this on the Backend server. If you are using multiple Frontends, test this on the remote PC’s that will be running the Frontend software (obviously replace the IP address with the actual IP address your Backend machine is using):
$ mysql mythconverg -h 192.168.0.10 -u mythtv -p
…when prompted, enter the MythTV password that was generated earlier. If successful, you should be looking at a “mysql>” prompt. If not, you will get an error, probably along the lines of “access denied”. NOTE: If you configured “localhost” to be the Backend Server in Step 2, then you must use the name “localhost” to connect to MySQL. Using “127.0.0.1” instead will not work because you have not configured “127.0.0.1” to have access to the mythconverg database. If you wanted these permissions, you would modify Step 11 to be the following commands:
mysql> grant all on mythconverg.* to mythtv@"192.168.0.%" identified by "8tSpxGiM";
mysql> grant all on mythconverg.* to mythtv@"127.0.0.1" identified by "8tSpxGiM";
mysql> grant all on mythconverg.* to mythtv@"localhost" identified by "8tSpxGiM";
mysql> flush privileges;
…which will allow the “mythtv” user to connect from any IP on the 192.168.0.x network, from 127.0.0.1 and any host called “localhost”, all using the specified password.
- Quit the MySQL client by typing “quit” at the “mysql>” prompt:
Configuring MythTV – the Backend
At this point, make sure your TV tuners are connected. In my case, the Asus U3100’s are connected into two free USB ports at the rear of the PC and have automatically been detected as Ubuntu carries full support for the U3100 already.
Now we need to start MythTV Backend Setup for the first time. Go to System->Administration->MythTV Backend Setup. When you do so, it will prompt you that your user (in my case “htpc” needs to be added to the “mythtv” group. Acknowledge this and then accept being logged out for the change to take effect. Log yourself back in. Once logged back in, restart the MythTV Backend Setup again. You will be reminded that the MythTV Backend needs to be stopped before you can continue. Click OK.
You are presented with several options. Choose “General” (if you are using a remote, you should find the basic Up/Down and OK buttons work here already).
- Change the “Local backend” and “Master backend” addresses to be “localhost” (in lower case and one word). Leave all the “port” numerical figures alone.
- Click on “Next”. If you’re only using a keyboard, then press ALT + N to proceed. The screen content will change.
- Change the “TV format” to suit your local country. In my case, this is “PAL”. If you are in America or Japan, you’ll use “NTSC”. Check your local TV standards if you are not sure.
- Change the channel frequency table option to your local country. In my case, this is “australia”.
- The timezone for your guide XML data will ultimately depend on how you get your guide data. In my case, I just use Auto.
- Click on “Next” or ALT + N on the keyboard.
- We don’t need to change anything on this screen or the five screens that follow it, so click on “Next” again until you get to the last page where the button now says “Finish”.
- Click on the “Finish” button or press ALT + F on the keyboard. You will be returned back to the main menu.
Now choose the “Capture cards” option.
- Choose the “New capture card” option from the list.
- What you choose here will be dependent on what your tuner hardware is. In my case, I change the “Card type” until it says “DVB DTV Capture Card (v3.x)” and you will see that the “Frontend ID” will show “DiBcom 7000PC” and the “Subtype” will be “DVB-T” indicating a “Digital Video Broadcast – Terrestrial” device was found.
- Click on the “Recording Options” button and ensure that the “Max recordings” option is set to “2” (most digital tuners can record two channels at once from the same network, thus two physical tuners effectively become four usable tuners within MythTV).
- Go back to the previous screen by clicking on Finish and then click on Finish again. You will be returned to the Capture card list and you will now see a new line for the card you just setup.
- Since I have two tuners, I repeat this whole process again – the system will pick up the second tuner and label it accordingly – you can’t setup a card more than once accidentally. In my case now I have two cards called DVB:0 and DVB:1 listed.
- Press ESC to return back to the main menu.
Now choose the “Video sources” option.
- Choose the “New video source” option from the list.
- Give your video source a name, eg: “Digital Free-to-Air”. This can be anything you want.
- For your Settings Grabber, just choose the “Transmitted guide only (EIT)” or “No grabber” option for now. If you already have a preferred grabber, then choose it here now.
- Click on Finish.
- We only need one source for both tuners, so we’re done here. Press ESC to return back to the main menu.
Now choose the “Input Connections” option. This is where we tie our source to the tuners.
- Choose the first tuner in your list. In my case I have “DVB: 0 (DVBInput) -> (None)”.
- Change the “Display Name (optional)” to be something that describes the tuner, eg: “Digital tuner 1″. This can be anything you want and will serve to highlight what tuner you are using to watch or record a particular show.
- Change “Video source” to the one you created in the “Video sources” earlier. In my case, I choose the only option I have – “Digital Free-to-Air”.
- Now press the “Scan for channels” button.
- Ensure that “Scan Type” is set to “Full Scan” and that your Country is correct.
- Make sure that your TV aerial is securely connected to your TV tuner and then click on “Next”. The tuner will begin looking for TV channels. This can take several minutes to complete. Do not interrupt the process, even if it looks like it has gotten stuck – it will finish eventually. Any channels found will be listed in the status window at the back.
- Once finished, press “Finish”.
- Now press “Next”. Don’t change anything here.
- Press “Finish”. You will be returned to the “Input Connections” list.
- Repeat steps 1 to 3 only for any additional tuners you have (in my case, I had to repeat for the second tuner). We don’t need to re-scan for channels because the tuners are using the same source and we’ve already populated it with channels in the first run. In this instance, once you have done steps 1 to 3, just click on “Next” and then “Finish”.
- Press ESC to return back to the main menu.
Now choose the “Channel Editor” option and review all the channels that were picked up in the scan. Optionally, you may also have MythTV automatically download what it believes are the correct network icons for those channels from the Internet using the “Download icons” button. Delete any channels you don’t want to review. Eg: in my case, I also picked up some digital radio channels. I’m not interested in those, so I could delete those if I so choose.
Press ESC to go back to the main menu.
Now choose the “Storage Directories” option. This is where we tell MythTV where to put all our TV recordings.
- Choose “Default” from the list.
- Choose the “/var/lib/mythtv/recordings” path already defined and change it to “/home/mythtv” (or whatever you prefer).
- Click the “OK” button.
- If you want to add more directories from other devices such as secondary hard-disks or network drives, just “Add directory” and specify them accordingly.
- Once done, press ESC to return back to the main menu.
We’re now done configuring the Backend, so press ESC again to close the MythTV Backend Setup application. If you get an error, review it and see if you can fix it based on the information provided. In particular, if it tells you that it couldn’t write a “.test” file to /home/mythtv, then you did not grant the “mythtv” group writer permissions to “/home/mythtv” (See Step 8 in “Installing MythTV” earlier in this article).
Upon exiting, after a couple of seconds a dialog box will appear asking if you wish to run “mythfilldatabase”. Say YES. Once this is done, the MythTV Backend should automatically restart in the background briefly and then its output window should disappear.
Configuring MythTV – the Frontend
We’re nearly there! Now to configure the Frontend! Go to Applications->Sound & Video->MythTV Frontend. After a brief delay, you will see the default MythTV menu.
- Choose “Utilities/Setup” from the menu.
- Now choose “Setup” in the next menu.
- Now choose “General” in the next menu.
- If the PC you are on now is the Backend server, then this should already show that the”Database Server Settings” hostname is “localhost”. If you are installing a laptop/desktop that is NOT the Frontend, then you need to have the IP or hostname of the Backend machine here instead so that Frontend client knows who to talk to. In the case of your installation example, I’m using 192.168.0.10.
- The port number can be left empty. It will use the MythTV default automatically.
- The database name should already be “mythconverg”.
- The user name should already be “mythtv”.
- The password should already be the one that was randomly generated during the installation process.
- Press “Next”.
- Nothing to change on this screen, so press “Next” again.
- Change the audio settings to suit your own configuration. If you are using an ordinary stereo setup, you can leave pretty much all of this unchanged, however I’d recommend adjusting the “Master Mixer Volume” to 100 and the “PCM Mixer Volume” to 80 or 90 (don’t set PCM to 100 as some motherboards will output scratchy/distorted audio depending on the quality of your on-board sound hardware).
- Press “Next” through the next four screens.
- Press “Finish”. You will be returned to the Setup menu.
Special setup: Configuring your MythTV Frontend to output digital audio via SP/DIF on the PC’s motherboard.
- By default, motherboards with on-board SP/DIF out generally have their output muted, and as a result you will not see any laser light from any toslink cable connected to the motherboard. Unless you’re lucky, 9 times out of 10, the SP/DIF controls will not appear in the graphical Volume Control applet. To get around this, open a terminal.
- Now type in “alsamixer” and you will be presented with a terminal version of the Volume Control applet.
- Now press the right-arrow key until you come across any “IEC958″ related options. There will generally be two or three entries. You will probably find they have “MM” above them which means they are Muted.
- Press the M key on your keyboard to toggle the Mute status of that option so that it now shows “OO” instead. This means it is no longer muted.
- If you’re looking at your toslink cable, you should now see the fibre optic line in it light up with red laser light as you unmute it. You’re done, so press ESC to close the Alsa Mixer interface.
Now choose “Appearance” from the menu.
- You can now choose a different theme from here which makes the interface look more attractive than the default theme. My personal favourite is “Blootube” and “Blootube Wide”.
- If you are using 3D-enabled video drivers such as the NVidia binary drivers, you can elect to change the Paint Engine to OpenGL which will do nice crossfade transitions from one menu to another (note that there are no 3D transitions).
- I also change the “Menu theme” here to “classic” as I believe it provides a more intuitive menu tree within MythTV. I encourage you to explore these options and choose what works best for you.
- Page the “Next” button until you get to the end and then click “Finish”.
- If you’ve chosen a new theme, it will now be scaled appropriately for your display and switched over.
You are now ready to begin watching TV, but you may want to quickly duck back into Setup->Playback OSD and change the theme there to “Blootube” or whatever you prefer as well as the On-Screen-Display when watching TV has a separate theme setting to the menus.
To watch TV, simply choose “TV” and then “Watch TV” from the MythTV menu. Use the up and down arrow keys and Enter to change channels.
MythWeb is completely automatically configured. Using our installation example Backend host IP of 192.168.0.10, you can access it by opening your web browser and surfing over to http://192.168.0.10/mythweb and you will be presented with the main menu of MythWeb.
Being a web site, MythWeb is obscenely easy and self-explanatory to get around, so I won’t detail any of its most common functions here. I encourage you to explore the interface.
One particularly useful feature of MythWeb is in getting the Digitech generic remote to work. Out of the box, I only found the direction and OK buttons to work right away. All the other buttons generate keyboard presses that do not coincide with MythTV’s default keys. For example, the Play/Pause key on the remote generates “CTRL + P” instead of just “P”, hence MythTV doesn’t act on the button press.
- To reconfigure key binds, all you have to do is click on the “Settings” option on the main menu.
- Now click on “Key Bindings” in the presented options.
- You are presented with all the available keybinds for various areas of MythTV. Scroll down the list until you find the keys pertaining to “TV Frontend” (first column).
- Now locate the key bind related to “PLAYBACK – Play Program” (second and third columns). You will notice that the key assigned (in the fourth column) already is “P”.
- To add the CTRL + P key combination without erasing the original “P” key, simply change the text box to read “P, Ctrl+P”. This binds both the P and CTRL + P key combinations to the Playback command.
- Change all the other keys you need to change or add.
- When done, scroll right to the very bottom of the key binds page and click on the “Save” button.
- Restart the Frontend to read in your new changes and test the remote.
This is what the Digitech generic MCE remote looks like:
OPTIONAL: Setting up the Shepherd Electronic Program Guide (EPG)
Shepherd is an amazing Perl script that enhances and keeps your EPG data up to date in Myth, always providing better information about programs than the networks themselves do. A typical example of a poor network-supplied program description might be “Late Movie: 10:30pm – Pirates of the Carribean starring Johnny Depp” and… that’s it. How boring! Shepherd will use a grading system as well as sourcing categories of data from different sites in order to provide you a comprehensive description of all your programs instead. In the case of the above example, it would go to the IMDB and get the official movie blurb to use instead.
NOTE: Shepherd is geared towards Australian MythTV users only. This is due to long-running (and petty) legal disputes over EPG supply and copyright in this country. If you are outside of Australia, you most likely already have a proper EPG provided for you and you should use that instead.
Setting up Shepherd is trivial (Shepherd was up to version 1.3.39 at the time of this writing – refer to the official installation page for any changes made to the installation process since).
- Open a terminal and type in the following:
$ wget http://www.whuffy.com/shepherd/shepherd
…and press Enter. This will grab the latest version of the Shepherd Perl script.
- Before we run it, we need to install some dependencies:
…and hit Enter.
- Once all that is installed, now run the Shepherd setup script with the command:
$ perl shepherd
…and hit Enter.
- Shepherd will initially re-install itself into the “mythtv” user’s home directory, ie: /home/mythtv, and re-run itself.
- Shepherd will then begin checking itself to ensure all its data grabbers are the latest versions and download any that are missing. It will then prompt you through the rest of the installation process, which is generally straight forward, but we’ll step through it here:
- First you are asked for a region code and are shown a giant list. Type in the number relevant to you and hit Enter. Eg: if you lived in Melbourne, Victoria, you would type in “94” as the code associated with that region. If you were in Sydney, you’d type in “73” instead.
- Next you are asked if you would like Guided Channel Selection. Say YES (or just hit Enter as the default response is yes anyway).
- You will then be asked if you have High-Definition TV. If you do use HDTV channels, you should say YES to this.
- You are then asked if you have PayTV. If you are only configuring MythTV for Free-to-Air TV, say NO to this.
- Now MythTV will ask you to match the known channels for your region to the channels that are setup in your MythTV installation. It will prompt you for each channel one by one. Simply enter the number corresponding to the guide data source you believe belongs to the currently displayed channel, eg: in some country areas, Channel Nine is known as WIN, so any references to “Channel Nine” you would tell Shepherd to use guide data provided by WIN. Repeat this until all channels have been prompted for. You may come across some doubled-up channels. This is normal.
- When finished, Shepherd will list all your selections so you can verify them. When you are happy, respond YES.
- You will then be asked about transitioning from an old grabber. Since this is a fresh installation, choose the zero (“do not transition”) option.
- You will be given one more review and will then be asked if you’d like Shepherd to create a configuration file and update MythTV. Say YES.
- When prompted about allowing Shepherd to auto-configure MythTV, say YES.
- When prompted for Shepherd to create a symbolic link, say YES.
- When prompted about the cron job Shepherd sets up, say YES.
- Respond YES to the review question.
- Shepherd will then begin testing its components and will eventually ask if you would like to install channel icons. This is not necessary (though you can complete it if you really like), so say NO to this.
- Shepherd will finish.
- Now we need to populate the EPG using Shepherd for the first time. Note that the initial run can take potentially an hour or more to run depending on your connection and quantity of channels in MythTV to find data for. Once finished, however, each subsequent run (once per hour, 24 hours) should be much faster. To run it for the first time manually, simply type in:
…and hit Enter.
- Depending on the minute that Shepherd setup for the cron job, you may find that as you try to run it manually, Shepherd advises that “another instance is running” and will abort itself. That’s fine – the job’s already started then automatically.
- When Shepherd has completed its run, you will find that your EPG within MythTV is now nicely populated with highly descriptive blurbs and will remain so for at least 7-8 days ahead as long as the PC has a connection to the Internet.