PVR

What is it.

This pages gives a description and some usage information of a home brew personal video recorder with Electronic Program Guide (EPG). Aim of the project is to record TV programs on a computer using open source software.

The current PVR uses a Hauppauge WinTV PVR USB2 for reception. This is an analog USB receiver that has an onboard MPEG2 encoder. However, as of today the setup is not operational. The Hauppauge card does not work when connected to the beagle USB OTG port. I suspect this is due to a bug in the MUSB driver, as the same setup works like a charm on NSLU2 (which also has an ARM processor).

Aim is to extend the functionality (e.g. support DVB-T and/or DVB-S cards), and update the tvguide stuff. Alternately MythTV could be an option.

How does it work.

The following diagram illustrates the structure of the PVR:

The following components can be identified. (note that recd, timers channels and the recd configuration file have man pages; these are not here but can be made available upon request).

web server

At the top the PVR has a web interface for controlling the PVR. This web interface is served by an Apache server. The static part of the UI (html pages, css style sheets, java script programs, images) resides on the background storage of the system. Everything that is dynamic is provided by the guideclient, which is a C program that is invoked from the html pages using CGI.

guideclient

The guideclient is responsible for all interaction between the user (who is looking at a page from the web server) and the system itself. It accesses the list of channels, the list of programmed timers and connects to the guideserver for EPG data. Also if the user decides to program a recording, the guideclient updates the timers file and triggers the recording daemon, by sending it a signal

recording daemon

The recording daemon does the actual recording. It reads the timers file and makes a recording when needed. So if the recording daemon sees that a recording should start it writes the video information provided by the USB video device to a file as long as the recording should last. The recording is made using the data format provided by the USB video device. For the WinTV card this is an mpeg2 stream. Once the recording is finished the file is closed. Naming of the file is configurable but typically contains start time, stop time, channel name and program name. This format is specified in the recd config file together with some other options (e.g. the maximum file size; if a recording is larger than the maximum file size it will be split into several files. This feature is there as files > 2GB or 4GB can not be handled by all programs.

Note that the recording daemon caches the contents of the timers file. Therefore if the guideclient changes the timers file, it will send a signal to the recording daemon to inform the daemon about changes, after which the daemon rereads the timers file (and terminates cancelled recordings etc).
Once a recording is complete the timers file will be updated.

The recording daemon is capable to handle multiple tuners.

guideserver

The EPG data itself is grabbed using xmltv (www.xmltv.org). This data is stored in a file tvguide.xml. As parsing of xml data can be time consuming and the NSLU2 is just a small device, it would take too much time for the guideclient to parse the data upon each invokation. Instead a guideserver has been written. This server also runs on the NSLU2 and remains active. It reads the tvguide.xml file, processes the data (filtering out unneeded channels and metadata), transforms it in a format that is more convenient for rendering and, upon request serves the data to the guideclient.

guide update

Guide update is a process that at regular intervals gets new data and updates tvguide.xml. After doing so the guideserver needs to be restarted. Currently this has only been partially automated as sometimes the xmltv grabber did not provide good data.

Demonstrator Usage notes.

As the PVR itself does not work, the current demo only provides the user interface and does not have the recording daemon.

The PVR UI is tested with firefox 3.0.5 under ubuntu 7.10 and opensuse 11.1; you might want to use F11 to get a full screen display. The UI is authored for a CRT.

The UI of the PVR is authored for use with a remote control. As a remote control has no free moving cursor, the arrow keys are used to steer the cursor. Typically a remote control sends keycodes to the web page which are then handled by javascript to move the cursor etc.

In a browser on a PC (or on the beagle board) the remote control can be mimic-ed by using the keyboard.

key up: will move up in a list
key down: will move down in a list
key right: will move you to the page for the item that has the cursor or will move you to the right in a table.
key left: will move you to the left in a table.
The software was designed to use backspace to go back to the previous screen. This works like a charm under windows (both with IE and firefox), but not on firefox under linux. If you want the back behaviour bound to backspace under linux follow the recipe on this page Alternately use the back button of the browser.

A brief walkthrough of the UI:
Use a web browser to browse to your beagle. When running on the beagle you can also browse to 127.0.0.1
This brings you to a screen with three entries: status, channels and EPG. You can navigate up and down to select an entry then use cursor right to move into the entry. Note that the full fledged system also has entries to playb back music and to view the image from a webcam. That functionality has been disabled for now.

An overview of the various screens:

Status

This gives a status overview of the device. If a recording is in progress this screen will tell you what is being recorded. Apart from that it will also tell you if an audio CD is being ripped. This functionality is unavailable for now.

Channels

This gives a list of channel names. Actually it is the content of the channels file. There are 37 channels in the current demonstrator. The screen itself still requires some work (e.g. channel logo's; maybe a link to the channel website or some info on the channel, better channel names etc etc)

EPG

The EPG screen is a now-next EPG giving an overview of what is running now and what is next. Unfortunately I did not have the time go get recent EPG data, so you'll see some old data from 2006 (after that the hard disk of my NSLU2 broke down and I never got to revive it).
You can use the arrow keys to move through the EPG, it will scroll while doing so (you can also use cursor left to go to earlier broadcasts). One word of caution though: do not move into an entry that reads "0000 no transmission". Doing so will crash the guide server. This is a known issue that still needs fixing (actually you should not be able to move into that). If you do so, a few refreshes will get the server up and running again (the client will start the server but there is a timeout before the socket is released by the system).

Pressing F1 (the red button) will toggle the recording status of that program. If a program is marked for recording this is indicated by a red dot. See below for a screenshot

Pressing F3 (the yellow button) will give an overview of all timers that are programmed. Entries can also be deleted from this screen (but note that if you do so and move back to the EPG screen you need to do a refresh manually in order to update the status of the recording marker; again a known issue.
See below for a screenshot:

What next?

- get the receiver working with beagle (my hope is that things work with the host port of rev C)
- Different/more receivers
- lirc support
- improved EPG
Or perhaps move to mythtv.