Professional Documents
Culture Documents
10
Document Purpose
The purpose of this document is to guide the reader through the installation of MythTV
0.20 on Ubuntu Gutsy 7.10. After completing this guide the reader will have a fully
functional MythTV Linux box that is capable of recording and playing digital television
as well as hosting your DVD and music collection, or streaming those media collections
to other MythTV front-end machines elsewhere around your house and wider networks,
even allowing access to your recordings via the web from outside of your home if desired.
Requirements
The following requirements are prerequisites for using this installation guide.
Example Hardware
I used the hardware specified below. If you use the exact same hardware then your
installation will work perfectly provided that you follow the instructions here accurately.
However, if you use different hardware (such as a different model of TV tuner or graphics
card) then you should do some research first to check that the hardware you have chosen
is compatible with Ubuntu Gutsy 7.10 and that it is it compatible with MythTV. The
safest option for a stressful install is to use the hardware I’ve written this guide around.
I wanted to point out a couple of things regarding my hardware setup. You will notice that
I’ve got video built into the motherboard, yet I also opted to install a separate graphics
card as well. The reason is that the separate graphics card will provide DVI output and
has a higher specification that the built-in one, which is important given that I need the
graphics card to deliver a clean crisp video image to the accompanying television.
Secondly, rather than installing a Wireless card I opted to use the built-in Ethernet port
and connect it to a Devolo Ethernet adaptor that plugs into a power socket in the wall.
These adaptors allow an 85mbps network connection to be established across the power
circuit in your home. One adapter connects the network from the router to the mains
circuit and the other adaptor connects the mains circuit to your MythTV computer. This is
especially useful because Linux still has problems natively supporting many wireless
cards and this approach will give you a consistent fast network connection that will better
facilitate streaming your media to other MythTV front-end PCs around your home.
One final point - get a lot of memory (1GB per TV channel you wish to be able to record
in parallel) and a large hard-disk. I fitted a 500GB hard-disk and was surprised how
quickly it filled up when I loaded on my DVD collection and started recording TV. You
can never have enough memory and never have enough hard-disk space available to you!
Page 1 of 46
Installing MythTV on Gutsy www.daviddn.com
In order to help you identify the hardware I used, please find below the details and boxes.
All these hardware products are compatible with Ubuntu Linux 7.10 and with MythTV.
Motherboard
nFORCE 4M-A ATX
(purchased in PC World) Processor
AMD Athlon 64 X2 dual core processor
(purchased in PC World)
Tuner Card
Hauppauge WinTV Nova T-500 dual tuner
(purchased in PC World)
Graphics Card
nVidia GeForce 7200 Series
(purchased in Maplins)
etwork
Devolo Highspeed Ethernet Starter Kit
(purchased in PC World)
Page 2 of 46
Installing MythTV on Gutsy www.daviddn.com
Table of Contents
DOCUMET PURPOSE 1
REQUIREMETS 1
EXAMPLE HARDWARE 1
TABLE OF COTETS 3
ISTALLIG UBUTU 5
EABLIG THE ROOT USER 6
COFIGURIG THE ETWORK 7
UPDATIG APTITUDE 8
ISTALLIG A SSH SERVER 9
ISTALLIG THE GEERIC SERVICES AD TOOLS 9
ISTALLIG A ETWORK TIME PROTOCOL SERVER 9
ISTALLIG MYTHTV 15
Page 3 of 46
Installing MythTV on Gutsy www.daviddn.com
/USR/LOCAL/BI/MYTHECODE.SH 38
/USR/LOCAL/BI/MYTHCLEA.SH 40
/USR/LOCAL/BI/RIPDVD 41
/ETC/LIRC/HARDWARE.COF 42
/ETC/LIRC/LIRCD.COF 43
/HOME/MYTHTV/.LIRCRC 44
Page 4 of 46
Installing MythTV on Gutsy www.daviddn.com
Installing Ubuntu
1. Install the hardware, insert the Ubuntu Gutsy CD into the DVD-drive and boot the PC
3. Add “noapic” to the Boot Options. This is required to work around an issue with
AMD 64 X2 processors hanging the OS. You may not need to include this step if you
are using an alternative processor. If you are unsure you should add this option.
4. Run the Install program from the Ubuntu Desktop and follow the pictures below.
6. The partitioner will start up. When asked how you would like to partition your disk
you should select manual. I created a 40GB partition for my root filesystem, a 10GB
swap partition, an optional 50GB partition for my network share and all the rest of my
space for my /var/ partition. The /var/ partition needs to be big because this is where
MythTV stores your media files by default. I installed a 500GB hard disk, so after
losing 100GB for my root, swap and share partitions I had 400GB left for /var/.
Page 5 of 46
Installing MythTV on Gutsy www.daviddn.com
When creating the /var/ partition I used a JFS file system. This is a journalled file
system and is also very efficient at handling large data files, such as media content.
7. Next provide your name and password details for the main account. We will be
setting up a mythtv account later on, so for now just create an account in your own
name. You should also provide a name for your computer; I used mythtv as the name.
8. The installation of the core Ubuntu operating system will then commence. Go and
grab yourself a cup of tea and after a while you will be prompted to reboot your PC.
1. First we need to enable the root user account. This is the account that we will be using
to install all the core services under. Root is considered to be a specially privileged
account, so be careful when issuing the commands in this installation guide.
su
Password: [enter the password you selected above]
Page 6 of 46
Installing MythTV on Gutsy www.daviddn.com
1. You should now be logged in as the root user and therefore have the required
privileges to change the system settings and install services and programs.
2. The first thing we need to configure is the networking so it uses a static IP address.
This is useful because you will need to know the IP address of this server in order to
access it from other PCs (such as other MythTV Front-ends) or from the Internet.
vi /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.2.100
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255
gateway 192.168.2.1
Restart the networking service (the grey text is the response you will get from Linux):
/etc/init.d/networking restart
* Reconfiguring network interfaces… [OK]
3. We will now set a hostname for the PC. This should be the full URL that you will use
to access the PC remotely. I have a dynamic IP for my machine, so I use a domain
name that I can manage the DNS for with ZoneEdit (http://dynamic.zoneedit.com)
vi /etc/hosts
Ensure the first three lines are as follows (I use www.davos.co.uk as my domain):
127.0.0.1 localhost
127.0.1.1 mythtv
192.168.2.100 www.davos.co.uk
Page 7 of 46
Installing MythTV on Gutsy www.daviddn.com
Updating Aptitude
1. We now need to change the Aptitude Repositories used by Ubuntu. These are the
places that Ubuntu looks when installing applications and services. I typically disable
the CD-ROM as a source (ensuring we always look on the web for the most recent)
and I add a couple of the core repositories that are needed later on in this guide.
vi /etc/apt/sources.list
# Universe Repositories
# Unsupported Multiverse
# Backports
2. Save the changes that you have made above, update the repository list and upgrade
the base components currently installed on your system by typing the following. The
upgrade option can take a while depending on how old your original Ubuntu CD was.
Page 8 of 46
Installing MythTV on Gutsy www.daviddn.com
1. Install an SSH server so that you can use a SSH client to access the PC:
1. Install additional generic software that will be required during this installation by
typing the command line below into your terminal. The applications being added here
include useful programs for compressing and uncompressing data (unzip and zip), for
fetching data from web pages (curl) or mail servers (fetchmail), for compiling code
(gcc and make) and for converting DOS files into UNIX files (apt-file and sysutils).
2. Remove some of the inet services that are not required on a MythTV server:
touch /etc/cron.weekly/setclock.cron
chmod +x /etc/cron.weekly/setclock.cron
vi /etc/cron.weekly/setclock.cron
#!/bin/bash
clock=clock.psu.edu
/usr/sbin/ntpdate -u $clock >& /dev/null
Page 9 of 46
Installing MythTV on Gutsy www.daviddn.com
1. As well as using the PC as a MythTV back-end, I also use the PC as a network file
server too. Therefore, it may be useful to have additional user accounts set up on the
machine. We already have one account setup for the main user, but you can add an
additional one by following the following steps (repeat as many times as necessary):
adduser [username]
1. Samba allows you to create shares on your Ubuntu server that are visible from
Windows PCs on your network. We plan to install Samba for two reasons; (1) so that
the recordings made by MythTV can be made easily available across the network to
Windows PCs that are not running a MythTV Front-end, and (2) so that we can use
the server as a standard file server for holding work files. Below I show how to install
Samba and create accounts for two users that I intend giving access to. The passwords
that are created are for the Samba accounts only, and do not need to be the same
passwords that are used on the accounts for accessing the Ubuntu machine.
smbpasswd -a david
New SMB password: [enter password]
Retype new SMB password: [re-enter password]
smbpasswd -a niamh
New SMB password: [enter password]
Retype new SMB password: [re-enter password]
vi /etc/samba/smb.conf
Under the Share Definitions section, add the following definition. This will create a
writable share under the path /shared/ on your Ubuntu server. We will need to create
this directory and set the permissions so that users can read and write appropriately.
[share]
comment = Shared Network Drive
writable = yes
path = /shared
public = yes
mkdir –p /shared/david
mkdir –p /shared/niamh
chown david:david /shared/david
chown niamh:niamh /shared/niamh
/etc/init.d/samba restart
Test that you can connect to the server from Windows using \\192.168.2.100\share\
Page 10 of 46
Installing MythTV on Gutsy www.daviddn.com
1. The next step is to install the NVIDIA graphics drivers for Ubuntu Linux. The easiest
way to do this is to use the Envy script, which is an automated detection and
compilation script for NVIDIA and ATI drivers. The Envy script comes highly
recommended by me. The project is maintained at http://albertomilone.com/ and the
script provides a very quick and pain-free installation of the NVIDIA graphics driver.
2. Follow the steps below to install the drivers for your NVIDIA card. Also, note that
when you upgrade your kernel you will need to reinstall the NVIDIA driver again.
cd ~/
wget http://albertomilone.com/ubuntu/nvidia/scripts/legacy/envy_0.9.10-0ubuntu6_all.deb
dpkg -i envy_0.9.10-0ubuntu6_all.deb
envy -t
+-----------------------------------------------------------+
| Envy Menu ver.0.9.10 |
| |
| 1 - Install the NVIDIA driver |
| |
| 2 - Uninstall the NVIDIA driver |
| |
| 3 - Install the ATI driver |
| |
| 4 - Uninstall the ATI driver |
| |
| 5 - Install the ATI/NVIDIA driver Manually |
| |
| 6 - Clean the Installation of any Nvidia driver |
| |
| 7 - Restart the Xserver |
| |
| 8 - Restart your computer |
| |
| 9 - Exit |
| |
| NOTE: IF THE SCREEN TURNS BLACK, PLEASE TYPE ALT+F1 |
+-----------------------------------------------------------+
Please select one of the activities displayed above and press ENTER:
[1]
Do you want your xorg.conf to be automatically configured? (y/n) \ "y" is the default answer
[Y]
Do you want to restart your computer now (Recommended)? (y/n) \ "y" is the default answer
[Y]
Page 11 of 46
Installing MythTV on Gutsy www.daviddn.com
1. Unfortunately the Hauppauge WinTV Nova-T 500 PCI Card does not work out of the
box with Ubuntu Gutsy, you will need to install a revised version of the firmware to
get it operational. Firstly, prepare Aptitude by running the following commands:
2. Now download the latest version of the firmware from the website below and place it
into the /lib/firmware directory on your Ubuntu server (also available with this guide).
wget http://www.wi-bw.tfh-wildau.de/~pboettch/home/linux-dvb-firmware/dvb-usb-dib0700-1.10.fw
cp dvb-usb-dib0700-1.10.fw /lib/firmware
4. Download the Linux source (I’m using 2.6.22, but your version might be different):
cd ~/
hg clone http://linuxtv.org/hg/v4l-dvb
cd v4l-dvb
When the configuration screen appears you should disable the ACI mixer in the
Audio Devices for Multimedia section because this can sometimes cause errors in the
aci.c module when you compile the source code.
make
make install
6. Enable the onboard amplifier (if not already done) to prevent poor reception:
vi /etc/modprobe.d/options
{add}
options dvb-usb-dib0700 force_lna_activation=1
Page 12 of 46
Installing MythTV on Gutsy www.daviddn.com
make load
modprobe dvb-usb-dib0700
shutdown –h now
8. Check that the Tuner card loaded the firmware successfully. Type the following and
look for a line that says that the Hauppauge Nova-T 500 was successfully initialised.
9. You may also want to check for similar success with the Infrared receiver:
1. MPLAYER and Xine can be used by MythTV to play media content that is not
natively supported. For example, they can play MP4 files whereas MythTV currently
cannot. They can also be used to test that the Tuner card is operating correctly before
we install MythTV. Follow the instructions below to install these packages:
2. We now need to tune the TV Tuner card in to pick up the local DVB channels. I live
near to London in the UK so I use the Crystal Palace UK DVB-T configuration file
because it is able to detect my DVB channels well. You may need to use a different
settings file from that directory depending on which country/town you are nearest to.
cd ~/
mkdir /root/.tzap
cd /usr/share/doc/dvb-utils/examples/scan/dvb-t
scan uk-CrystalPalace > /root/.tzap/channels.conf
Page 13 of 46
Installing MythTV on Gutsy www.daviddn.com
3. From one terminal I now tune in to BBC One and leave it running:
4. From another terminal I launch the DVB stream into one of the media players I
installed (either MPLAYER or XINE). Both commands should be run from the local
machine, they will fail if you run the commands remotely from an SSH terminal.
or
You should now see the channel you selected above playing on your Linux machine.
Page 14 of 46
Installing MythTV on Gutsy www.daviddn.com
Installing MythTV
1. To install MythTV follow the instructions below. If you get errors when trying to
install MythTV via Aptitude then you may need to go back to the section entitled
Updating Aptitude and enable all the repositories that are listed and then try again.
2. During the installation you will be prompted to provide a root password for MySQL
(this is the database server that gets installed for MythTV to store its information into).
Pick a memorable password and write it down because you will need it later on.
3. You will also be asked if you would like to enable Remote Connections from other
MythTV front-ends on your network. Since you may want other machines on your
network to connect to your server for the purposes of watching television or films I
would advise you select yes for this option. Your broadband router should by default
not allow computers that are external (such as those on the Internet) to connect in.
4. After the installation completes, make sure that the Myth Backend is running:
/etc/init.d/mythtv-backend start
1. This process was documented during the installation of MythTV 0.20. However, the
process for MythTV 0.21 is almost identical and you should be able to use the guide
below equally well for MythTV 0.21 (although some options are on different screens).
2. From the desktop menu, select System / Administration / MythTV Backend Setup
3. You will be asked the following question; “You must be a member of the mythtv
group before starting any mythtv applications. Would you like to automatically be
added to the group?” Select OK, you will be encouraged to log out and back in again.
4. Once logged back in again, run the following command from the terminal:
Page 15 of 46
Installing MythTV on Gutsy www.daviddn.com
Question Response
Question Response
8. From the desktop menu, select System / Administration / MythTV Backend Setup.
You will be told that Mythbackend must be closed before continuing. You should
select OK and then the MythTV Language Configuration screen will appear:
Question Response
9. The next screen allows you to configure the Database. Fill in the details as below:
Question Response
Database mythconverg
User: mythtv
Page 16 of 46
Installing MythTV on Gutsy www.daviddn.com
10. The MythTV Backend configuration will start. You need to follow the instructions
below to detect and configure the TV Tuners cards, and to configure the TV sources.
Only the key configuration changes are included, the rest can be left as default.
Main Menu
Page 17 of 46
Installing MythTV on Gutsy www.daviddn.com
Main Menu
Select Capture Cards from the main menu
Capture Cards
Select (New Capture Card)
Page 18 of 46
Installing MythTV on Gutsy www.daviddn.com
Repeat the above process for the second Tuner on the Hauppauge
DVB-T 500 tuner card by specifying 1 as the DVB Card Number
Capture Cards
Your Capture Card screen should now look as shown on the left,
with two DVB cards selected - DVB:0 and DVB:1
Main Menu
Video Source
Select New Video Source
The channel frequency table and the listings grabber that you
select will typically depend on where you like, I live near London
in the UK so the settings above are appropriate for me.
Page 19 of 46
Installing MythTV on Gutsy www.daviddn.com
Video Sources
Main Menu
Select Input Connections from the Main Menu, this option allows
you to link a Capture Card to a Video Source. My configuration
has two Capture Cards, and I will link both to the TV video
source that I defined above.
Input Connections
Scan Type
Select Full Scan and the country that you live in (I live in the
United Kingdom), then click on Next
Page 20 of 46
Installing MythTV on Gutsy www.daviddn.com
Scanning
Wait patiently whilst the scan takes place, this can take up to 5
minutes on some systems depending on your computer
performance and on the strength of your TV signal.
Input Connections
11. After finishing with the settings you will be prompted if you would like to run
mythfilldatabase. You should select OK to this option and let the database be updated.
You may be asked for your root password during this process also.
1. From a terminal enter the following to reset the mythtv account password:
adm
admin
powerdev
3. Log out and then log in as the mythtv user to complete the following steps
4. From the desktop menu select Applications / Sound & Video / MythTV Frontend
5. The MythTV Frontend configuration will start. You now need to follow the
instructions below to configure the various components in order to watch TV. Again,
only the key configuration changes are shown below, the others can be left as default.
Page 21 of 46
Installing MythTV on Gutsy www.daviddn.com
Main Menu
Select Utilities / Setup from the main menu and then select Setup
from the Utilities menu. You will be then shown the screen below
Setup Menu
Database: mythconverg
User: mythtv
Audio
Audo output device: ALSA: default
General
System Exit Key: ESC (or you may want to disable it)
Page 22 of 46
Installing MythTV on Gutsy www.daviddn.com
General
Setup Menu
Theme
Theme: MythCenter-wide (my preference)
Paint Engine: Qt
Screen Settings
Configure the screen settings to match your TV output. I use the
defaults shown on the left. You should only change them if your
TV doesn’t line up the display correctly.
Page 23 of 46
Installing MythTV on Gutsy www.daviddn.com
Localisation
QT
Small Font: 12
Medium Font: 16
Big Font: 25
Page 24 of 46
Installing MythTV on Gutsy www.daviddn.com
1. Install the MythTV plugins package by following the instructions below. As part of
the installation you will be prompted whether or not you wish to password-protect
MythWeb. I would recommend that you do (we will also look at SSL security later).
/etc/init.d/apache2 restart
4. Place an empty index.html file into /var/www/ to prevent browsing your web-root:
touch /var/www/index.html
6. We now need to set the correct permissions on the directories we are referencing:
mkdir -p /var/lib/mythtv/videos
mkdir -p /var/lib/mythtv/videos-posters
chown mythtv:mythtv /var/lib/mythtv/videos
chown mythtv:mythtv /var/lib/mythtv/videos-posters
chmod 775 /var/lib/mythtv/videos
chmod 775 /var/lib/mythtv/videos-posters
Page 25 of 46
Installing MythTV on Gutsy www.daviddn.com
1. You will no doubt have media files that you have encoded into MPG or MP4 format
on your computer that you now want to view on your TV using MythTV. To be able
to access this content via MythTV you will need to follow the steps outlined below:
2. Firstly copy all the video media files into the directory /var/lib/mythtv/videos
cp *.mpg /var/lib/mythtv/videos
chown mythtv:mythtv /var/lib/mythtv/videos/*
3. Now follow these steps to load in the metadata and images for the videos from IMDB
Video Manager
The list of all the media you copied over should now appear in
the list. Click I (for Information) and the Action menu will appear
Action Menu
Action Menu
MythTV will search the IMDB and bring back a list of all the
possible matches for the video file. You should then select the
correct one from that list. If no match is found then you can
always input the IMDB number manually if you know it.
Next time you enter the Video Gallery the poster and the details
for your movie files will be available for browsing.
Page 26 of 46
Installing MythTV on Gutsy www.daviddn.com
1. To use the Hauppauge Remote Control that came with your tuner card you should
follow the steps below. Make sure that the remote receiver is plugged into the back of
your computer and that the remote control is within line-of-sight of the receiver.
cat /proc/bus/input/devices
2. Look for the entry for your remote control (it should look like that shown below):
3. Make a note of the Handlers line and the event (the input device the remote control is
using). My IR receiver uses event4. This can be tested by running the following
command and pressing some buttons on the remote control. Please note not to hit the
Power button on your remote because by default this will shut your machine down.
4. Install the required components for integrating MythTV with your remote control:
apt-get update
apt-get install lirc
/etc/lirc/hardware.conf
/etc/lirc/lircd.conf
/home/mythtv/.lircrc
6. Some of the settings from .lircrc require certain keyboard shortcuts to exist in
MythTV (for example ALT+H to jump to the Home Screen). You will need to
configure these in the Edit Keys section of the MythTV Settings menu.
7. Start the LIRC daemon and test the remote control keys:
8. Link the .lircrc file to the MythTV lircrc file and then start the Front-end to test:
ln -s /home/mythtv/.lircrc /home/mythtv/.mythtv/lircrc
Page 27 of 46
Installing MythTV on Gutsy www.daviddn.com
1. The purpose of this section is to configure the MythTV server so that it allows you to
play back video and TV without being interrupted by system sounds, screen savers
and other alerts commonplace on a computer that could spoil your viewing pleasure.
These steps should all be completed whilst logged in as the mythtv user.
2. From the Desktop menu select System / Preferences / Power Management. On the AC
Power Tab, slide the two sliders to the far right (the word #ever appears as below).
This will prevent the display turning off when you a watching a long TV program and
will prevent the computer sleeping and becoming unresponsive during TV playback.
3. On the General tab select Shutdown as the action for when the user presses the Power
button and Do #othing as the action for when the user presses the Suspend button.
4. From the Desktop menu select System / Preferences / Removable Media. Uncheck all
the auto-mount and auto-play features so that inserting a DVD or a removable hard-
disk into your MythTV server doesn’t cause the TV player to be disrupted.
Page 28 of 46
Installing MythTV on Gutsy www.daviddn.com
5. From the Desktop menu select System / Preferences / Sound Preferences. Ensure that
#o Sound is selected against each of the system sounds that are listed on the screen.
1. It is nice to have the MythTV Frontend run automatically when you power on your
MythTV server. In order to do this you will need to automate the log in of the mythtv
user. Follow the steps below to have the mythtv user automatically log in at boot:
vi /etc/gdm/gdm.conf-custom
[daemon]
AutomaticLoginEnable=true
AutomaticLogin=mythtv
2. Now, to ensure MythTV Front-end runs when the mythtv user logs in:
touch /home/mythtv/.gnomerc
chmod 755 /home/mythtv/.gnomerc
vi /home/mythtv/.gnomerc
Page 29 of 46
Installing MythTV on Gutsy www.daviddn.com
1. Some of your media may be in formats that are not natively supported under Linux.
Follow these steps to include support for CSS encrypted DVDs and Windows codecs.
First add the Medibuntu sources to Aptitude by issuing the following commands:
wget -q http://packages.medibuntu.org/medibuntu-key.gpg -O- | sudo apt-key add - && sudo apt-get update
2. Now install the components for DVD playback and the common Windows codecs
1. You may wish to secure some of the URLs on your web server with SSL encryption
so that information passed over the internet between your client PC and the MythTV
server (such as passwords) cannot be read or intercepted. This would be particularly
useful to help secure MythWeb. Follow the steps below to install and configure SSL.
Country Name: GB
State or Province: London
Locality: London
Organisation: DavOS
Organisational Unit Name: DavOS
Host Name: www.davos.co.uk
Email Address: webmaster@davos.co.uk
a2enmod ssl
Module ssl installed; run /etc/init.d/apache2 force-reload to enable.
3. Edit the ports configuration file so Apache listens for SSL connections on port 443:
vi /etc/apache2/ports.conf
Listen 80
<IfModule mod_ssl.c>
Listen 443
</IfModule>
Page 30 of 46
Installing MythTV on Gutsy www.daviddn.com
4. Copy the default configuration file so that it can be edited for the SSL configuration:
cp /etc/apache2/sites-available/default /etc/apache2/sites-available/ssl
ln -s /etc/apache2/sites-available/ssl /etc/apache2/sites-enabled/ssl
sudo a2ensite ssl
5. We now add rewrites to force certain URLs (on port 80) to use an SSL connection:
vi /etc/apache2/sites-available/default
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
RewriteEngine On
RewriteCond %{HTTPS} off
#RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteRule (/mythweb/*) https://%{HTTP_HOST}%{REQUEST_URI}
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
</VirtualHost>
Page 31 of 46
Installing MythTV on Gutsy www.daviddn.com
6. We now edit the SSL configuration to specify the certificate we will be using:
vi /etc/apache2/sites-available/ssl
NameVirtualHost *:443
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
SSLEngine On
SSLCertificateFile /etc/ssl/private/certname.pem
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
</VirtualHost>
7. Finally, reload Apache. You should be able to test the above configuration by
navigating to MythWeb on your MythTV server. A certificate will be displayed and
you will be redirected to use an HTTPS (SSL) connection instead of standard HTTP.
Page 32 of 46
Installing MythTV on Gutsy www.daviddn.com
1. The version of FFMPEG that comes as standard from the Ubuntu repositories has
been heavily crippled. In order to install FFMPEG with support for MP4 follow the
steps below. First use Aptitude to download and install the required libraries:
su
2. Use subversion to check out the latest source code for FFMPEG
cd
svn checkout -r 8998 svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
cd ffmpeg
make
4. Run checkinstall to configure and install FFMPEG. Make sure your settings are
comparable to the settings below. Please note that you will want to use your own
email address for the maintainer (this package will not be delivered externally).
checkinstall
0 - Maintainer: [ root@www.davos.co.uk ]
1 - Summary: [ Package created with checkinstall 1.6.1 ]
2 - Name: [ ffmpeg ]
3 - Version: [ 3:0.svn20080308 ]
4 - Release: [ 1 ]
5 - License: [ GPL ]
6 - Group: [ checkinstall ]
7 - Architecture: [ i386 ]
8 - Source location: [ ffmpeg ]
9 - Alternate source location: [ ]
10 - Requires: [ ]
ENTER to continue
Page 33 of 46
Installing MythTV on Gutsy www.daviddn.com
Installing Handbrake
2. Handbrake requires a relatively long command line to rip DVDs. I have therefore
written a script to wrap Handbrake and make it easier to rip directly into MythVideo.
The script, called /usr/local/bin/ripdvd, can be found in Appendix A of this guide.
Installing NFS
1. NFS will allow you to share the contents of your MythTV video and video-posters
directories on your local network so that other MythTV Front-ends can access and
use the same media content across the network. To install NFS on the server follow
the steps below. When you are asked whether to bind loopback you should say no.
2. To share the MythTV directory on the network you should do the following:
vi /etc/exports
{ADD}
/var/lib/mythtv *(ro,sync,no_subtree_check)
/etc/init.d/nfs-kernel-server restart
{ADD}
Page 34 of 46
Installing MythTV on Gutsy www.daviddn.com
Installing PHPMyAdmin
1. PHPMyAdmin will allow you to configure and manage MythTV directly from the
database. To install PHPMyAdmin you will need to visit the PHPMyAdmin website
at http://www.phpmyadmin.net/ and download the latest all-languages.zip file.
2. Place all-languages.zip into /var/www/ and run the following from a terminal:
cd /var/www
unzip phpMyAdmin-*-all-languages.zip
mv phpMyAdmin-*-all-languages phpmyadmin
rm phpMyAdmin-*-all-languages.zip
cd /var/www/phpmyadmin
mv config.sample.inc.php config.inc.php
vi config.inc.php
{CHANGE}
$cfg['blowfish_secret'] = 'hello';
4. You should now be able to log into PHPMyAdmin by entering your MythTV
database username and password into the site http://192.168.2.100/phpmyadmin
Page 35 of 46
Installing MythTV on Gutsy www.daviddn.com
1. When recordings have finished I use a script to encode those recordings into MP4 and
FLV format so that they can be played on my iPhone and on a networked computer.
If you also want this functionality then copy my mythencode.sh script from Appendix
A of this document to /usr/local/bin/ and then set the permissions on it as follows:
mkdir –p /var/www/tv/flv
mkdir –p /var/www/tv/icons
mkdir –p /var/www/tv/mp4
3. Create soft links from the shared directory to the MP4 directory:
mkdir -p /shared/media
chown mythtv:mythtv /shared/media
chmod 775 /shared/media
ln –s /var/www/tv/mp4 /shared/media/tv
Parameter Description
%DIR% The directory component of the recording's filename
%FILE% The filename component of the recording's filename
%TITLE% The title of the recording (e.g., name of the series)
%SUBTITLE% The subtitle of the recording (e.g., name of the episode)
%DESCRIPTION% The description text for the recording (from guide data)
%HOSTNAME% The backend making the recording
%CATEGORY% The category of the recording (from guide data)
%RECGROUP% The recording group
%CHANID% The MythTV channel ID making the recording
%STARTTIME% The recording start time (YYYYMMDDhhmmss)
%ENDTIME% The recording end time (YYYYMMDDhhmmss)
%PROGSTART% The recording's start time (from guide data)
%PROGEND% The recording's end time (from guide data)
Page 36 of 46
Installing MythTV on Gutsy www.daviddn.com
5. Run MythTV-Backend and select General, then on the Job Queue (Host-specific)
settings screen check the box that says Allow User #1 Jobs. Click #ext two times and
then enter the following in the User Job #1 Description and Command boxes:
Setting Value
AutoCommercialFlag 0
AutoExpireDefault 1
AutoExpireExtraSpace 1
AutoExpireLiveTVMaxAge 1
AutoRunUserJob1 1
AutoTranscode 0
8. The standard MythTV recordings will auto-delete themselves when disk space is
required, however the MP4 and FLV encoded versions will not. Therefore you will
need to use a script to delete old media to ensure that these files don’t fill up your file
system. The mythclean script in Appendix A is written by me for this purpose. Copy
it over to /usr/local/bin/ and then use the cron to schedule it to run every 24 hours.
Page 37 of 46
Installing MythTV on Gutsy www.daviddn.com
/usr/local/bin/mythencode.sh
This script is called by MythTV User Job 1 after it completes recording a television
program. It will encode the recording into MP4 and FLV format, and place those
resulting media files onto the network file server and onto the web server.
#!/bin/bash
#####################################################################################
#
# Encode MythTV Recording for iPod and FLV for Streaming
#
# author: David de Niese
#
# /usr/local/bin/mythencode.sh "%DIR%/%FILE%" "%TITLE%" "%STARTTIME%"
#
#####################################################################################
file=$1;
title=$2;
starttime=$3;
LOG=/tmp/mythencode.log
# Inform Log
# Check Parameters
if [ "$title" == "" ]
then
fi
if [ "$file" == "" ]
then
fi
if [ "$starttime" == "" ]
then
echo `date` - ERR - Script called incorrectly - No Start Time >> $LOG
exit 1
fi
if [ ! -r $file ]
then
echo `date` - ERR - Failed to read source file $file >> $LOG
exit 1;
fi
# Inform Log
Page 38 of 46
Installing MythTV on Gutsy www.daviddn.com
tmpmp4target=/tmp/mythenc.`basename $file`.mp4
tmpflvtarget=/tmp/mythenc.`basename $file`.flv
if [ -r $tmpmp4target ]
then
rm -f $tmpmp4target
if [ $? -ne 0 ]
then
echo `date` - ERR - Could not delete file $tmpmp4target >> $LOG
exit 1
fi
fi
if [ -r $tmpflvtarget ]
then
rm -f $tmpflvtarget
if [ $? -ne 0 ]
then
echo `date` - ERR - Could not delete file $tmpflvtarget >> $LOG
exit 1
fi
fi
ffmpeg -y -async 12 -i "$file" -ac 2 -ar 22050 -ab 128k -s 320x240 -vcodec mpeg4 -b 120k
-flags +aic+mv4+trell -mbd 2 -cmp 2 -subcmp 2 -g 250 -maxrate 512k -bufsize 2M -title "$title"
"$tmpmp4target" 2> /tmp/mythencode.ffmpeg.log
if [ $? -ne 0 ]
then
# Inform on Error
if [ -f "$tmpmp4target" ]
then
rm -f "$tmpmp4target"
fi
else
mv -f $tmpmp4target $mp4lantarget
chmod 664 $mp4lantarget
chown mythtv:www-data $mp4lantarget
echo `date` - INF - Performing MP4 Encoding Complete >> $LOG
# Create Thumbnail
fi
ffmpeg -y -async 12 -i $file -ac 2 -r 20 -s 320x240 -deinterlace -ar 22050 -aspect 4:3 -b 100k
$tmpflvtarget 2> /tmp/mythencode.ffmpeg.log
Page 39 of 46
Installing MythTV on Gutsy www.daviddn.com
if [ $? -ne 0 ]
then
# Inform on Error
# Delete File
if [ -f "$tmpflvtarget" ]
then
rm -f "$tmpflvtarget"
fi
else
mv -f $tmpflvtarget $flvlantarget
chmod 664 $flvlantarget
chown mythtv:www-data $flvlantarget
echo `date` - INF - Performing FLV Encoding Complete >> $LOG
fi
/usr/local/bin/mythclean.sh
This script is called daily by cron and will delete the files created by mythencode (see
above) after they become more than 7 days old. The FLV and MP4 files are encoded
versions of the original recordings, and the PNG files are the video thumbnails.
#!/bin/bash
#####################################################################################
#
# Clean MythTV Recordings for iPod and FLV
#
# author: David de Niese
#
#####################################################################################
# Set Correct Ownership on Media Files and Delete those over 7 days old
Page 40 of 46
Installing MythTV on Gutsy www.daviddn.com
/usr/local/bin/ripdvd
This script is used to wrap the functionality of Handbrake. It can be called from the
command line and will rip the DVD mounted from the DVD drive into MP4 format
and place it into the MythVideo directory (ready for it to be used by MythTV). If you
call this script with the parameter scan it will list the DVD titles available for ripping.
Otherwise you can call this script with the numeric title that you wish to rip.
#!/bin/bash
#####################################################################################
#
# Rip DVD
#
# author: David de Niese
#
#####################################################################################
HB=/usr/local/bin/HandBrakeCLI
if [ "$1" == "scan" ]
then
$HB -i /media/cdrom -t 0
exit
fi
TITLE = 0
if [ "$1" != "" ]
then
if [ $? -eq 1 ]
then
if [ $1 -lt 10 ]
then
if [ $1 -gt 0 ]
then
TITLE=$1
echo Setting Title as $1
fi
fi
fi
fi
# Check Parameters
if [ "$moviename" == "" ]
then
fi
Page 41 of 46
Installing MythTV on Gutsy www.daviddn.com
# Check if it Exists
if [ -r $outputfile ]
then
fi
if [ $TITLE -ne 0 ]
then
else
fi
if [ $? –ne 0 ]
then
rm –f "$outputfile”
fi
/etc/lirc/hardware.conf
This configuration file tells LIRC which device the Remote Control is using.
LIRCD_ARGS=""
START_LIRCMD=false
LOAD_MODULES=true
DRIVER="dev/input"
DEVICE="/dev/input/event4"
MODULES=""
LIRCD_CONF=""
LIRCMD_CONF=""
Page 42 of 46
Installing MythTV on Gutsy www.daviddn.com
/etc/lirc/lircd.conf
This configuration file maps the data values coming from the Hauppauge WinTV
DVB T-500 remote control to button names that can be used with LIRC.
begin remote
name hauppauge_nova_t_uk
bits 16
eps 30
aeps 100
one 0 0
zero 0 0
pre_data_bits 16
pre_data 0x8001
gap 135803
toggle_bit 0
begin codes
Go 0x0162
Power 0x0074
TV 0x0179
Videos 0x0189
Music 0x0188
Pictures 0x00E2
Guide 0x016D
Radio 0x0181
ArrowUp 0x0067
ArrowLeft 0x0069
OK 0x0160
ArrowRight 0x006A
ArrowDown 0x006C
BackExit 0x009E
Menu 0x008B
VolumeUp 0x0073
VolumeDown 0x0072
PrevCh 0x016B
Mute 0x0071
ChannelUp 0x0192
ChannelDown 0x0193
Record 0x00A7
Rewind 0x00A8
SkipBack 0x0195
Play 0x00CF
Pause 0x0077
Stop 0x0080
Fwdwind 0x00D0
SkipFwd 0x0197
1 0x0002
2 0x0003
3 0x0004
4 0x0005
5 0x0006
6 0x0007
7 0x0008
8 0x0009
9 0x000A
Star 0x0037
0 0x000B
# 0x0029
Red 0x018E
Green 0x018F
Yellow 0x0190
Blue 0x0191
end codes
end remote
Page 43 of 46
Installing MythTV on Gutsy www.daviddn.com
/home/mythtv/.lircrc
This configuration file converts the buttons from the remote to commands in MythTV
begin
prog = mythtv
button = Go
config = ALT+H
end
begin
prog = mythtv
button = TV
config = ALT+T
end
begin
prog = mythtv
button = Videos
config = ALT+V
end
begin
prog = mythtv
button = Guide
config = s
end
begin
prog = mythtv
button = ArrowUp
repeat = 3
config = Up
end
begin
prog = mythtv
button = ArrowLeft
repeat = 3
config = Left
end
begin
prog = mythtv
button = ArrowRight
repeat = 3
config = Right
end
begin
prog = mythtv
button = ArrowDown
repeat = 3
config = Down
end
begin
prog = mythtv
button = 1
config = 1
end
begin
prog = mythtv
button = 2
config = 2
end
begin
prog = mythtv
button = 3
config = 3
end
begin
prog = mythtv
button = 4
config = 4
end
begin
prog = mythtv
button = 5
config = 5
end
begin
prog = mythtv
button = 6
config = 6
end
Page 44 of 46
Installing MythTV on Gutsy www.daviddn.com
begin
prog = mythtv
button = 7
config = 7
end
begin
prog = mythtv
button = 8
config = 8
end
begin
prog = mythtv
button = 9
config = 9
end
begin
prog = mythtv
button = BackExit
config = Esc
end
begin
prog = mythtv
button = 0
config = 0
end
begin
prog = mythtv
button = VolumeUp
repeat = 3
config = F11
end
begin
prog = mythtv
button = VolumeDown
repeat = 3
config = F10
end
begin
prog = mythtv
button = OK
config = Return
end
begin
prog = mythtv
button = Mute
config = F9
end
begin
prog = mythtv
button = ChannelUp
config = Up
end
begin
prog = mythtv
button = ChannelDown
config = Down
end
begin
prog = mythtv
button = Record
config = R
end
begin
prog = mythtv
button = Rewind
config = Left
end
begin
prog = mythtv
button = SkipBack
config = PgUp
end
begin
prog = mythtv
button = Play
config = P
end
Page 45 of 46
Installing MythTV on Gutsy www.daviddn.com
begin
prog = mythtv
button = Pause
config = P
end
begin
prog = mythtv
button = Stop
config = Esc
end
begin
prog = mythtv
button = Fwdwind
config = Right
end
begin
prog = mythtv
button = SkipFwd
config = PgDown
end
Page 46 of 46