Boggle.org: The Mediabeast, Mark IV

Overview

The mediabeast is a digital media jukebox and digital TV recorder. The primary interface is via the connected TV set and a remote control, though recording is scheduled using a web browser. It records MPEG-2 streams from DVB-T broadcasts and plays a wide range of audio and video formats including MPEG-1/2/4, QuickTime, MP3, and OGG.

This is the fourth version of the system and this document. There was an unfortunate "accident" which required me to rebuild the system, which gave me the chance to examine newer tools and to improve the system.

Hardware

The system is built on an older Athlon (running at 1.4GHz) with an OEM Technotrend DVB-T card and a Matrox G400 for video output. It uses a Griffin iMic for audio output, and a serial IR receiver for the remote. There are two IDE disks -- one 40GB for the operating system and tools, one 250GB for media storage. There is an IDE Pioneer DVD-ROM drive.

Software

The system is built on top of Gentoo Linux 2004.0. It is currently running kernel 2.4.25 as built by the genkernel tool, and the linuxtv.org DVB driver kit version 1.1.1. Audio-out is provided by the ALSA usb-audio driver, and the remote is handled by LIRC.

Recording is done using tzap. The current (as of 13/3/2004) CVS version of this includes a "-o" option which dumps the requested MPEG-2 transport stream to disk. I had previously been using dvbstream, but this seems to have some problems tuning the card with the current drivers. tzap has proven to be extremely reliable.

Scheduling is handled by WebVCR+. I have a small shell script which this uses in place of vcr to control tzap and do the actual recording. The resulting files are at present simple dumps of the MPEG-2 transport stream, but once the system has been running reliably for a month or so I intend to rig this up to automatically convert the saved data to MPEG-2 programme stream format, as that is what most players support.

A/V playback is controlled by Freevo displaying to the G400 in framebuffer mode. Freevo is using MPlayer as a back-end.

Software setup details

This section is a quasi-HOWTO. I'm assuming you have a running Linux system with the same hardware as I have (the key parts being a Technotrend DVB-T card and a Matrox G400) -- if not you'll have to work out the differences for yourself.

Digital TV

First off, you'll need the linuxtv.org drivers. At present the version in Portage is quite old, so you'll be better off grabbing the latest release. Compiling and testing this is pretty easy:

cd linuxtv-dvb-1.1.1/build-2.4
make
./ldm

That should get the modules built and inserted in the running kernel. Check the output of dmesg and the contents of /dev/dvb/adapter0 (assuming you're running with devfs, of course). You should see:

romana build-2.4 # ls -l /dev/dvb/adapter0/
total 0
crw-------    1 root     root     250,   4 Jan  1  1970 demux0
crw-------    1 root     root     250,   5 Jan  1  1970 dvr0
crw-------    1 root     root     250,   3 Jan  1  1970 frontend0
crw-------    1 root     root     250,   7 Jan  1  1970 net0

Note that you may need to put a copy of the DVB-T firmware in the correct directory before the modules will load successfully. You can grab the latest firmware from the Technotrend site. You'll have to download the full Windows driver kit and dig around looking for the file tda1004x.dll. In the case of my Gentoo system the correct place to drop this was /usr/lib/hotplug/firmware/tda1004x.bin.

Now install the drivers:

make install

Then, finally, make sure the correct drivers are loaded on boot. For my card, this meant adding the following to /etc/modules.autoload.d/kernel-2.4:

input
evdev
videodev
dvb-core
tda1004x
saa7146
saa7146_vv
ttpci-eeprom
dvb-ttpci
dvb-ttpci-budget
dvb-ttpci-budget-ci
dvb-ttpci-budget-av

(Some of these may be superfluous, I haven't felt inclined to go through and try it without each one in turn to figure out which.)

Once you've got the drivers installed, you'll be wanting to try capturing some video. To do this, install dvb-apps from linuxtv.org. At the moment you'll be needing the CVS version. Building and installing these is simple:

cd dvb-apps
make
make install

To get tzap to do anything useful you'll need a channels.conf file. Here's mine (for Melbourne, Australia):

ABC HDTV:226500000:INVERSION_OFF:BANDWIDTH_7_MHZ:FEC_3_4:FEC_3_4:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:2307:2308:560
ABC TV Melbourne:226500000:INVERSION_OFF:BANDWIDTH_7_MHZ:FEC_3_4:FEC_3_4:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:512:650:651
ABC DiG Radio:226500000:INVERSION_OFF:BANDWIDTH_7_MHZ:FEC_3_4:FEC_3_4:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:0:2310:566
TEN Digital:219500000:INVERSION_OFF:BANDWIDTH_7_MHZ:FEC_3_4:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:512:650:1585
TEN HD:219500000:INVERSION_OFF:BANDWIDTH_7_MHZ:FEC_3_4:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:514:0:1592
Nine Digital:191625000:INVERSION_OFF:BANDWIDTH_7_MHZ:FEC_3_4:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:519:720:1072
Nine Digital HD:191625000:INVERSION_OFF:BANDWIDTH_7_MHZ:FEC_3_4:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:512:0:1073
Nine Guide:191625000:INVERSION_OFF:BANDWIDTH_7_MHZ:FEC_3_4:FEC_1_2:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_16:HIERARCHY_NONE:517:700:1074
7 Digital:177500000:INVERSION_OFF:BANDWIDTH_7_MHZ:FEC_2_3:FEC_2_3:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:769:770:1328
7 HD Digital:177500000:INVERSION_OFF:BANDWIDTH_7_MHZ:FEC_2_3:FEC_2_3:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:833:834:1332
7 Program Guide:177500000:INVERSION_OFF:BANDWIDTH_7_MHZ:FEC_2_3:FEC_2_3:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:865:866:1334
SBS HD:536625000:INVERSION_OFF:BANDWIDTH_7_MHZ:FEC_2_3:FEC_2_3:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:102:103:784
SBS DIGITAL 1:536625000:INVERSION_OFF:BANDWIDTH_7_MHZ:FEC_2_3:FEC_2_3:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:161:81:785
SBS DIGITAL 2:536625000:INVERSION_OFF:BANDWIDTH_7_MHZ:FEC_2_3:FEC_2_3:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:162:83:786
SBS EPG:536625000:INVERSION_OFF:BANDWIDTH_7_MHZ:FEC_2_3:FEC_2_3:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:163:85:787
SBS RADIO 1:536625000:INVERSION_OFF:BANDWIDTH_7_MHZ:FEC_2_3:FEC_2_3:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:0:201:798
SBS RADIO 2:536625000:INVERSION_OFF:BANDWIDTH_7_MHZ:FEC_2_3:FEC_2_3:QAM_64:TRANSMISSION_MODE_8K:GUARD_INTERVAL_1_8:HIERARCHY_NONE:0:202:799

Now, to record a minute of ABC-TV:

tzap -c /usr/local/share/channels.conf -t 60 -o wibble.ts "ABC TV Melbourne"

You'll need to convert the result to programme stream format before anything much will play it. Get the libdvb package and build it. That will give you the ts2ps tool which you can then use:

ts2ps 0 0 < wibble.ts > wibble.mpg

The result should play nicely in MPlayer. If you want to watch it on a Win32 system you'll need to pass it through PVAstrumento before VLC will be happy playing it.

Provided you've got this much working, the rest is a doddle. Fetch WebVCR+ and install it following the provided instructions. You can get an XMLTV grabber for Australia here, and you should also follow his directions for modifying WebVCR+ to suit if you want to use the ratings field.

Modify the following shell script to suit your locale:

#!/bin/bash

# some variables

TZAP=/usr/local/bin/tzap
CHANNELS=/usr/local/share/channels.conf

# first, figure out what tzap station name we want

if [ "$1" == "2" ]; then
	station="ABC TV Melbourne";
elif [ "$1" == "3" ]; then
	station="SBS DIGITAL 1";
elif [ "$1" == "7" ]; then
	station="7 Digital";
elif [ "$1" == "9" ]; then
	station="Nine Digital";
elif [ "$1" == "10" ]; then
	station="TEN Digital";
fi

# record the programme

$TZAP -c $CHANNELS -t $2 -o "$3" "$station"

and save it as /usr/local/bin/wvcrrec.sh. Now enter the following in the "Recording Program" field in the WebVCR+ configuration page:

/usr/local/bin/wvcrrec.sh #STATION# #TIME# "#OUTPUT#.ts"

Hopefully you should now be able to schedule recordings and have them happen.

Media Jukebox

Freevo largely installs itself. The one thing you'll need to do before installing it is to get your framebuffer and TV-out working. There's a good document here describing how to get a G400 set up. Some things to note if you're using a reasonably recent kernel and the Gentoo genkernel tool:

Now you'll need LIRC. This is fairly easy to install and configure, so I won't go into it here.

Installing Freevo on Gentoo is of course very easy. Just make sure you've included matrox in your USE flags:

ACCEPT_KEYWORDS="~x86" emerge freevo

Using DVB there's not much point having the Freevo TV module enabled, so you may as well disable it by adding:

TV_CHANNELS = []
plugin.remove('tv')

to your local_conf.py file.

Freevo is fairly well-documented. While parts of the documentation are out-of-date -- the software improves rather more rapidly than the docs do -- you'll find most of what you need in the Freevo Wiki.

Processing recordings

Sometimes you'll want to hang on to something for the long term. In principle you can convert DVB-T recordings to DVD and burn them for playback in a standalone player, but as reception where I live is a bit dodgy that doesn't work so well for me. So I transcode programmes to MPEG-4.

Precisely how a given programme is treated varies. Most are transcoded to MPEG-4 using the libavcodec support in mencoder. That produces pretty reasonable results. I do this using a simple Perl script which automates much of the work. It is currently being re-written, and will be put online here once it's ready.

I also record music videos broadcast on Rage. These are handled differently:

  1. The entire stream is cleaned up using PVAstrumento on Windows;
  2. Individual music videos are selected and compressed (2 pass DivX Pro) using VirtualDubMod. Audio is left un-touched;
  3. The resulting AVI files are copied back to the mediabeast, where mencoder finishes the job transcoding the audio using the LAME "standard" preset.

This provides the best combination of convenience (VirtualDubMod is very good when you want to do simple cuts) with quality (DivX Pro is quite good, and using LAME we get the best VBR MP3 around).


© 2009 Matt McLeod, All Rights Reserved
This page was last updated Sunday, 14-Mar-2004 03:05:54 UTC
webmonster@boggle.org