Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP


 
Open Source @ HP all of HP US
HP.com home

Open Source and Linux from HP

Primed for Business Advantage
» 

Large Enterprise Business

» Products
» Business & IT services
» Solutions
»

Open source & Linux

» Platforms & printers
» Linux distributions
» Indemnity
» Support matrices
» Security certifications
» Solutions portfolio
» HP Open Source Middleware Stacks
» Documentation
» Services & education
» Open source at HP
» Partner programs
1-888-475-4689
Content starts here

HP TechBriefs

 
Christopher Worsley Building an Open Source Digital Entertainment System - Part I
by Wylie Swanson
 
This TechBrief provides an introduction to the leading open source home media convergence system, Mythical TV, more commonly referred to as MythTV.

» Introduction
» What is MythTV?
» Why use MythTV?
» MythTV requirements
» Installing the OS and libraries
» Downloading and building
» Installing IvyTV drivers
» Configuring
» Starting MythTV frontend
» Acknowledgement


Introduction

MythTV is a digital entertainment suite that is as sophisticated as any commercial system available on the market today. Part 1 serves as an introduction to MythTV and guide to install the latest development frontend and backend on Ubuntu Linux. It covers building the development branch of the project suite using the latest source. Due to the complexity and variations of hardware and software, this brief will only focus on North American service. Part 2 will focus on building and installing the complete set of official modules.

What is MythTV?

MythTV is a GPL licensed suite of applications that, together, provide a complete home entertainment system. The system's capabilities include television, movies, music, photography and the display of other information like weather and news. It has been developed using only open source components and works under a variety of operating systems from Linux to Mac OS X.

Television features:
  • You may pause, fast-forward and rewind television.
  • You can automatically skip or remove most commercials from television programming.
  • You may install multiple capture cards to record more than one program at a time from a variety of sources, including cable TV, satellite, and over the air broadcasts like ATSC HDTV.
  • You can have multiple servers, each with multiple capture cards in them. All servers are centrally managed and all programs are scheduled by a single master backend. Non-master backends can provide commercial flagging, transcoding and other processing services.
  • You can have multiple clients (called "frontends"), each with a common view of all available programs. Any client can watch any program that was recorded by any of the servers. Clients can be diskless and controlled entirely by a physical remote control.
  • You may use any combination of standard analog capture cards, MPEG-2, MJPEG, DVB or HDTV capture devices. With appropriate hardware, MythTV can control set top boxes, often found in digital cable and satellite TV systems."
  • Program guide data in North America is downloaded from Zap2It.com, a subsidiary of Tribune Media Services, at no charge. This free service is called DataDirect, and provides MythTV with almost two weeks of scheduling information. Program guide data for other countries can be obtained using XMLTV.
Official Modules
  • MythBrowser: a KDE-based web browser
  • MythDVD: a DVD viewer / ripper
  • MythGallery: a picture-viewing and slideshow application
  • MythGame: an X Windows front-end to MAME, the Multiple Arcade Machine Emulator.
  • MythMusic: a music playing/ripping/burning application that supports MP3 and FLAC codecs
  • MythNews: an RSS news grabber and display tool
  • MythPhone: a voice and videophone application leveraging SIP.
  • MythVideo: a media-viewer for content not created within MythTV that leverages the GPL application MPlayer.
  • MythWeather: a weather reporting system with international support
  • MythWeb: a web-browser enabled MythTV management console. With MythWeb you can schedule and delete recordings, manage media files, change key bindings and more.


Why use an open source DVR like MythTV?

Commercial makers of Digital Video Recorders (DVR), like TiVo and ReplayTV, have agreed to limit how long consumers can keep pay-for-view movies stored on future versions of their devices. Open source DVRs put the power and decision making in the hands of the consumers. Every consumer has the ability to set the policies of the system. For example, it is highly unlikely that any commercial system will incorporate commercial skip into their technology! And setting the behavior/policies of the system does not necessarily mean understanding how to further develop or change the source code. Largely, these configuration policies can be done using the graphical frontend and MythWeb module with easy to understand user interfaces. For those that are capable of developing the code itself, they are free to enhance or change the functionality further. Today, there are many official modules (listed above), but there are also a number of unofficial modules that add functionality to the suite. Examples include managing kitchen recipes to downloading BitTorrent movies via RSS feeds from sites like TorrentSpy.

MythTV Requirements

The first step in a MythTV installation is to understand the hardware requirements. MythTV can work with any Linux distribution over a variety of hardware architectures. This brief addresses setup on Ubuntu's latest release (5.10), mainly because it provides one of the best environments for MythTV operation. Ubuntu rivals all free and commercial desktop Linux environments today.

CPU Requirements
Selection of CPU type and speed can be tricky, mainly because of the tradeoffs. If you have plenty of CPU, you can use higher bitrates and capture sizes. High-end video capture cards and devices like TiVo and ReplayTV have dedicated hardware encoders which convert the video stream to MPEG-2/MPEG-4 without using the system CPU. At minimum, the system CPU has the responsibility of running the operating system and reading and writing encoded video frames and audio to disk. These tasks have reasonably low CPU requirements compared to encoding video. MythTV has two modes of operation.

The first mode of operation is to have MythTV function as a software video encoder when using fairly "dumb" video capture cards to get video frames, and encode them using the motherboard CPU.

The second mode of operation, which is preferred, is where MythTV is paired with one or more hardware-based video encoders. In this mode, because the video encoding is done by a dedicated video processor, the system CPU requirements are reasonably low. The most popular video capture cards with hardware-based video encoders are the Hauppauge WinTV-PVR-150, 250, 350 and 500. The PVR-350 has a hardware-based video decoder for playback, which further reduces CPU requirements.

Memory Requirements
A MythTV host that is both a backend and a frontend and using software encoding with a single capture card should run adequately in 256MB of RAM. Additional RAM above 256MB will not necessarily increase performance, but can be useful if you are running multiple encoders on the same backend.

Hard Disk(s)
Encoded video takes up a lot of disk space. The exact amount of space required will vary depending on the encoding scheme, the size of the raw images, and the recording frames per second. Typical usage ranged from 700 megabytes/hour for MPEG-4, 2 GB/hour for MPEG-2 and RTjpeg and 7GB/hour for ATSC HDTV. Writing video to disk is sensitive to timing issues; RTjpeg requires less CPU with the tradeoff being larger files and needing to write to the disk faster. MPEG-4 requires more CPU, but the files are smaller. The default resolution, MPEG-2, creates the largest files, but with almost no impact to the motherboard CPU. MPEG-2 is also the native format for the Hauppauge WinTV-PVR capture/encoders that this brief addresses.

File systems
MythTV creates large files, many in excess of 2GB. You must use a file system that will allow you to create large files. Because the system creates very large files, a file system that does well at deleting large files is also important. Numerous benchmarks show that XFS and JFS do very well at this task. You are strongly encouraged to consider using XFS for the partition that will store the video. The default file system, Ext3 for Ubuntu, is sufficient for all but the video capture file system. For testing purposes, however, you can still use Ext3, but it will not be optimal for a production backend server.

Video Capture Devices
MythTV will need one or more video capture devices with Linux drivers. There are a number of classes of hardware available for capturing video. This brief addresses the use of WinTV-PVR series hardware MPEG-2 capture/encoders. The Hauppauge cards are supported by the IvyTV driver project. The PVR-150 capture cards can be purchased with OEM packaging for around $70, the PVR-250 for $130, and the PVR-350 for $170. The PVR-500 is a dual-tuner and runs about $140. The PVR-250 is the most commonly used and known to the MythTV community.

This TechBrief does not address DVB, HDTV and MythTV installations outside North America. However, it is relevant that DVB and HDTV are supported. DVB is a video standard that has been well known in Europe and is now becoming more popular in the United States with over-the-air ATSC HDTV and over-cable ATSC HDTV QAM256 decoding. Currently, there are two HDTV cards with Linux drivers known to operate in the United States: the HD-2000/HD-3000, available from PCHDTV, and the Air2PC-ATSC-PCI/AirStar-HD5000-PCI.

It is important to note that if you wish to record one show and watch live TV at the same time, you will need at least two video capture encoders. If you wish to record two shows and watch live TV at the same time, you will need three, and so on. If you plan to have multiple frontends operating multiple TVs, you will need at least one video capture encoder per television for each television to watch live TV concurrently.

Sound card
The system needs a sound card or an on-board equivalent on the motherboard to play back, and in some cases, record sound. Any sound card that can be operated by the ALSA (Advanced Linux Sound Architecture) kernel modules will work with MythTV. This knowledge brief will assume that you are using a system that is supported by ALSA, as is the case with almost all HP hardware. I have successfully used the following audio controllers (lspci output):
  • Multimedia audio controller: Intel Corp. 82801DB/DBL/DBM (ICH4/ICH4-L/ICH4-M) AC'97 Audio Controller (rev 01)
  • Multimedia audio controller: Intel Corp. 82801FB/FBM/FR/FW/FRW (ICH6 Family) AC'97 Audio Controller (rev 03)

Video Display card
MythTV will work with just about any video card. However, it is recommended that you use a card which supports XVideo (XV) extensions. If your card does not support XV, color conversion and scaling will be performed by your CPU rather than the video card. This can be very CPU and memory intensive and can result in dropped frames and corresponding degradation of quality. NVidia GeForce video cards are the most popular, but ATI video cards can also work well with a little more effort. This is because ATI has proprietary components that make it more difficult to build the drivers.

Installing the operating system, Ubuntu "Breezy Badger"

Ubuntu is a complete Linux-based operating system, based on Debian, and freely available with both community and professional support. The latest release, 5.10, is affectionately known as the "Breezy Badger" release. The release provides an excellent foundation for the installation of MythTV front-ends, largely due to the volume control support on laptops and DPMS integration between xscreensaver and MythTV's frontend. Best of all, the installation process is simple.

The first step is to download the ISO from your closest Ubuntu mirror. Visit www.ubuntu.com/download/ and download the PC (Intel x86) install CD ISO Ubuntu-5.10-install-i386.iso. Using your favorite ISO burning software, burn the image to a CD and use it to boot your target system.

The default installation options for Ubuntu will be fine for your first pass installation. You will likely want to repeat process after you familiarize yourself with the workings of MythTV and Ubuntu to create the optimum environment for your personal use. The basic install is enough is acceptance, though you will probably want to customize the file system setup to allocate space to an XFS file system. If you decide to create the video file system on your first attempt, use /mnt/store as the mount location.

Installing the MythTV prerequisite libraries

At this point, you have the Ubuntu installed and the foundation ready to download, build and install the MythTV environment. However, you first need to install the prerequisite libraries required to build the source code into executable format.

Open a terminal window by going to "Applications | Accessories | Terminal" and use sudo to invoke a bash shell as the system root super-user. Then edit the system's APT sources configuration with your favorite editor. For the purpose of this brief, the vi editor will be used to edit text files.

mythtv$ sudo bash

mythtv# vi /etc/apt/sources.list


Remove the comments that disable Ubuntu's universe software repositories, and add the multiverse repository as shown below. Do not enable the commented backports repository that appears below the universe declaration. The first two lines you will uncomment and the third you will type manually.

deb http://us.archive.ubuntu.com/ubuntu breezy universe

deb-src http://us.archive.ubuntu.com/ubuntu breezy universe

deb http://us.archive.ubuntu.com/ubuntu breezy multiverse


After you have enabled the universe and added the multiverse repositories, go to the end of the /etc/apt/sources.list configuration file and add the following repositories. These repositories will provide the needed perquisite libraries that are not available from official Debian or Ubuntu sources.

deb ftp://ftp.nerim.net/debian-marillat/ sid main

deb http://dijkstra.csh.rit.edu/~mdz/debian unstable mythtv

deb-src http://dijkstra.csh.rit.edu/~mdz/debian unstable mythtv


Save and exit the sources.list configuration file. You are now ready to update your system's APT tree and upgrade any packages that are insecure or out of date. After you have successfully updated and upgraded with the latest APT resources, you will build the MythTV prerequisites with the APT build-dep command (as shown below). Say "Yes" whenever you are prompted to do so. This includes ignoring the notice that you do not have a valid signature for the dijkstra.csh.rit.edu or ftp.nerim.net sources. Many other applications and libraries will be triggered automatically by the apt-get build-dep and install commands that follow.

# apt-get update

# apt-get upgrade

# apt-get build-dep mythtv


You have now built the prerequisite libraries MythTV requires to build. It is time to enable the libraries. This is accomplished by adding their install location to the dynamic linker/loader configuration file, /etc/ld.so.conf, and informing the system to reload its shared library run-time bindings.

# echo /usr/local/lib >> /etc/ld.so.conf
# /sbin/ldconfig -v


Downloading and building from the latest MythTV sources

You are now ready to fetch the latest MythTV sources and build your digital entertainment system. You will need the Subversion source control client to access the latest source code. Now is the time to install the client, and it is also a good time to add the XVideo development libraries and MySQL database driver for threaded Qt3. phpMyAdmin will come in handy when it is time to manage the MySQL database, but you can skip it with frontend and non-master backend setups. Again, you will want to accept installation of applications that are automatically triggered as well as those specified on the command line.

# apt-get install subversion libxv-dev libqt3-mt-mysql phpmyadmin


Create a home for the MythTV sources, go to the directory, and fetch the sources from the Subversion repository.

# cd /usr/local/src

# mkdir mythtv ; chmod a+w mythtv ; cd mythtv

# svn co http://svn.mythtv.org/svn/trunk/mythtv

# svn co http://svn.mythtv.org/svn/trunk/mythplugins

# svn co http://svn.mythtv.org/svn/trunk/myththemes


You now have all of the sources for MythTV and its official modules ready for build. Now go to the backend/frontend source directory and build and install. Using chmod on the front-end will give MythTV performance advantages when operating as a normal user (as opposed to root super-user) later.

# cd /usr/local/src/mythtv/mythtv

# ./configure

# make

# make install

# chmod +s /usr/local/bin/mythfrontend


Congratulations! You have now completed the installation of MythTV's frontend and backend services. It is time to setup an initial database for the master backend. You can repeat the steps above for creating additional frontend systems. The next few steps relate only to backend services.

Installing IvyTV drivers for Hauppauge tuner cards

In order to get your Hauppauge PVR-X50 or PVR-500 working, you will need the IvyTV (ivtv) drivers. To compile the ivtv sources, you will need to have a build environment for your kernel. This portion may seem confusing, and there is more help on the ivtv driver Web site.

# apt-get install linux-source-2.6.12 libncurses5-dev kernel-package fakeroot

# cd /usr/src

# svn co http://ivtvdriver.org/svn/ivtv/branches/0.4 ivtv-0.4

# tar jxf linux-source-2.6.12.tar.bz2

# ln -s linux-source-2.6.12 linux

# cd linux

# cp /boot/config-`uname -r` .config

# make oldconfig

# ln -s /usr/src/linux /lib/modules/`uname -r`/build

# cd /usr/src/ivtv-0.4/driver

# make

# cd /lib/modules/`uname -r`

# rm -f `find -name tuner.ko` `find -name cx25840.ko` `find -name ivtv.ko` `find -name saa7115.ko` `find -name tuner.ko` `find -name wm8775.ko` `find -name ivtv-fb.ko` `find -name msp3400.ko` `find -name saa7127.ko` `find -name tveeprom.ko`

# cd /lib/modules/`uname -r`/kernel/drivers/media/video

# rm -f msp3400.ko tveeprom.ko tuner.ko

# cd /usr/src/ivtv-0.4/driver

# make install

# depmod -a

# cd ../utils

# make install

# modprobe ivtv


Zap2it screenshot

Configuring the Zap2It DataDirect services

Zap2It DataDirect is a service provided by Zap2It, a subsidiary of Tribune Media Systems (TMS). TMS is one of the primary providers for program listing data in the United States and Canada.

First, you'll need to establish a user account by visiting http://labs.zap2it.com and click the "New User? Sign Up" link. Read the license terms, and if you agree with them, click "Accept". In the "Certificate Code" field, enter "ZIYN-DQZO-SBUT". At sign-up, and every few months, you will need to fill out a survey to continue using the free service.

Proceed to the next screen which will give you an opportunity to define your lineup choices and configure your account for your location and services.

The Zap2It configuration will be imported to MythTV when you run the mythtv-setup program.

Setting up the master backend database
As we covered at the beginning of this Tech Brief, there is only one master backend. The master backend manages all data via a MySQL database. Using the terminal window, verify or install the MySQL server with the following commands. If you already have a working MySQL server, nothing will need to be done. If the MySQL server has to be installed, you will likely be prompted for Postfix configuration, and it is ok to answer "No configuration".

# apt-get install mysql-server


Now that you have verified or installed a working MySQL server, you need to create an account for MythTV. Back to the terminal window.

# mysql -u root < /usr/local/src/mythtv/mythtv/database/mc.sql

# mysql -u root mysql

mysql> GRANT USAGE ON * . * TO 'mythtv'@'%' IDENTIFIED BY 'mythtv' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 ;

mysql> FLUSH PRIVILEGES;

mysql> QUIT


Final backend configuration steps, prior to startup

Starting the setup interface
The next step is to start the MythTV backend setup program. This program is used to initialize the master backend, and it is also used to configure services on non-master backend(s). For the purpose of this guide, we will now use to initialize the master backend database. Using the terminal window, verify the video storage directory is mounted, or create one for testing purposes, and then start the setup interface.

# [ ! -d /mnt/store ] && mkdir /mnt/store

# mythtv-setup


Prior to the graphical setup interface showing on the screen, you should see setup activity logging the initial database creation and schema upgrading to the latest available. Once the graphical configurator open, you can select your preferred language. You should now see the following screen:
MythTV screen capture
Capture cards setup
There is no reason to change General configuration for a single backend/frontend configuration. Select the Capture cards menu option and then select New capture card. Set the card type to "MPEG-2 encoder card (PVR-x50, PVR-500)". The video device and default input should be automatically detected. Repeat the process once for a PVR-500 or if you have multiple PVR-x50 series encoder cards, once for each physical card. Return to the mythtv-setup main menu (shown above) when you are done adding capture cards.

Video sources setup
You will now add the video sources for each of the tuner cards added in the last step. Go to the Video sources menu option and select "Add video source". You will now use the account information you created earlier in the DataDirect process. For example, I specify the video source name "Cox - Basic Cable" for the two PVR-250's connected to (basic) cable TV coaxial, and I use the appropriate DataDirect Lineup, which is "Cox Communications-Cable-85028-AZ". You only need to create one video source if both tuners are connected to the same source (e.g. Cox Cable). Return to the mythtv-setup main menu when you are done adding the video source.

Input menu setup
Now visit the Input menu. Here you will specify which MPEG devices are attached to which programming lineups. For example, I setup the following references.
  • [ MPEG : /dev/video0 ] (Tuner 0) -> Cox Cable
  • [ MPEG : /dev/video1 ] (Tuner 0) -> Cox Cable
The remaining inputs, Composites and S-Video, should remain set to (None).

You can now exit the setup interface completely and return to the terminal window.

Loading the programming data into the database
At this point, all of the necessary installation and configuration for a basic setup is done. You are now ready to populate the MythTV database with the programming data you selected. You only need to do this once. MythTV will automatically refresh program data nightly after the backend process has been started. Go back to the terminal window and execute mythfilldatabase. This process will take a while to run.

# mythfilldatabase


Automating mythbackend service loading at system startup time
You will probably want the backend services to start at system boot time. Edit the file /etc/init.d/mythbackend and add the following:

#!/bin/sh # # mythbackend # PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/local/bin/mythbackend NAME=mythbackend DESC="mythbackend" MBE_LOGFILE="/var/log/mythtv/mythbackend.log" [ ! -d /var/log/mythtv ] && mkdir /var/log/mythtv test -x $DAEMON || exit 0 set -e case "$1" in start) echo -n "Starting $DESC: $NAME" $DAEMON -v all -d -l ${MBE_LOGFILE} & echo "." ;; stop) echo -n "Stopping $DESC: $NAME " killall $DAEMON echo "." ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop}" >&2 exit 1 ;; esac exit 0


Start the backend using the newly created script after making it executable. Also set Ubuntu to start the backend whenever the system is booted.

# chmod +x /etc/init.d/mythbackend

# update-rc.d mythbackend defaults

# /etc/init.d/mythbackend start


Starting MythTV frontend

You are finally ready to start MythTV! Go to the terminal window and execute mythfrontend.

# mythfrontend


The frontend will scale the theme and fonts for your display. You are now ready to watch and/or record television broadcasts. Enjoy!
MythTV main screen

Acknowledgement

Thanks to Risto Haukioja and Marc Torres for reviewing this Tech Brief and for the suggestions they have provided.

Wylie Swanson is based in Phoenix, Arizona. He works as the open source and Linux lead for the HP Services Chief Technology Office.


Was this article useful? Tell us what you think!
Printable version
Privacy statement Using this site means you accept its terms Feedback to Webmaster
© 2007 Hewlett-Packard Development Company, L.P.