MythTV in Ireland
Karl Jeacle


Introduction

This document describes the configuration of my first MythTV system. Its primary aim is to serve as a reminder for me of the steps required to get everything working. It may be useful if you are wondering how well MythTV works in Ireland with Freesat and the Saorview DTT service.

In summary, it works pretty well. If you have a satellite dish and an aerial, you can build a combined satellite/DTT PVR that picks up all of the UK and Irish channels, number the channels as you wish, and get a full 7-day EPG automatically off-air. No messing around with external EPGs, no pointing IR transmitters at external boxes, and no re-encoding video from external SCART inputs. (My TiVo still does this, and it's great, but it's error-prone.)

Software

As a FreeBSD user, I wanted to spend the least amount of time possible configuring Linux and the most amount of time configuring MythTV. For this reason, I chose Mythbuntu. It seems to give you the ease of installation of Ubuntu with all of the MythTV software ready to go. I used Mythbuntu 9.10 - this is based on Ubuntu 9.10 and MythTV 0.22. (Update: currently on 11.04 / 0.24)

Hardware

MythTV is split into backends and frontends. The backends have minimal hardware requirements. The frontends need a little more power as they have to decode and display the video.

Backend/Frontend

I used quite old hardware to build a combined backend/frontend, and have found that apart from displaying BBC HD (where it stutters), the system manages to run smoothly most of the time. The hardware I used was:

Asus A7N8X-VM 
Nvidia GeForce 4 MX
Athlon XP 2600+
2GB RAM
320GB PATA

As you can see, it's circa 2004 hardware, so any modern system should be more than adequate for the task. HD recording is no problem, but for HD viewing, you'll either need a fast enough CPU or a GPU with VDPAU.

For video input, I initially bought a Hauppauge WinTV HVR-4000. This is a combined DVB-S2 and DVB-T card. But there is a catch: you can only use one tuner at a time. Because of this, I decided to dedicate it for satellite use and added a WinTV Nova-HD-S2 so that I could watch/record two programmes on satellite at the same time. For DTT, I installed a WinTV Nova-T-500 which is a dual-tuner DVB-T card.

For video output, I just used VGA and line out, as this is all I have on my motherboard.

Frontend

For viewing in another room, I built a small diskless fanless frontend using MiniMyth. The hardware I used was:

Zotac Ion ITX C-E
2GB DDR2-800 PC2-6400
M350 Mini-ITX Case
Streamzap Remote Control

The system PXEboots its OS from a TFTP server on the backend. The result is full access to the MythTV backend and all its recorded programmes. You can even watch live TV. This is all streamed over the network. The Zotac motherboard has HDMI, DVI and VGA outputs. While HDMI output worked, I couldn't get MiniMyth to adjust the audio output level using the remote control (it appeared to be fixed on HDMI output), so I just used analog line out audio and DVI for video. (Update: changing the mixer settings in the frontend allows audio level changes on HDMI).

Configuration

HVR-4000 / Nova-HD-S2

The HVR-4000 and Nova-HD-S2 require firmware, so won't scan for satellite channels on initial install. I installed the v1.26.90.0 firmware as described here. After a reboot, you can do a Full Scan (Tuned) with these settings:

Frequency: 10847000
Polarisation: Vertical
Symbol Rate: 22000000
Default for everything else

This takes a while, but should get you all of the Freesat channels plus everything else at 28.2E.

Nova-T-500

For Irish DTT, do a Full Scan (Tuned) with these settings:

Freq = 546000000 (UHF Channel 30 - Three Rock MUX 1)
Freq = 570000000 (UHF Channel 33 - Three Rock MUX 2)
Band = 8MHz
Inversion = Auto
Constellation = QAM 64
LP Coderate = 1/2
HP Coderate = 2/3
Trans. Mode = 8k
Guard Interval = 1/32
Hierarchy = None 

While the Nova-T-500 will work out of the box, there are a number of problems once it's up and running. To ensure stable operation, create /etc/modprobe.d/dvb-t.conf as follows:

# Enable DiB0700 Low Noise Amps
options dvb-usb-dib0700 force_lna_activation=1
# Disable DVB remote(s)
options dvb-usb disable_rc_polling=1
# stop usb sleeping
options usbcore autosuspend=-1

Unfortunately the side effect of the above is that you lose remote control functionality on the DVB-T card and the DVB-S card. You'll need a separate remote control solution.

Another useful addition to dvb-t.conf is forcing the order that DVB cards are recognised at boot time. Without this, the cards may appear in a different order at subsequent boots and cause confusion. This config forces the satellite cards to be adapters 0 and 1, and the terrestrial cards to be 2 and 3:

# sat first
options cx88_dvb adapter_nr=0,1
# dtt second
options dvb_usb_dib0700 adapter_nr=2,3

Another reason for doing this is that I want BBC1 instead of RTE1 to be the default channel when choosing to watch live TV. This is because of the MPEG-4 issue below.

Some manual database tweaking is also possible for tuner order.

With the information above, everything should be working at this point. Unfortunately while MPEG-2 video from Freesat works well, MythTV has a bit more difficulty handling DTT and MPEG-4.

When tuning away from a channel with MPEG-4, you may hear a huge amount of disk activity and see your log files full of messages that say "number of reference frames exceeds max". This causes a significant performance hit and a workaround is necessary. To stop the messages appearing in the logfile, installing syslog-ng with a filter is a pretty good solution. Steps as follows:

1) create fifo files: 
   mkfifo /var/log/mythtv/mythfrontend.fifo
   mkfifo /var/log/mythtv/mythbackend.fifo

2) Edit /etc/default/mythtv-backend like this:
# User as which to run
USER=mythtv
# Replace all arguments to mythtv-backend
#ARGS="--logfile /var/log/mythtv/mythbackend.log"
ARGS="--logfile /var/log/mythtv/mythbackend.fifo"

Edit /usr/share/mythtv/mythfrontend.sh like this:
#    MYTHFELOG="/var/log/mythtv/mythfrontend.log"
    MYTHFELOG="/var/log/mythtv/mythfrontend.fifo"

3) install syslog-ng

4) add to bottom of /etc/syslog-ng/syslog-ng.conf
source mythfront-s {
        pipe("/var/log/mythtv/mythfrontend.fifo");
};
source mythback-s {
        pipe("/var/log/mythtv/mythbackend.fifo");
};
destination mythfront-d { file("/var/log/mythtv/mythfrontend.log"); };
destination mythback-d  { file("/var/log/mythtv/mythbackend.log");  };
filter mpeg4-errors {not match("number of reference frames exceeds max");};
log {
        source(mythfront-s);
        filter(mpeg4-errors);
        destination(mythfront-d);
};
log {
        source(mythback-s);
        filter(mpeg4-errors);
        destination(mythback-d);
};

5) Set owners on logfiles:
chown root.mythtv mythfrontend.log
chown kj.mythtv mythfrontend.fifo
chown root.mythtv mythbackend.log
chown mythtv.mythtv mythbackend.fifo

6) Restart syslog-ng

7) Restart frontend and backend

Duplicate recordings

When a recording is scheduled and the programme is found on two channels at the same time, both broadcasts will be recorded. I noticed this when recording from RTE Radio 1. On my system, RTE is on channel 750 on Satellite and channel 901 on DTT. To prevent duplicate recordings, I changed the priority on the satellite channels to -1 using the channel editor in the backend settings. This appeared to work for a while, but a more drastic solution was necessary: simply hide either the satellite or DTT channels from the EPG, again using the channel editor.

Hiding channels with MySQL

The original scan for satellite channels added hundreds of channels to the EPG with channel numbers from 1-60000. I used the Freesat EPG numbering scheme to move channels to a number range of 101-999. This left all of the unwanted channels with channel numbers greater than 1000. To remove these from the EPG, I modified the MythTV database:

% mysql -u mythtv -pXXX mythconverg
mysql> set visible=0 from channel where channum > 1000;

NFS / mythlink.pl

Recorded programmes are stored in /var/lib/mythtv/recordings and this is exported via NFS. You can mount this from any client and use a media player to watch recordings. The only catch is that the filenames are in MythTV format and not particularly human readable.

mythlink.pl is a Perl script that consults the database and creates symbolic links to the recordings with easy-to-read filenames. I have a cron job to run this at 6am each morning.

0 6 * * * /home/kj/bin/mythlink.pl --dest /var/lib/mythtv/recordings/l

mythlink.pl first appeared in MythTV 0.23. As my system is running 0.22, I have placed it in my home directory and made a small change to suit my system:

#        symlink $show->{'local_path'}, "$dest/$name"
        symlink "../".basename($show->{'local_path'}), "$dest/$name"

I'm forcing the symlinks to point to the recordings in ".." because when you mount the file system remotely, the default link points to /var/lib/mythtv/recordings which is not present on the client.

Backend settings

General

192.168.1.x for both local backend and master backend.
Don't allow commercial detection jobs.

Capture cards

SAT-1
- Max recordings = 1
- DON'T Open DVB card on demand
- Use DVB Card for active EIT scan
- Tuning delay = 0
SAT-2
- Max recordings = 1
- DON'T Open DVB card on demand
- DON'T use DVB Card for active EIT scan
- Tuning delay = 0
DTT-1
- Max recordings = 1
- Open DVB card on demand
- Use DVB Card for active EIT scan
- Tuning delay = 150ms
DTT-2
- Max recordings = 1
- Open DVB card on demand
- DON'T Use DVB Card for active EIT scan
- Tuning delay = 150ms

Video sources

Create two sources: DTT-EPG and SAT-EPG

Input connections

Display name: SAT1
Video source: SAT-EPG
Quick tuning: Never
Start channel: 101

Display name: SAT2
Video source: SAT-EPG
Quick tuning: Never
Start channel: 101

Display name: DTT1
Video source: DTT-EPG
Quick tuning: Never
Start channel: 1

Display name: DTT2
Video source: DTT-EPG
Quick tuning: Never
Start channel: 1

MiniMyth Configuration

For MiniMyth to PXE boot, a DHCP server on the LAN needs to specify the boot host that is running a TFTP server. I already had a DHCP server, so I configured it to use the address of the backend as the boot host. On the backend, TFTP and PXE software was required:

apt-get install tftp-hpa
apt-get install pxe

cp /usr/lib/syslinux/pxelinux.0 /var/lib/tftpboot

/etc/init.d/tftp restart

PXE needs a config file called /var/lib/tftpboot/pxelinux.cfg/default

DEFAULT minimyth-ram

LABEL minimyth-ram
        KERNEL minimyth/kernel
        APPEND ro root=/dev/ram0 ramdisk_size=128000 initrd=minimyth/rootfs

MiniMyth is installed in /var/lib/tftpboot/minimyth where there should be a "kernel" file a "rootfs" file and a "themes" directory. MiniMyth's config files are in the /var/lib/tftpboot/conf/default/ directory.

Below is my minimyth.conf. DHCP is used to get a dynamic IP address during the network boot process, but is then replaced with a fixed address once the system is up and running.

MM_DHCP_ADDRESS='192.168.1.x'
MM_DHCP_BROADCAST='192.168.1.255'
MM_DHCP_SUBNET_MASK='255.255.255.0'
MM_DHCP_ROUTERS='192.168.1.1'
MM_DHCP_HOST_NAME='minimyth'
MM_DHCP_DOMAIN_NAME='jeacle.ie'
MM_DHCP_DOMAIN_NAME_SERVERS='192.168.1.1'
MM_DHCP_NTP_SERVERS='tick.eircom.net'
MM_DHCP_TCODE='Europe/Dublin'

MM_MINIMYTH_BOOT_URL='tftp://192.168.1.y/'

MM_MASTER_DBUSERNAME='mythtv'
MM_MASTER_DBPASSWORD='xxx'
MM_MASTER_DBNAME='mythconverg'
MM_MASTER_SERVER='192.168.1.y'

MM_THEME_NAME='MythCenter'
MM_THEMEOSD_NAME='BlackCurves-OSD'

MM_LIRC_AUTO_ENABLE='yes'
MM_LIRC_FETCH_LIRCRC_MYTHTV='yes'

MM_VIDEO_ASPECT_RATIO='16:9'
MM_VIDEO_RESIZE_ENABLED='yes'
MM_VIDEO_DEINTERLACER='auto'
MM_VIDEO_DECODER='vdpau'
MM_VIDEO_PLAYBACK_PROFILE='VDPAU Slim'

MM_X_MODE='1360x768'
MM_X_OUTPUT_DVI='auto'

MM_PLUGIN_GAME_ENABLED='no'
MM_PLUGIN_OPTICAL_DISK_ENABLED='no'
MM_PLUGIN_STREAM_ENABLED='no'
MM_PLUGIN_ZONEMINDER_ENABLED='no'
MM_FLASH_URL='none'

MM_MEDIA_GALLERY_URL='nfs://192.168.1.z/mnt/media/photos/nfs'
MM_MEDIA_MUSIC_URL='nfs://192.168.1.z/mnt/media/music/albums'
MM_MEDIA_VIDEO_URL='nfs://192.168.1.z/mnt/media/video'

MM_X_SCREENSAVER='xorg'
MM_X_SCREENSAVER_TIMEOUT='30'

MM_MYTHDB_SETTINGS_StickyKeys='StickyKeys~0'

#MM_X_OUTPUT_HDMI='1'
#MM_AUDIO_TYPE='digital'
#MM_AUDIO_CARD_NUMBER='0'
#MM_AUDIO_DEVICE_NUMBER='3'

Next, the lircrc.mythtv for my Streamzap. I have mapped "Info" to the Red button, and "Delete" to the Green button.

begin
    prog = mythtv
    button = KEY_MUTE
    config = |
end

begin
    prog = mythtv
    button = KEY_1
    config = 1
end

begin
    prog = mythtv
    button = KEY_2
    config = 2
end

begin
    prog = mythtv
    button = KEY_3
    config = 3
end

begin
    prog = mythtv
    button = KEY_4
    config = 4
end

begin
    prog = mythtv
    button = KEY_5
    config = 5
end

begin
    prog = mythtv
    button = KEY_6
    config = 6
end

begin
    prog = mythtv
    button = KEY_7
    config = 7
end

begin
    prog = mythtv
    button = KEY_8
    config = 8
end

begin
    prog = mythtv
    button = KEY_9
    config = 9
end

begin
    prog = mythtv
    button = KEY_0
    config = 0
end

begin
    prog = mythtv
    button = KEY_CHANNELUP
    config = PgUp
    repeat = 2
    delay = 4
end

begin
    prog = mythtv
    button = KEY_CHANNELDOWN
    config = PgDown
    repeat = 2
    delay = 4
end

begin
    prog = mythtv
    button = KEY_VOLUMEUP
    config = ]
    repeat = 2
    delay = 4
end

begin
    prog = mythtv
    button = KEY_VOLUMEDOWN
    config = [
    repeat = 2
    delay = 4
end

begin
    prog = mythtv
    button = KEY_UP
    config = Up
    repeat = 2
    delay = 4
end

begin
    prog = mythtv
    button = KEY_DOWN
    config = Down
    repeat = 2
    delay = 4
end

begin
    prog = mythtv
    button = KEY_LEFT
    config = Left
    repeat = 2
    delay = 4
end

begin
    prog = mythtv
    button = KEY_RIGHT
    config = Right
    repeat = 2
    delay = 4
end

begin
    prog = mythtv
    button = KEY_OK
    config = Return
end

begin
    prog = mythtv
    button = KEY_MENU
    config = M
end

begin
    prog = mythtv
    button = KEY_EXIT
    config = Esc
end

begin
    prog = mythtv
    button = KEY_PLAY
    config = P
end

begin
    prog = mythtv
    button = KEY_PAUSE
    config = P
end

begin
    prog = mythtv
    button = KEY_STOP
    config = Escape
end

begin
    prog = mythtv
    button = KEY_PREVIOUS
    config = seek_backward
end

begin
    prog = mythtv
    button = KEY_NEXT
    config = seek_forward
end

begin
    prog = mythtv
    button = KEY_REWIND
    config = <
end

begin
    prog = mythtv
    button = KEY_FORWARD
    config = <
end

begin
    prog = mythtv
    button = KEY_RECORD
    config = R
end

begin
    prog = mythtv
    button = KEY_RED
    config = i
end

begin
    prog = mythtv
    button = KEY_GREEN
    config = d
end

For MiniMyth to store data across reboots, make a "conf-rw" directory in /var/lib/tftpboot and chmod it 777. Also modify /etc/inetd.conf to start the TFTP server with the -c flag - this allows new files to be created.

Once up and running, you can telnet to the MiniMyth client with username root and no password. "mm_command mythdb_settings_print" will give you a list of configuration variables - these can be modified as per the StickyKeys line above. You can also see the current log entries using http://a.b.c.d:8080/var/log/messages