Installing MythTV 0.20 on Ubuntu Gutsy 7.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. 1. Ubuntu Gutsy 7.10 desktop CD (available from www.ubuntu.net) 2. Hardware that is identical or comparable to that specified below
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. Processor Motherboard Memory Graphics Card Media Drives Tuner Card Network Remotes
: : : : : : : :
AMD Athlon 64 X2 dual core processor nFORCE 4M-A ATX 2GB DDR2 RAM chip nVidia GeForce 7200 Series LG DVD/CD re-writer internal drive Hauppauge WinTV Nova T-500 dual tuner Devolo Highspeed Ethernet Starter Kit (better than using Wireless) iPhone/iTouch, or use the remote that accompanied the Tuner
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 ISTALLIG MYTHTV 0.20 O UBUTU GUTSY 7.10
1
DOCUMET PURPOSE REQUIREMETS EXAMPLE HARDWARE TABLE OF COTETS
1 1 1 3
ISTALLIG THE BASE SYSTEM
5
ISTALLIG UBUTU EABLIG THE ROOT USER COFIGURIG THE ETWORK UPDATIG APTITUDE ISTALLIG A SSH SERVER ISTALLIG THE GEERIC SERVICES AD TOOLS ISTALLIG A ETWORK TIME PROTOCOL SERVER
5 6 7 8 9 9 9
ISTALLIG THE FILE SERVER COMPOETS
10
CREATIG USER ACCOUTS ISTALLIG SAMBA FILE SHARIG DAEMO
10 10
COFIGURIG THE VIDEO HARDWARE
11
ISTALLIG THE VIDIA GRAPHICS DRIVERS ISTALLIG FIRMWARE FOR THE HAUPPAUGE WITV OVA-T 500 TESTIG THE HAUPPAUGE WITV OVA-T 500
11 12 13
ISTALLIG MYTHTV
15
ISTALLIG MYTHTV SERVER COFIGURIG MYTHTV BACKED COFIGURIG MYTHTV FROTED ISTALLIG MYTHTV PLUGIS COPYIG OVER YOUR MEDIA FILES TO MYTHTV COFIGURE THE HAUPPAUGE REMOTE COTROL
15 15 21 25 26 27
ADDIG THE FIISHIG TOUCHES
28
COFIGURIG THE DESKTOP USER ITERFACE COFIGURIG AUTOMATIC LOGI AD START UP OF MYTHTV FROT-ED ADDIG SUPPORT FOR DVD PLAYBACK AD RESTRICTED FORMATS SECURE APACHE2 WITH SSL ISTALLIG FFMPEG WITH FULL MP4 SUPPORT ISTALLIG HADBRAKE ISTALLIG FS ISTALLIG PHPMYADMI SCRIPTS FOR ECODIG RECORDIGS TO IPHOE/ITOUCH FORMAT
28 29 30 30 33 34 34 35 36
Page 3 of 46
Installing MythTV on Gutsy
www.daviddn.com
APPEDIX A – COFIGURATIO FILES
38
/USR/LOCAL/BI/MYTHECODE.SH /USR/LOCAL/BI/MYTHCLEA.SH /USR/LOCAL/BI/RIPDVD /ETC/LIRC/HARDWARE.COF /ETC/LIRC/LIRCD.COF /HOME/MYTHTV/.LIRCRC
38 40 41 42 43 44
Page 4 of 46
Installing MythTV on Gutsy
www.daviddn.com
Installing the base System Installing Ubuntu 1. Install the hardware, insert the Ubuntu Gutsy CD into the DVD-drive and boot the PC 2. Highlight “Start or Install Ubuntu” and press F6 (Other Options) 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. 5. Select the language and region options for the installation
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.
Enabling the Root User 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. sudo passwd root [sudo] password for username: [enter password] Enter new UNIX password: [enter password] Retype new UNIX password: [enter password again] passwd: password updated successfully su Password: [enter the password you selected above]
Page 6 of 46
Installing MythTV on Gutsy
www.daviddn.com
Configuring the Network 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
Enter the following, which will give you a static IP of 192.168.2.100: 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 127.0.1.1 192.168.2.100
localhost mythtv www.davos.co.uk
Now set the hostname for the machine echo www.davos.co.uk > /etc/hostname /bin/hostname –F /etc/hostname
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
# Main Gutsy Repositories deb http://gb.archive.ubuntu.com/ubuntu/ gutsy main restricted deb-src http://gb.archive.ubuntu.com/ubuntu/ gutsy main restricted # Major Bug Fixes deb http://gb.archive.ubuntu.com/ubuntu/ gutsy-updates main restricted deb-src http://gb.archive.ubuntu.com/ubuntu/ gutsy-updates main restricted # Universe Repositories deb http://gb.archive.ubuntu.com/ubuntu/ gutsy universe deb-src http://gb.archive.ubuntu.com/ubuntu/ gutsy universe deb http://gb.archive.ubuntu.com/ubuntu/ gutsy-updates universe deb-src http://gb.archive.ubuntu.com/ubuntu/ gutsy-updates universe # Unsupported Multiverse deb http://gb.archive.ubuntu.com/ubuntu/ gutsy multiverse deb-src http://gb.archive.ubuntu.com/ubuntu/ gutsy multiverse deb http://gb.archive.ubuntu.com/ubuntu/ gutsy-updates multiverse deb-src http://gb.archive.ubuntu.com/ubuntu/ gutsy-updates multiverse # Backports deb http://gb.archive.ubuntu.com/ubuntu/ gutsy-backports main restricted universe multiverse deb-src http://gb.archive.ubuntu.com/ubuntu/ gutsy-backports main restricted universe multiverse # Canonical's Partner repository deb http://archive.canonical.com/ubuntu gutsy partner deb-src http://archive.canonical.com/ubuntu gutsy partner # Restricted Security Repositories deb http://security.ubuntu.com/ubuntu gutsy-security main restricted deb-src http://security.ubuntu.com/ubuntu gutsy-security main restricted deb http://security.ubuntu.com/ubuntu gutsy-security universe deb-src http://security.ubuntu.com/ubuntu gutsy-security universe deb http://security.ubuntu.com/ubuntu gutsy-security multiverse deb-src http://security.ubuntu.com/ubuntu gutsy-security multiverse
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. sudo apt-get update sudo apt-get –y upgrade
Page 8 of 46
Installing MythTV on Gutsy
www.daviddn.com
Installing an SSH Server 1. Install an SSH server so that you can use a SSH client to access the PC: sudo apt-get –y install ssh
Installing the Generic Services and Tools 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). sudo apt-get –y install unzip zip curl fetchmail libarchive-zip-perl zlib1g-dev libpopt-dev nmap openssl lynx gcc flex make ncftp libdb4.3-dev rar wput apt-file sysutils
2. Remove some of the inet services that are not required on a MythTV server: update-inetd update-inetd update-inetd update-inetd update-inetd update-inetd update-inetd update-inetd
--remove --remove --remove --remove --remove --remove --remove --remove
daytime telnet time finger talk ntalk ftp discard
Installing a Network Time Protocol Server 1. Install ntpdate to enable your clock to be automatically synchronised with an Internet Time server using NTP (Network Time Protocol). It is important for your clock to be correct for timed recordings, otherwise you may miss programs you want to record. sudo apt-get –y install ntpdate /etc/network/if-up.d/ntpdate
2. Add the ntpdate check to the weekly schedule: 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
Installing the File Server Components Creating User Accounts 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]
Installing Samba File Sharing Daemon 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. sudo apt-get -y install samba samba-doc smbclient smbfs 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 mkdir chown chown
–p /shared/david –p /shared/niamh david:david /shared/david 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
Configuring the Video Hardware Installing the NVIDIA Graphics Drivers 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. Install the dependencies: apt-get install html2text po-debconf debhelper dh-make dpatch fakeroot libstdc++5 module-assistant xserver-xorg-dev gettext intltool-debian gcc-3.3-base
Download and run Envy: 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
Installing Firmware for the Hauppauge WinTV Nova-T 500 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: sudo apt-get update sudo apt-get upgrade sudo apt-get dist-upgrade
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
3. Install the packages to build the Kernel modules: apt-get -y install linux-headers-$(uname -r) build-essential apt-get -y install mercurial
4. Download the Linux source (I’m using 2.6.22, but your version might be different): apt-get -y install linux-source cd /usr/src/ tar -xjvf linux-source-2.6.22.tar.bz2 ln -s /usr/src/linux-source-2.6.22 /lib/modules/$(uname -r)/source
5. Install the Video for Linux DVB drivers: cd ~/ hg clone http://linuxtv.org/hg/v4l-dvb cd v4l-dvb apt-get -y install ncurses-dev make menuconfig
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
7. Load the modules and reboot the machine 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. dmesg | grep dvb [ 12.972000] dvb-usb: [ 13.044000] dvb-usb: [ 13.780000] dvb-usb: [ 13.780000] dvb-usb: [ 14.392000] dvb-usb: [ 14.960000] dvb-usb: [ 14.960000] dvb-usb: [ 14.960000] usbcore:
found a 'Hauppauge Nova-T 500 Dual DVB-T' in cold state, will try to load a firmware downloading firmware from file 'dvb-usb-dib0700-1.10.fw' found a 'Hauppauge Nova-T 500 Dual DVB-T' in warm state. will pass the complete MPEG2 transport stream to the software demuxer. will pass the complete MPEG2 transport stream to the software demuxer. schedule remote query interval to 150 msecs. Hauppauge Nova-T 500 Dual DVB-T successfully initialized and connected. registered new interface driver dvb_usb_dib0700
9. You may also want to check for similar success with the Infrared receiver: dmesg | grep DVB [ 12.972000] dvb-usb: found a 'Hauppauge Nova-T 500 Dual DVB-T' in cold state, will try to load a firmware [ 13.780000] dvb-usb: found a 'Hauppauge Nova-T 500 Dual DVB-T' in warm state. [ 13.780000] DVB: registering new adapter (Hauppauge Nova-T 500 Dual DVB-T) [ 13.892000] DVB: registering frontend 0 (DiBcom 3000MC/P)... [ 14.392000] DVB: registering new adapter (Hauppauge Nova-T 500 Dual DVB-T) [ 14.400000] DVB: registering frontend 1 (DiBcom 3000MC/P)... [ 14.960000] input: IR-receiver inside an USB DVB receiver as /class/input/input4 [ 14.960000] dvb-usb: Hauppauge Nova-T 500 Dual DVB-T successfully initialized and connected.
Testing the Hauppauge WinTV Nova-T 500 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: sudo apt-get upgrade sudo apt-get install dvb-utils dvbstream sudo apt-get install xine-ui mplayer
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 0x6000 0x6a00: pmt_pid 0x03f0 Channel 4 TV -- Film4 (running) 0x6000 0x6780: pmt_pid 0x0402 BBC -- BBC World Sv. (running) 0x6000 0x6a80: pmt_pid 0x03f2 Camelot Group plc -- Lottery Xtra (running) Network Name 'Crystal Palace' dumping lists (104 services) Done.
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: tzap –r "BBC ONE"
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. dvbstream -o -ps 600 601 -qam 16 -cr 3_4 | mplayer – or dvbstream -o -ps 600 601 -qam 16 -cr 3_4 | gxine stdin://mpeg2
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 Installing MythTV Server 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. sudo apt-get update sudo apt-get install mythtv mythtv-themes
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
Configuring MythTV Backend 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: sudo dpkg-reconfigure mythtv-database
Page 15 of 46
Installing MythTV on Gutsy
www.daviddn.com
5. Enter the following responses for the questions below: Question
Response
MySQL Server
localhost
MySQL Administration Account
root
Will you be using other computers running MythTV?
Yes
6. Next run the following command from the terminal: sudo dpkg-reconfigure mythtv-common
7. Enter the following responses for the questions below: Question
Response
What database should be used to hold MythTV data?
mythconverg
What username should MythTV use?
mythtv
What password should MythTV use?
[use password in /etc/mythtv/mysql.txt]
On what host does the MySQL server reside?
localhost
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
Select your preferred language
English (British)
9. The next screen allows you to configure the Database. Fill in the details as below: Question
Response
Host name
localhost
Database
mythconverg
User:
mythtv
Password:
[use password in /etc/mythtv/mysql.txt]
Database Type
MySQL
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 Select General from the main menu
Host Address Backend Setup IP address for Host:
192.168.2.100
Port Server runs on:
6543
Port Server status:
6544
Master Server IP:
192.168.2.100
Port Master Server:
6543
Host-specific Backend Setup Directory to hold recordings:
/var/lib/mythtv/recordings
Global Backend Setup TV Format:
PAL (I’m in the UK)
VBI Format:
None
Channel Frequency:
Europe-west
Time offset for listings:
None
EIT Scanner Options Time offset for EIT listings:
Auto
EIT Transport Timeout (mins):
5
Cross Source EIT:
[Unchecked]
Backend Idle Before EIT Crawl:
60
Page 17 of 46
Installing MythTV on Gutsy
www.daviddn.com Job Queue (Host-specific) Maximum simultaneous jobs:
1
Job Queue Check Frequency:
60
Job Queue Start Time:
00:00
Job Queue End Time:
23:59
CPU Usage:
Medium
Job Queue (Global): Run Jobs only on original host:
[Unchecked]
Start Auto-commercial flagging:
[Unchecked]
Commercial Flagger command:
mythcommflag
Transcoder command:
mythtranscode
Job Queue (Job Commands): User Job #1 Description:
User Job #1
User Job #1 Command:
[blank]
We will be setting the details for User Job #1 later on…
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 Capture Card Setup Card Type:
DVB DTV capture card
DVB Card Number:
0 (the first on the Dual)
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 Select Video Sources from the main menu
Video Source Select New Video Source
Video Source Setup Video Source Name:
TV
Listings Grabber:
Transmitted EIT
Channel frequency table:
Europe-west
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 Your finished Video Sources screen should look like this.
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 Select the first Input Connection to configure it.
Connect Source to Input Select the TV video source and then click on Scan for Channels
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 When complete you should have assigned both your DVB capture cards to the TV video source (see image on the left)
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.
Configuring MythTV Frontend 1. From a terminal enter the following to reset the mythtv account password: sudo passwd mythtv Enter new UNIX password: [enter a password] Retype new UNIX password: [enter a password] passwd: password updated successfully
2. Edit /etc/group and add mythtv to the following groups: 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 Select General from the Setup menu
Database Configuration (1/2) Host name:
localhost
Database:
mythconverg
User:
mythtv
Password:
[password from /etc/mythtv/mysql.txt]
Database Type:
MySQL
Audio Audo output device:
ALSA: default
Passthrough device:
Default
Use Internal volume:
[checked]
Mixer Device:
/dev/mixer
Mixer Controls:
PCM
Master Mixer Volume:
90
PCM Mixer Volume:
100
General System Exit Key:
ESC (or you may want to disable it)
Confirm Exit:
[checked]
Enable Network Remote: [checked] Network Remote Port:
Page 22 of 46
6546
Installing MythTV on Gutsy
www.daviddn.com General Require Setup PIN:
[unchecked]
Setup Pin Code:
[blank]
Monitor CD/DVD:
[unchecked]
Enable Xbox hardware:
[unchecked]
Myth Database Logging Log MythTV events:
[unchecked]
Maximum Entries:
100
Setup Menu Select Appearance and press Enter
Theme Theme:
MythCenter-wide (my preference)
Paint Engine:
Qt
Qt Style:
Desktop style
Font size:
default
Menu theme:
classic
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 Video Mode Settings Uncheck the option on this screen and click on Next
Localisation Language:
English (British)
Guide Language#1:
English
Guide Language#2:
English
Data Format:
Fri 7 Mar
Short Date Format:
07/03
Time Format:
11:42 PM
QT Small Font:
12
Medium Font:
16
Big Font:
25
Use Transparent Boxes:
[unchecked]
Background Shading:
Fill
Use Line Edit Virtual:
[unchecked]
LCD Device Display Enable LCD device:
[unchecked]
MythTV Main Menu MythTV will restart and the main menu should appear.
Page 24 of 46
Installing MythTV on Gutsy
www.daviddn.com
Installing MythTV Plugins 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). sudo apt-get -y install mythplugins
2. Restart your web server for the changes to be picked up in MythWeb: /etc/init.d/apache2 restart
3. Test the MythWeb installation by navigating to http://192.168.2.100/mythweb/ 4. Place an empty index.html file into /var/www/ to prevent browsing your web-root: touch /var/www/index.html
5. Configure MythVideo by following starting MythTV Frontend, navigating to Setup / Video Settings / General Settings and then entering the information shown below: General Settings (1/2) Directory that holds videos:
/var/lib/mythtv/videos
Directory that holds posters:
/var/lib/mythtv/videos-posters
Default View:
Gallery
General Settings (2/2) Show Unknown File Types:
[unchecked]
Video Browser browses files:
[unchecked]
Video Gallery browses files:
[unchecked]
Video List browses files:
[unchecked]
Newly scanned are browsable:
[checked]
Sorting ignores case:
[checked]
6. We now need to set the correct permissions on the directories we are referencing: mkdir mkdir chown chown chmod chmod
-p /var/lib/mythtv/videos -p /var/lib/mythtv/videos-posters mythtv:mythtv /var/lib/mythtv/videos mythtv:mythtv /var/lib/mythtv/videos-posters 775 /var/lib/mythtv/videos 775 /var/lib/mythtv/videos-posters
Page 25 of 46
Installing MythTV on Gutsy
www.daviddn.com
Copying over your Media Files to MythTV 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 MythTV Main Menu Select Videos, then select Video Manager
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 Select Search IMDB from the Action menu. You can alternatively enter the IMDB number manually if you know it.
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
Configure the Hauppauge Remote Control 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): I: N: P: S: H: B: B:
Bus=0003 Vendor=2040 Product=9950 Version=0100 Name="IR-receiver inside an USB DVB receiver" Phys=usb-0000:01:08.2-1/ir0 Sysfs=/class/input/input4 Handlers=kbd event4 EV=3 KEY=14afc336 284284d 0 0 0 4 80058000 2190 40000801 9e96c0 0 900200 ffd
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. sudo evtest /dev/input/event4
4. Install the required components for integrating MythTV with your remote control: apt-get update apt-get install lirc
5. Copy over the following files from Appendix A of this document /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: sudo /etc/init.d/lirc start irw
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
Adding the Finishing Touches Configuring the Desktop User Interface 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 harddisk 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.
Configuring Automatic Login and Start up of MythTV Front-end 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
{add under the daemon section} [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
sleep 5 && mythfrontend > /tmp/mythfrontend.log 2>&1 &
Page 29 of 46
Installing MythTV on Gutsy
www.daviddn.com
Adding Support for DVD Playback and Restricted Formats 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 http://www.medibuntu.org/sources.list.d/gutsy.list -O /etc/apt/sources.list.d/medibuntu.list 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 sudo apt-get -y install ubuntu-restricted-extras sudo apt-get –y install libdvdcss2 sudo apt-get –y install w32codecs
Secure Apache2 with SSL 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. sudo apt-get install openssl sudo apt-get install ssl-cert
2. Now create an SSL certificate for your website: make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/ssl/private/certname.pem Country Name: GB State or Province: London Locality: London Organisation: DavOS Organisational Unit Name: DavOS Host Name: www.davos.co.uk Email Address:
[email protected] 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
Listen 443
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
ServerAdmin webmaster@localhost DocumentRoot /var/www/ RewriteEngine On RewriteCond %{HTTPS} off #RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} RewriteRule (/mythweb/*) https://%{HTTP_HOST}%{REQUEST_URI} Options FollowSymLinks AllowOverride None Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all ErrorLog /var/log/apache2/error.log LogLevel warn CustomLog /var/log/apache2/access.log combined ServerSignature On Alias /doc/ "/usr/share/doc/" Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128
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
ServerAdmin webmaster@localhost DocumentRoot /var/www/ SSLEngine On SSLCertificateFile /etc/ssl/private/certname.pem Options FollowSymLinks AllowOverride None Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all ErrorLog /var/log/apache2/error.log LogLevel warn CustomLog /var/log/apache2/access.log combined ServerSignature On Alias /doc/ "/usr/share/doc/" Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128
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. sudo /etc/init.d/apache2 force-reload
Page 32 of 46
Installing MythTV on Gutsy
www.daviddn.com
Installing FFMPEG with full MP4 support 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 apt-get -y build-dep ffmpeg apt-get -y install liblame-dev libfaad2-dev libfaac-dev libxvidcore4-dev liba520.7.4 liba52-0.7.4-dev libx264-dev checkinstall build-essential subversion
2. Use subversion to check out the latest source code for FFMPEG cd svn checkout -r 8998 svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
3. Configure and make FFMPEG cd ffmpeg ./configure --enable-gpl --enable-pp --enable-libvorbis --enable-libogg --enableliba52 --enable-dc1394 --enable-libgsm --disable-debug --enable-libmp3lame -enable-libfaad --enable-libfaac --enable-xvid --enable-pthreads --enable-x264 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 Should I create a default set of package docs? [y]: This package will be built according to these values: 0 1 2 3 4 5 6 7 8 9 10 -
Maintainer: [
[email protected] ] Summary: [ Package created with checkinstall 1.6.1 ] Name: [ ffmpeg ] Version: [ 3:0.svn20080308 ] Release: [ 1 ] License: [ GPL ] Group: [ checkinstall ] Architecture: [ i386 ] Source location: [ ffmpeg ] Alternate source location: [ ] Requires: [ ]
ENTER to continue
Page 33 of 46
Installing MythTV on Gutsy
www.daviddn.com
Installing Handbrake 1. Handbrake is a superb DVD ripper for Linux. To install it go to the Handbrake website at http://handbrake.fr/ and download the Linux version to your user home directory. Now follow the steps below from a Terminal to install it: tar -xzvf HandBrake-0.9.2_i386.tar.gz sudo cp HandBrakeCLI /usr/local/bin
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. sudo apt-get install nfs-kernel-server nfs-common portmap sudo dpkg-reconfigure portmap sudo /etc/init.d/portmap restart
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
3. Now on the client machines (such as on your MythTV front-ends): apt-get install portmap nfs-common sudo vi /etc/fstab
{ADD} 192.168.2.100:/var/lib/mythtv /var/lib/mythtv nfs rw,hard,intr 0 0
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
3. Change the PHPMyAdmin configuration file by adding the blowfish secret: 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
Scripts for Encoding Recordings to iPhone/iTouch format 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: chmod 755 /usr/local/bin/mythencode.sh
2. Create the directories required for the encoded media files: mkdir –p /var/www/tv/flv mkdir –p /var/www/tv/icons mkdir –p /var/www/tv/mp4 chown mythtv:mythtv /var/www/tv/flv chown mythtv:mythtv /var/www/tv/icons chown mythtv:mythtv /var/www/tv/mp4 chmod 775 /var/www/tv/flv chmod 775 /var/www/tv/icons chmod 775 /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
4. We now need to add mythencode.sh as a User Job in MythTV so that it runs by default after a recording finishes. The script will then encode that recording into MP4 and FLV format and publish the files onto the shared drive and onto the web server. When adding a User Job to MythTV you can use any of the following variables: 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: /usr/local/bin/mythencode.sh "%FILE%" "%TITLE%" "%STARTTIME%"
6. Go to MythWeb (http://192.168.2.100/mythweb/), then go to the Setting page and click MythTV Settings Table. Now enter the following information into the table: Setting
Value
AutoCommercialFlag
0
AutoExpireDefault
1
AutoExpireExtraSpace
1
AutoExpireLiveTVMaxAge
1
AutoRunUserJob1
1
AutoTranscode
0
7. Now save your settings and close MythWeb. 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. chmod 755 /usr/local/bin/mythclean
Page 37 of 46
Installing MythTV on Gutsy
www.daviddn.com
APPENDIX A – Configuration Files This appendix contains configuration and script files for key components referenced throughout the main MythTV Installation guide. The filename for each configuration file is shown above each listing. To install these configuration files and scripts simply copy the contents of the listing into the filename specified.
/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%" # ##################################################################################### # Grab File Title and Start Time file=$1; title=$2; starttime=$3; # Grab Log Reference LOG=/tmp/mythencode.log # Inform Log echo `date` - INF - Starting Encoding Job >> $LOG # Check Parameters if [ "$title" == "" ] then echo `date` - ERR - Script called incorrectly - No Title >> $LOG exit 1 fi if [ "$file" == "" ] then echo `date` - ERR - Script called incorrectly - No Filename >> $LOG exit 1 fi if [ "$starttime" == "" ] then echo `date` - ERR - Script called incorrectly - No Start Time >> $LOG exit 1 fi
# Check File Exists if [ ! -r $file ] then echo `date` - ERR - Failed to read source file $file >> $LOG exit 1; fi # Inform Log echo `date` - INF - Encoding $file >> $LOG echo `date` - INF - Title is $title >> $LOG
Page 38 of 46
Installing MythTV on Gutsy
www.daviddn.com
# Calculate MP4 Destination Filename tmpmp4target=/tmp/mythenc.`basename $file`.mp4 tmpflvtarget=/tmp/mythenc.`basename $file`.flv mp4lantarget=$(echo "/var/www/tv/mp4/$starttime - $title.mp4" | tr "? " _ ) flvlantarget=$(echo "/var/www/tv/flv/$starttime - $title.flv" | tr "? " _ ) # Check Destination isnt already there 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 # Inform Log and Start MP4 Encoding echo `date` - INF - Performing MP4 Encoding >> $LOG 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 echo `date` - ERR - Failed MP4 Encoding >> $LOG cat /tmp/mythencode.ffmpeg.log >> $LOG if [ -f "$tmpmp4target" ] then rm -f "$tmpmp4target" fi else # Move File Successfully mv -f $tmpmp4target $mp4lantarget chmod 664 $mp4lantarget chown mythtv:www-data $mp4lantarget echo `date` - INF - Performing MP4 Encoding Complete >> $LOG # Create Thumbnail thumbfile=`basename $mp4lantarget | cut -d . -f 1` echo `date` - INF - Creating Thumbnail $thumbfile.jpg >> $LOG gnome-video-thumbnailer -s 100 "$mp4lantarget" "/var/www/tv/icons/$thumbfile.png" echo `date` - INF - Creating Thumbnail Complete >> $LOG fi
# Inform Log and Start FLV Encoding echo `date` - INF - Performing FLV Encoding >> $LOG 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 echo `date` - ERR - Could not Encode to FLV >> $LOG cat /tmp/mythencode.ffmpeg.log >> $LOG # Delete File if [ -f "$tmpflvtarget" ] then rm -f "$tmpflvtarget" fi else # Move File Successfully 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 chown mythtv:www-data /var/www/tv/flv/*.flv 2> /dev/null chmod 664 /var/www/tv/flv/*.flv 2> /dev/null find /var/www/tv/flv/*.flv -type f -mtime +7 -exec rm {} \; 2> /dev/null chown david:www-data /var/www/tv/mp4/*.mp4 2> /dev/null chmod 664 /var/www/tv/mp4/*.mp4 2> /dev/null find /var/www/tv/mp4/*.mp4 -type f -mtime +7 -exec rm {} \; 2> /dev/null chown david:www-data /var/www/tv/icons/*.png 2> /dev/null chmod 664 /var/www/tv/icons/*.png 2> /dev/null find /var/www/tv/icons/*.png -type f -mtime +7 -exec rm {} \; 2> /dev/null
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. /usr/local/bin/ripdvd scan /usr/local/bin/ripdvd 2
# Will list the titles available # Will rip title 2 from the DVD
#!/bin/bash ##################################################################################### # # Rip DVD # # author: David de Niese # ##################################################################################### # Check for Scan Parameter HB=/usr/local/bin/HandBrakeCLI if [ "$1" == "scan" ] then $HB -i /media/cdrom -t 0 exit fi TITLE = 0 if [ "$1" != "" ] then echo $1 |
grep -q [^[:digit:]]
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 # Grab File Title echo Enter name of Movie: read moviename # Check Parameters if [ "$moviename" == "" ] then echo `date` - ERR - Invalid Movie Name exit 1 fi moviename=$(echo "$moviename" | tr ' ' _) outputfile=/var/lib/mythtv/videos/$moviename.mp4 echo $outputfile
Page 41 of 46
Installing MythTV on Gutsy
www.daviddn.com
# Check if it Exists if [ -r $outputfile ] then echo `date` - ERR - Output file already exists exit 1 fi # Encode into MP4 Format if [ $TITLE -ne 0 ] then $HB -t $TITLE -i /media/cdrom -o $outputfile --preset "iPhone" else $HB -i /media/cdrom -o $outputfile --preset "iPhone" fi # Encode Down to MPG at 1Mbps ffmpeg -y -i "$outputfile" -b 1000k "/var/lib/mythtv/videos/$moviename.mpg" if [ $? –ne 0 ] then # Remove Original MP4 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 bits eps aeps
hauppauge_nova_t_uk 16 30 100
one 0 0 zero 0 0 pre_data_bits 16 pre_data 0x8001 gap 135803 toggle_bit 0 begin codes Go Power TV Videos Music Pictures Guide Radio ArrowUp ArrowLeft OK ArrowRight ArrowDown BackExit Menu VolumeUp VolumeDown PrevCh Mute ChannelUp ChannelDown Record Rewind SkipBack Play Pause Stop Fwdwind SkipFwd 1 2 3 4 5 6 7 8 9 Star 0 # Red Green Yellow Blue end codes
0x0162 0x0074 0x0179 0x0189 0x0188 0x00E2 0x016D 0x0181 0x0067 0x0069 0x0160 0x006A 0x006C 0x009E 0x008B 0x0073 0x0072 0x016B 0x0071 0x0192 0x0193 0x00A7 0x00A8 0x0195 0x00CF 0x0077 0x0080 0x00D0 0x0197 0x0002 0x0003 0x0004 0x0005 0x0006 0x0007 0x0008 0x0009 0x000A 0x0037 0x000B 0x0029 0x018E 0x018F 0x0190 0x0191
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 = button repeat config
mythtv = ArrowUp = 3 = Up
prog = button repeat config
mythtv = ArrowLeft = 3 = Left
prog = button repeat config
mythtv = ArrowRight = 3 = Right
prog = button repeat config
mythtv = ArrowDown = 3 = Down
end begin
end begin
end begin
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 = button repeat config
mythtv = VolumeUp = 3 = F11
prog = button repeat config
mythtv = VolumeDown = 3 = F10
end begin
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