Installing MythTV on Gentoo Linux

From Section6wiki

Jump to: navigation, search

Contents

Installing MythTV on Gentoo Linux

author: TBONIUS

MythTV is a GPL licensed suite of programs that allow you to build a Personal Video Recorder (PVR) system on your own using Open Source software and operating systems. Much like commercial systems such as Tivo, MythTV allows one to pause live TV, schedule recordings, and use a variety of media such as music CDs, DVDs, and digital photos as well. MythTV in its current incarnation runs on most GNU/Linux distributions. The distribution(s) of choice here at Section6 happen to be:


For the following article, we will use Gentoo Linux 2006 as the distribution of choice; the reason being that Gentoo offers very current versions of the MythTV packages.

Requirements

A computer with a minimum of a 1.8 ghz processor (2.8 recommended), 512MB RAM (1GB recommended), a working soundcard, a working ethernet interface, 80GB harddrive (The larger the harddrive, the better), a working DVD drive (DVD/RW recommended), NVidia Geforce4 or higher (with S-video out capabilities), and a Hauppauge WinTV GO capture card (PVR150 or higher recommended).

We will also need a single S-video cable to run into a television.. and a stereo mini-jack to RCA audio cable to run out of the soundcard into a television or stereo receiver/amplifier. (Note: if you are planning on using optical audio out for 5.1 or above, please consult the Alsa Documentation Wiki for your soundcard information and configuration.

Another thing covered in this document that you till need is the Hauppauge remote control that comes with the WinTV Go capture card. If you wish to use another type of remote control, consult the documentation for LIRC at the following URL:

The final thing we will need is a valid Zap2It account. the Zap2It service allows us to download and populate channel guide information for the area we live in. Accounts are free and require registration at the following URL:

Installing Gentoo

Although not as straight forward as the installations of such distributions as Ubuntu or Fedora, Gentoo documentation will help one overcome many of the complications of installation. If you are new to Gentoo Linux, please refer to the Gentoo Quick Install Guide

Configuring USE Flags for Portage

The USE flags for Gentoo are arguably the most important part of installation and configuration of the various packages that will be involved in the setup of MythTV. It is very important to configure these flags correctly in order to compile the ports we need with the correct options. The first file we will look at is /etc/portage/package.use

#/etc/portage/package.use 
media-tv/mythtv alsa opengl vorbis dvb dvd ieee1394 lirc mmx xvmc xv joystick
x11-libs/qt mysql opengl
dev-lang/php  dba gd session pcre mysql apache2 posix
media-video/mplayer divx4linux live mythtv win3codecs xvid alsa fbcon lirc joystick i8x0 mmx sse sse2 v4l xvmc encode dts dvb dvd dvdread dga opengl xv aac 
app-misc/lirc ~x86
dev-lang/php  dba gd session pcre mysql apache2 posix
media-plugins/mythdvd transcode
games-emulation/xmame joystick lirc
net-misc/tightvnc server
media-video/transcode dvdread dv mp3 imagemagick jpeg mjpeg mpeg ogg vorbis quicktime sse sse2 3dnow mmx v4l2 xvid xml a52 extrafilters truetype network media-video/mjpegtools yv12 dv

The next file we need to alter is the /etc/make.conf. Add the following lines to your make.conf file (Depending on the hardware you have):

#/etc/make.conf
USE="lirc"
LIRC_DEVICES="hauppauge"
ALSA_CARDS="snd-intel8x0"
VIDEO_CARDS="nvidia"

If you have different soundcards or videocards in your system, consult the Gentoo Make Wiki for more information on specifying your specific hardware.

MythTV pre-installation

At this point we need to install some software from the portage tree in order to get our system ready to install MythTV. There is a lot of prep work to do here, so patience is a must. Once we get past this hump we can move forward in getting MythTV configured and installed.

The first thing we must do is sync our portage tree:

root@host# emerge -sync

Then we must compile QT3 specific libraries with MySQL support:

root@host# emerge -1 =x11-libs/qt-3*

This will take quite a while.. but should compile cleanly for our hardware architecture. Next we must update our environment to make sure subesequent software compiles correctly:

root@host# env-update && source /etc/profile

Now we will perform the actuall installation of MythTV so that our package.use flags will pass the dependencies we specified to the compiler.

root@host# emerge -av mythtv

Again, this will take quite a while.. but the end result should be a nicely streamlined installation of MythTV. We can now move on to configuring the MySQL database.

Configuring MySQL

The MySQL database will house the guide data and various other backend database information that MythTV will require. Now that MySQL is installed, there are just a couple of steps we need in order to prepare the database for useage:

root@host# /etc/init.d/mysql start
root@host# rc-update add mysql default
root@host# mysql -u root -p < /usr/share/mythtv/database/mc.sql

Once the database has been created, we will grant permissions for the MythTV database account to use this database:

user@host# sudo mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 51 to server version: 5.0.26-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

This indicates that we are now in the MySQL command environment using the command line MySQL client that was installed earlier.

mysql> grant all privileges on mythconverg.* to 'mythtv'@'localhost' identified by 'password';

This command passed to the MySQL server will grant access to a database user called "mythtv" with a password of "password". Of course you can make the useraccount and password anything you want, but be sure and remember this information later when we go to configure MythTV to use this database account

After you create the account, simply type the following command to exit the MySQL command environment and return to your shell:

mysql> exit

Building LIRC

LIRC is a set of kernel modules and binaries that allow us to use a remote controle with our Linux System. To use our Hauppauge remote we should install LIRC. At the time of this article, the latest version of LIRC is 0.8.0.

root@host# emerge lirc

This should install lirc with the Hauppauge drive support we specified earlier in the make.conf file. After it is installed we now need to load the kernel module:

root@host# modprobe lirc_i2c

We can verify that it is loaded by checking the list of loaded modules:

root@host# lsmod |grep lirc_i2c*
lirc_i2c               11268  0
lirc_dev               15220  1 lirc_i2c
i2c_core               19072  6 cx88xx,bttv,i2c_algo_bit,tveeprom,lirc_i2c,i2c_acpi_ec

We also need to make sure the correct devices in /dev were created:

user@host# ls -al /dev/lirc*
srw-rw-rw- 1 root root  0 Feb 18 22:06 /dev/lircd
/dev/lirc:
total 0
drwxr-xr-x  2 root root    60 Feb 18 22:05 .
drwxr-xr-x 19 root root 13700 Feb 18 22:06 ..
crw-rw----  1 root root 61, 0 Feb 18 22:05 0

Now that we know the correct modules are loaded and the devices are present, we need to add a line to our /etc/modules.autoload.d/kernel-2.6 file to load the lirc_i2c and i2c_core modules.

#/etc/modules.autoload.d/kernel-2.6
i2c_core
lirc_i2c

We then run a few commands to make sure the module list is updated:

root@host# update-modules

We now need to configure it to start upon every reboot of the system:

root@host# /etc/init.d/lircd start
root@host# rc-update add lircd default

Now before we can start the service we need to configure the lircd.conf file to define our remote control buttons. Simply change to the /etc directory (create it if it does not exist), end edit the lircd.conf file to reflect the following example:

# /etc/lircd.conf file 
# This configuration file is for the newer Grey Hauppauge remotes
# If this file does not match your remote exactly..
# use the irw command to find your remote control button codes 
#
begin remote
name grayHauppauge
bits 13
flags RC5
eps 30
aeps 100
one 0 0
zero 0 0
gap 200966
repeat_bit 2
begin codes
Power 0x00000000000017BD
Go 0x0000000000001FBB
TV 0x000000000000179C
Videos 0x0000000000001F98
Music 0x0000000000001799
Pictures 0x0000000000001F9A
Guide 0x000000000000179B
Radio 0x0000000000001F8C
Up 0x0000000000001794
Left 0x0000000000001F96
Right 0x0000000000001797
Down 0x0000000000001F95
Ok 0x00000000000017A5
Back/Exit 0x0000000000001F9F
Menu 0x000000000000178D
Prev-Channel 0x0000000000001F92
Mute 0x000000000000178F
Vol+ 0x0000000000001F90
Vol- 0x0000000000001791
Ch+ 0x0000000000001FA0
Ch- 0x00000000000017A1
Record 0x0000000000001FB7
Stop 0x00000000000017B6
Rewind 0x0000000000001FB2
Forward 0x00000000000017B4
Play 0x0000000000001FB5
Previous 0x00000000000017A4
Next 0x0000000000001F9E
Pause 0x00000000000017B0
1 0x0000000000001F81
2 0x0000000000001782
3 0x0000000000001F83
4 0x0000000000001784
5 0x0000000000001F85
6 0x0000000000001786
7 0x0000000000001F87
8 0x0000000000001788
9 0x0000000000001F89
0 0x0000000000001780
star 0x0000000000001F8A
hash 0x000000000000178E
red 0x0000000000001F8B
green 0x00000000000017AE
yellow 0x0000000000001FB8
blue 0x00000000000017A9
end codes
end remote 

If the buttons listed above do match your remote control, you can either see other Hauppauge remote control configurations at http://lirc.sourceforge.net/remotes/hauppauge/, or you can find your remote button codes by running irw and pressing buttons on your remote to find the correct HEX values and configure them for the corresponding button names.

After creating the lircd.conf file we need to create a symbolic link from the /etc directory to our new lircd.conf file we just created:

Now we can start the lircd service:

root@host# /etc/init.d/lircd start
Starting lirc daemon: lircd.

Now that we have lirc running, let use move on to configuring and installing MythTV itself.


Configuring MythTV

Now that LIRC has been configured, we can finally move on to running myth and setting up its preferences. We should have a basic installation of Xorg installed and be able to run an ugly X server long enough to get Myth setup:

(Note: if you wish to run MythTV as another user besides root, create that user account and then log on as that use to run the MythSetup utility).

root@host# startx

Then from a terminal window, we can run the setup utility for MythTV. To do this, simply run the following command in the terminal window:

root@host# mythtv-setup

The MythTV menuing system has very attractive layout, but the navigation controls can leave a little bit to be desired. At this point we a re still using the keyboard to setup our MythTV system. Use the UP and DOWN arrow keys to navigate menu options. Use the LEFT and RIGHT arrow keys to change individual options. Use the ENTER key to select buttons such as "Next", "back", and "Finish". Use the ESC key to go back to previous menus or to cancel. Some individual settings may vary, but for the most part.. if you are using the same hardware listed in this tutorial.. you should be able to use these settings.

Database Configuration

Usually when MythTV setup first launches for the first time, it requests information for the database setup. If you are not prompted for this information, don't worry.. we can still configure it in the "mythfrontend" program. We must define this information before we can populate the guide data with the "mythfilldatabase" program.

Host name: localhost
Database: mythconverg 
User: mythtv
Password: password
Database Type: MySQL

Of course we would replace the username and password with whatever username and password you granted access to the "mythconverg" database earlier.

General

The only thing you might have to alter here is the option:

Directory to hold recordings

If you wish to alter this, just make sure the directory exists and that it is writable by the user that is running mythfrontend

Capture Cards

In this case we would create a new capture card setting and choose

Analog V4L capture card

The default choices for devices should work here (assuming your Hauppauge capture card is installed and detected by Ubuntu Linux).

Video Device: /dev/video0
VBI Device: /dev/vbi
Audio Device: /dev/dsp

Audio tends to be a topic of confusion for many people in dealing with MythTV. For now it is safe to use your default DSP device as your adio input, the reason being that we will use the mini cable that comes with the Hauppauge card to run from the audio out on the capture card to the line in on your sound card.

Default Input: Television

We need to make sure this is set to accept a signal on the "Television" Coaxial input for our Hauppauge capture card. If you plan on using the Composite Input, please consult the documentation for MythTV.

Video Sources

We also need to create a new Video Source. In this case we would name the Video Source something like "Television".

We also need to use the Zap2It account that we created earlier. In the "User ID" and "Password" boxes, we need to put in our Zap2It account information and then choose the "Retrieve Lineups" option to pull in the guide data for our area.

Input Connections

In this case, we would choose the "V4L:/dev/video0 (Television)->television" option. We need to create a display name for this connection and make sure the input for this connection is defined:

Display Name: television
Video Source: television

Once we have defined these options, we can exit the MythTV setup program and finally populate our database with the guide data (Remember if you have not defined the username and password with which MythTV will access the database, mythfilldatabase will most likely fail)

root@host# mythfilldatabase

This might take quite a few minutes, as MythTV will fill entries for every channel over the next week or so. Once completed we need to setup our audio card for the correct input to be used. We might need to install a couple more applications to make sure this is done correctly.

root@host# emerge alsa-oss 
root@host# emerge alsa-tools
root@host# emerge alsamixer 
root@host# emerge alsamixergui

Once these applications are installed, we can run the "alsamixergui" and make sure our Line-in is selected as our default in on our soundcard. We do this by finding the channel called "Line" and clicking the circles at the top of the channel so that they are red. This lets us know that this channel is the default "in" source. We also need to make sure this channel is muted, that way we only get sound through this channel when MythTV is running. Make sure the speaker icons on the "Line" channel are not selected green. Aftwerwards we can close the mixer application and make sure these settings are saved.

root@host# alsactl store

This will save the sound channel settings. We are ready to move on to configuring MythTV to use our remote control.

Configuring MythTV to use LIRC

Next we need to create a file called lircrc for MythTV to pass its commands to the lircd service. This file will exist in the home directory of the user under which mythfrontend runs. We need to change to the user's home directory that MythTV will run as and create a file called .lircrc and populate it with the following information (note the dot in front of the file name):

# MythTV native LIRC config file for
# the new grey Hauppauge remote
#
# Here we have the jump point commands.  They only work if you have
# defined function keys for these jump points.  For me the most
# common command is the menu of recordings, so I put that on "videos"
# even though that's counter-intuitive
# power buttom
begin
prog = irexec
button = Power
repeat = 4
config = /usr/local/bin/mythpowerbutton.sh
end
begin
prog = mythtv
button = TV
repeat = 3
config = F6
end
begin
prog = mythtv
button = Videos
repeat = 3
config = F7
end
# Not yet defined
begin
prog = mythtv
button = Music
repeat = 3
config = F9
end
# Given another function for now, I don't use mythgallery
begin
prog = mythtv
button = Pictures
repeat = 3
config = F8
end
begin
prog = mythtv
button = Guide
repeat = 3
config = S
end
# I stuck the "todo" list on here as Myth has no radio function
begin
prog = mythtv
button = Radio
repeat = 3
config = F5
end
begin
prog = mythtv
button = Up
repeat = 3
config = Up
end
begin
prog = mythtv
button = Down
repeat = 3
config = Down
end
begin
prog = mythtv
button = Left
repeat = 3
config = Left
end
begin
prog = mythtv
button = Right
repeat = 3
config = Right
end
# Channel Up
begin
prog = mythtv
button = Ch+
repeat = 3
config = Up
end
# Channel Down
begin
prog = mythtv
button = Ch-
repeat = 3
config = Down
end
# OK/Select
begin
prog = mythtv
button = OK
config = Space
end
# Play
begin
prog = mythtv
button = Play
config = Return
end
# Stop
begin
prog = mythtv
button = Stop
config = I
end
# Escape/Exit/Back
begin
prog = mythtv
button = Back/Exit
config = Esc
end
# Power Off/Exit
#begin
#prog = mythtv
#button = Power
#config = Esc
#end
# Pause
begin
prog = mythtv
button = Pause
repeat = 3
config = P
end
# Mute
begin
prog = mythtv
button = Mute
repeat = 3
config = |
end
# Fast forward (30 sec default)
begin
prog = mythtv
button = Rewind
repeat = 3
config = <
end
# Rewind (10 sec default)
begin
prog = mythtv
button = Forward
repeat = 3
config = >
end
# Skip forward (10 min default)
begin
prog = mythtv
button = SkipForward
repeat = 3
config = End
end
# Skip backward (10 min default)
begin
prog = mythtv
button = Replay/SkipBackward
repeat = 3
config = Home
end
# Record
begin
prog = mythtv
button = Record
repeat = 3
config = R
end
# Delete
begin
prog = mythtv
button = Red
repeat = 3
config = D
end
# Bring up the edit screen
begin
prog = mythtv
button = Green
repeat = 3
config = E
end
# Display EPG while in live TV,
# View selected show while in EPG
begin
prog = mythtv
button = Menu/i
repeat = 3
config = M
end
# Scroll up
begin
prog = mythtv
button = Vol+
repeat = 3
config = F11
end
# Scroll down
begin
prog = mythtv
button = Vol-
repeat = 3
config = F10
end
# Bring up OSD info
begin
prog = mythtv
button = Go
repeat = 3
config = I
end
# previous channel
begin
prog = mythtv
button = Prev.Ch
repeat = 3
config = H
end
# tag a recording, in the Recordings section
begin
prog = mythtv
button = Yellow
repeat = 3
config = Y
end
# change tuners
begin
prog = mythtv
button = #
repeat = 3
config = C
end
# load the cut list while editing
begin
prog = irexec
button = Blue
repeat = 0
config = /usr/local/bin/osd.sh
end
# load the cut list while editing
#begin
#prog = mythtv
#button = Blue
#repeat = 3
#config = Z
#end
# Numbers 0-9
begin
prog = mythtv
button = 0
repeat = 3
config = 0
end
begin
prog = mythtv
button = 1
repeat = 3
config = 1
end
begin
prog = mythtv
button = 2
repeat = 3
config = 2
end
begin
prog = mythtv
button = 3
repeat = 3
config = 3
end
begin
prog = mythtv
button = 4
repeat = 3
config = 4
end
begin
prog = mythtv
button = 5
repeat = 3
config = 5
end
begin
prog = mythtv
button = 6
repeat = 3
config = 6
end
begin
prog = mythtv
button = 7
repeat = 3
config = 7
end
begin
prog = mythtv
button = 8
repeat = 3
config = 8
end
begin
prog = mythtv
button = 9
repeat = 3
config = 9
end
### MPlayer lirc setup
# Show OSD
begin
prog = mplayer
button = Menu/i
repeat = 3
config = osd
end
# Pause playback
begin
prog = mplayer
button = Pause
repeat = 3
config = pause
end
# Skip ahead a minute if playing
# If paused, resume playing
begin
prog = mplayer
button = Play
repeat = 3
config = seek +1
end
# Stop playback and exit
begin
prog = mplayer
button = Stop
repeat = 3
config = quit
end
# Mute
begin
prog = mplayer
button = Mute
repeat = 3
config = mute
end
# Seek back 10 seconds
begin
prog = mplayer
button = Rewind
repeat = 3
config = seek -10
end
# Seek forward 30 seconds
begin
prog = mplayer
button = Forward
repeat = 3
config = seek +30
end
# Quit
begin
prog = mplayer
button = Back/Exit
repeat = 3
config = quit
end
# Seek forward 10 minutes
begin
prog = mplayer
button = SkipForward
repeat = 3
config = seek +600
end
# Seek backward 10 minutes
begin
prog = mplayer
button = Replay/SkipBackward
repeat = 3
config = seek -600
end
# Toggle full-screen
begin
prog = mplayer
button = Prev.Ch
repeat = 3
config = vo_fullscreen
end
### Xine lirc setup
begin
prog = xine
button = Play
repeat = 3
config = Play
end
begin
prog = xine
button = Stop
repeat = 3
config = Quit
end
#begin
#prog = xine
#button = OFF
#repeat = 3
#config = Quit
#end
begin
prog = xine
button = Pause
repeat = 3
config = Pause
end
begin
prog = xine
button = Up
repeat = 3
config = EventUp
end
begin
prog = xine
button = Down
repeat = 3
config = EventDown
end
begin
prog = xine
button = Left
repeat = 3
config = EventLeft
end
begin
prog = xine
button = Right
repeat = 3
config = EventRight
end
begin
prog = xine
button = OK
repeat = 3
config = EventSelect
end
begin
prog = xine
button = Back/Exit
repeat = 3
config = Menu/i
end
begin
prog = xine
button = Forward
repeat = 3
config = SpeedFaster
#config = SeekRelative+60
end
begin
prog = xine
button = Rewind
repeat = 3
config = SpeedSlower
#config = SeekRelative-60
end
begin
prog = xine
button = Vol+
repeat = 3
config = Volume+
end
begin
prog = xine
button = Vol-
repeat = 3
config = Volume-
end
begin
prog = xine
button = Mute
repeat = 3
config = Mute
end
begin
prog = xine
button = Menu/i
repeat = 3
config = RootMenu
end
begin
prog = xine
button = Guide
repeat = 3
config = RootMenu
end
begin
prog = xine
button = SkipForward
repeat = 3
config = SeekRelative+60
#config = EventNext
end
begin
prog = xine
button = Replay/SkipBackward
repeat = 3
config = SeekRelative-60
#config = EventPrior
end
begin
prog = xine
button = Go
repeat = 3
config = OSDStreamInfos
end
begin
prog = xine
button = Red
repeat = 3
config = Quit
end
begin
prog = xine
button = Yellow
repeat = 3
config = Eject
end

Once this file has been created, we can either copy it or make a symbolic link to it in the user's .mythtv directory.

user@host# cd ~
user@host# cp .lircrc ~/.mythtv/lircrc

Configuring MythWeb

MythWeb will allow us to connect to the MythTV system remotely and schedule recordings and other various remote functions. This is a handy feature if we wish to schedule a recording but are not at home to do so.

Getting MythWeb up and running with basic functionality is a straightforward process. We just need to install MythWeb and it will install all relevent dependencies.

root@host# emerge mythweb

This of course will also install the Apache2 web server. We need to configure Apache2 to start at boot and also start the web server itself:

root@host# rc-update add apache2 default
root@host# /etc/init.d/apache2 restart

(Note: if you get an error about resolving the ServerName for the system, make sure you have the ServerName directive configured for your hostname and that either DNS or the /etc/hosts file is configured correctly)

We now need to do a little more configuration for MythWeb to run. First we can edit the /etc/php/apache2-php5/php.ini file and change the following option:

#/etc/php/apache2-php5/php.ini
allow_url_fopen = On

We will also need to make sure you have PHP enabled in our /etc/conf.d/apache2 file. with the line:

#/etc/conf.d/apache2
APACHE2_OPTS="-D DEFAULT_VHOST -D PHP5"

The final step we need to do is to have the directory settings for the web server look in the correct directory for the MythWeb content. This is done by editing the /etc/apache2/vhosts.d/00_default_vhost.conf file to look similar to the following:

DocumentRoot "/var/www/localhost/htdocs/mythweb/"
<Directory "/var/www/localhost/htdocs/mythweb">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Deny from none
</Directory>
root@host# /etc/init.d/apache2 restart

Once the webserver has restarted, point a web browser from another computer on your local network to the IP address of your MythTV system. If you are not sure what your IP address is, either run ifconfig -a from a shell (terminal) or check the settings in your Network Configuration option from your Gnome window manager.

At this point MythWeb is up and running.

Running MythTV

We are now ready to launch the "mythfrontend" application and test all of this out. From a shell within Xorg (terminal), simply run:

user@host# mythfrontend

This might take a minute or so the first time, as the frontend is building and scaling images to the defined layout of our screen.

Once this is launched, we should try using our remote control to navigate menu options. If for any reason the remote fails to move menu options, we should probably double check our configurations files for lirc and their locations.

If the menu options do respond to the remote, we can go forward in configuring the various other MythPlugins under the Utilities/Setup option. Some of these plugins include

  • MythMusic: A frontend to play music CDs and Mp3s
  • MythDVD: A Myth frontend that plays and copies DVD's
  • MythWeather: Pugin that interfaces with weather.com
  • MythFlix: Interface for Netflix accounts
  • MythPhone: SIP based Voice over IP plugin for MythTV
  • MythGallery: Frontend Picture/Photo Gallery for MythTV
  • MythNews: Configurable Web-based News Feeds.

Configuring most of these plugins should be pretty self-explanatory. If you have any additional questions about the way these plugins work, please consult the MythTV documentation.

From here we should probably test out the most important feature of all: Watching Live TV.

Some users have initial problems with watching Live TV based on one issue; the configuration of the BTTV drivers for their Hauppauge cards.

Assuming "mythfilldatabase" has been run, and the guide data has been populated, choose the "Watch TV" option. If you get no picture at this point.. then a little adjusting needs to be done to the BTTV drivers.

In our case, we are using the Hauppauge WinTV GO-Plus capture card. There are specific card and tunner settings that need to be applied for this card to work correctly.

To set these options, we need to create a file in the /etc/modprobe.d directory called bttv and set up some configuration options for the card to work properly

user@host# sudo touch /etc/modprobe.d/bttv

Then we can edit this file and put in the following options:

options bttv radio=1 card=26 tuner=39 gbuffers=10

In this case we enabled the Radio feature as well on the card, though the options we put here will largely depend on what model of Hauppauge WinTV card we have. You might have to adjust the card number and tuner number based on your model. For a more complete list of card and tuner numbers supported by bttv, please refer to the MythTV BTTV wiki.

Once we have configured the card and tuner types, we can either reload the bttv modules or reboot the system (module reloading is much quicker). We must make sure "mythfrontend" and "mythtv-backend" are both not running. Exit out of the frontend and then we can stop the backend and reload the modules and try again.

user@host# sudo /etc/init.d/mythtv-backend stop
user@host# sudo rmmod tuner && rmmod bttv
user@host# sudo modprobe bttv
user@host# sudo /etc/init.d/mythtv-backend start

We can now launch the "mythfrontend" application and try again. If this still does not work, keep adjusting the card and tuner types and repeat the process listed above until you find a combination that works for you.

Once you have a working combination that get a good television signal, its now time to put the finishing touches on the MythTV system so that we can plug it up to our TV.

Installing MythStream

MythStream is a very nice unofficial MythTv plugin that plays Internet audio and video streams. Besides playing from a list of harvested and bookmarked streams, you can use MythStream to browse or search stream url sources without configuring every stream URL explicitly.

The homepage for this plugin can be found at the following URL:

http://home.kabelfoon.nl/~moongies/streamtuned.html

During the time of writing this article, installing MythStream on Gentoo takes a little more work than just emerging an ebuild. First we must install a few dependencies in order for the Stream Parser to work correctly:

root@host# emerge wget
root@host# emerge dev-perl/XML-Simple
root@host# emerge dev-perl/XML-XQL
root@host# emerge dev-perl/XML-DOM
root@host# emerge sci-libs/fftw-2*

Once this has completed we need to create a temporaty working directory in which we can downloads the source and compile it. Something such as /myth-tmp might work.

root@host# mkdir /myth-tmp && cd /myth-tmp
root@host# wget "http://home.kabelfoon.nl/~moongies/sw9vc4htz2/mythstream-v0.17_2.tar.gz"

Now that we have downloaded the source, we need to go ahead and extract it and do some symbolic linking in order for the compile to work correctly.

root@host# tar -xzf mythstream-v0.17_2.tar.gz
root@host# cd mythstream-0.17_2 && ln -s /usr/include/mythtv/ mythtv
root@host# cd mythstream && ln -s /usr/include/mythtv/ mythtv && cd ..
root@host# qmake mythstream.pro

From here we should be able to simply compile the plugin and install it. If for any reason you have trouble during the compile process, verify that your environmental variable for $QTDIR is set to /usr/qt/3. Many people have complained about not being able to compile MythStream, and one of the most common issues is the $QTDIR environmental variable.

root@host# QTDIR=/usr/lib/qt3; export QTDIR
root@host# make && make install

Now we have the plugin installed and just need to enable buttons in the MythTV frontend that will allow us to access the MythStream feature (The installation does not alter any of the MythTV theme files, this is something we must do ourselves). This includes the following functionality:

Set buttons of type STREAM in library.xml (provides mythstream menu entry)

Set buttons of type STREAM in media_settings.xml (provides mythstream-setup menu entry)

Define the STREAM button in your theme's theme.xml (provides icon in menu entries)

Change to the /usr/share/mythtv directory and make additions to the following files:

#library.xml:
<button>
  <type>STREAM</type>
  <text>Internet Streams</text>
  <action>PLUGIN mythstream</action>
  <depends>mythstream</depends>
</button>
#media_settings.xml:
<button>
   <type>STREAM</type>
   <text>Stream settings</text>
   <action>CONFIGPLUGIN mythstream</action>
   <depends>mythstream</depends>
</button>

We will also need to add stream buttons to our MythTV theme.xml file (below the "mainmenu.xml" comment). Yhis file would be found under the themes directory, and whichever theme we are currently suing in MythTV:

#example: themes/blue/theme.xml
<buttondef name="STREAM">
 <image>stream.png</image>
 <offset>60,30</offset>
</buttondef>
#example: themes/MythCenter[-wide]/theme.xml
<buttondef name="STREAM">
  <image>ui/button_off.png</image>
  <watermarkimage>watermark/stream.png</watermarkimage>
  <offset>0,0</offset>
</buttondef>

After saving the various XML files, we should be able to restart the MythFrontend and see our new options for Streaming Music under the Media Library. The same holds true for the configuration of MythStream. This can be found in the Media Settings menu. From here Mythstream is up and running and ready to connect to whatecer sources we configure. For any questions on the useage of MythStream, consult the README file located under the directory in which we extracted the MythStream source.

Final Touches

At this point we have done all the major work to get MythTV up and running. Now we just need to make some minor tweaks such as configuring an autologin account that will start MythTV frontend everytime the computer boots.

This is a straightforward process. With no Window Manager, and no login manager, we can simply use inittab to perform this task. Change the C6 line in the /etc/inittab to the following:

c6:2345:respawn:/usr/bin/openvt -fwc 2 -- /bin/su - user -c /usr/bin/startx >& /dev/null

Be sure and substitute the "user" with the actual user account that you wish to use to run MythTV. Then create a file called .xinitrc in the user's home directory to run a few options and start the MythFrontend.

xset -dpms s off
xvattr -a XV_COLORKEY -v 0
xsetroot -solid black
mythfrontend -v all

These options will set the background to black and turn off power management and screensave blank options. We should make sure that these utilities are present once we save the .xinitrc file.

root@host# emerge xset
root@host# emerge xvattr
root@host# emerge xsetroot

Now we should be able to reboot the machine and it automatically logs on and runs the MythTV application.

Once the system has rebooted, the only thing left to configure is the TV out settings for our video card. As stated earlier, we are using an Nvidia chipset.. and with the packages we added earlier, we can easily configure our display to go out to the SVideo output as well as our monitor at the same time.

We can accomplish this task by making entries in (or even replacing) the /etc/X11/xorg.conf file. Before we do this, we want to make a backup in case anything goes wrong.

user@host# sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.backup

Now we can either edit the entries in this file, or replace it with the following example:

# /etc/X11/xorg.conf (xorg X Window System server configuration file)
#
# If you have edited this file but would like it to be automatically updated
# again, run the following command:
#   sudo dpkg-reconfigure -phigh xserver-xorg
Section "ServerLayout"
   Identifier     "Default Layout"
   Screen         "Default Screen" 0 0
   InputDevice    "Generic Keyboard"
   InputDevice    "Configured Mouse"
EndSection
Section "Files"
   # path to defoma fonts
   FontPath        "/usr/share/X11/fonts/misc"
   FontPath        "/usr/share/X11/fonts/cyrillic"
   FontPath        "/usr/share/X11/fonts/100dpi/:unscaled"
   FontPath        "/usr/share/X11/fonts/75dpi/:unscaled"
   FontPath        "/usr/share/X11/fonts/Type1"
   FontPath        "/usr/share/X11/fonts/100dpi"
   FontPath        "/usr/share/X11/fonts/75dpi"
   FontPath        "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
EndSection
Section "Module"
   Load           "i2c"
   Load           "bitmap"
   Load           "ddc"
   Load           "extmod"
   Load           "freetype"
#  Load           "glx"
   Load           "int10"
   Load           "type1"
   Load           "vbe"
EndSection
Section "InputDevice"
   Identifier     "Generic Keyboard"
   Driver         "kbd"
   Option         "CoreKeyboard"
   Option         "XkbRules" "xorg"
   Option         "XkbModel" "pc104"
   Option         "XkbLayout" "us"
EndSection
Section "InputDevice"
   Identifier     "Configured Mouse"
   Driver         "mouse"
   Option         "CorePointer"
   Option         "Device" "/dev/input/mice"
   Option         "Protocol" "ExplorerPS/2"
   Option         "ZAxisMapping" "4 5"
   Option         "Emulate3Buttons" "true"
EndSection
Section "Monitor"
   Identifier     "Generic Monitor"
   HorizSync       31.5 - 48.5
   VertRefresh     70
   Option         "DPMS"
   ModeLine "960x540p" 37.26 960 976 1008 1104 540 542 548 563 +hsync +vsync
EndSection
Section "Device"
   Identifier     "NVIDIA Corporation"
   Driver         "nvidia"
   Option         "DPMS"
   Option         "IgnoreEDID" "1"
   Option         "TVStandard" "NTSC-M"
   Option         "TVOutFormat" "SVIDEO"
   Option         "TVOverScan" "0.6"
   Option         "ConnectedMonitor" "tv"
   Option         "TwinView" "true"
   Option         "TwinViewOrientation" "Clone"
   Option         "SecondMonitorHorizSync" "30-50"
   Option         "SecondMonitorVertRefresh" "60"
   Option "MetaModes" "1024x768,1024x768;800x600,800x600;640x480,640x480;512x384,512x384"
EndSection
Section "Screen"
   Identifier     "Default Screen"
   Device         "NVIDIA Corporation"
   Monitor        "Generic Monitor"
   DefaultDepth    24
   SubSection     "Display"
       Depth       1
       Modes      "1280x1024" "1024x768" "800x600" "640x480"
   EndSubSection
   SubSection     "Display"
       Depth       4
       Modes      "1280x1024" "1024x768" "800x600" "640x480"
   EndSubSection
   SubSection     "Display"
       Depth       8
       Modes      "1280x1024" "1024x768" "800x600" "640x480"
   EndSubSection
   SubSection     "Display"
       Depth       15
       Modes      "1280x1024" "1024x768" "800x600" "640x480"
   EndSubSection
   SubSection     "Display"
       Depth       16
       Modes      "1280x1024" "1024x768" "800x600" "640x480"
   EndSubSection
   SubSection     "Display"
       Depth       24
       Modes      "1280x1024" "1024x768" "800x600" "640x480"
   EndSubSection
EndSection

Note the entries for the default mouse. If you are using a PS/2 based mouse, and maybe not using a USB mouse, correct these entries with the entries from your original xorg.conf.backup file. Yhis will eventually be irrelevent once the system is hooked up to the Television.. we will not need a mouse then. Also note that here we are cloning the output of our Monitor to the S-Video output of the Nvidia card.

Now we can simply install the NVIDIA drivers for the system:

root@host# emerge nvidia-drivers

We should also make sure the NVIDIA module is loaded and will always load upon subsequent boot:

root@host# modprobe nvidia

And of course edit the /etc/modules.autoload.d/kernel-2.6 file and add the line:

nvidia

Now we should be able to connect an S-Video cable out of our Nvidia card directly into the input of a Television. You might want to play with the horizontal/vertical refresh settings and resolution modes if you find these settings do not work well for you.. but generally they should work for most televisions.

From here, all you need is to connect the Audio Line Out (or Multiple Lines Out) from your soundcard to your television or stereo receiver/amplifier. Adapter cables that go from mini jack out to RCA audio in can usually be purchased at your local Radio Shack or other Electronics Store.

Also, we need to make sure the BIOS for the system is not halting when a keyboard or monitor is not connected to it. Be sure and change any BIOS settings to correct this problem. Once rebooted, we should have a basic functioning MythTV Home Media Center running. Enjoy!

Personal tools