Table of Contents

Introduction and Overview

In this tutorial I want to explain how you can combine Mythtv (a free Media Center software for Linux) and Aontv (an Austrian IPTV service of Telekom Austria). Why do you want to do this when you already have a working Settop Box sitting beneath your TV? Mythtv turns your PC into a digital video recorder with the following features:

livetv welcome recordings

The tutorial basically shows how I configured my system and does not claim to be the only or most elegant solution. It still is your own risk to follow my example. The tutorial covers different aspects, which may or may not be relevant for your own setup. You decide what you need and how much you are capable of realizing. The network configuration and the installation of Mythtv is rather easy and well documented here. The latter chapters may demand better skills and own research. Some configurations may be a task of a few minutes or may evolve into time and energy vampires. The provided link literature should in any case point you towards the right directions for problem solving. You should definitely check it if some of my comments are not so clear to you.

Mythbuntu Installation

For the operating system, I now use Mythbuntu 10.04 (get it here) and formerly use a standard Ubuntu Linux version. Mythbuntu gives you the advantage of installing a lightweight Mythtv installation right away - lightweight because it is using xfce instead of gnome. There are hardly any differences in the configuration but I will try to report most of them. One big difference is the installation, since Mythtv is configured and installed right from the LiveCD. Please mind that you have the possibility of installing a new system with a USB stick instead of burnt CDs (Startup Disk Creator on Ubuntu).

The basic installation of Mythbuntu is easy (slightly outdated tutorial). The only thing which requires your brain is the partitioning. Since 1 hour of recorded video is approximately 1.3 gigabyte you should have enough space. My filesystem consists of a 10gb system partition on / (ext4), 1gb swap space, the rest (ext4) for /home. The larger harddrive sdb1 250gb is mounted at /home/mythtv and also formatted to ext4. This is the place where I want Mythtv to store its recordings.

During the installation of Mythbuntu the basic settings for Mythtv are configured. Choose primary backend with frontend when asked. You may already enable the propietary driver for your graphics card if you available. The most parameter can be made later on in the Control Center, so I suggest skipping the settings concerning MythTV service, Lirc, etc. neither do you need to launch the Mythtv-Setup.

For best results connect your PC to the TV using a HDMI cable. check if your display is configured correctly. I needed to change my resolution manually to 1920×1080 using Nvidias system tool by choosing the correct resolution and writing it to the X Conf File. Additionally, make sure you installed all system updates. This may take some time…

One of the first things I deselect is to automatically launch the Frontend after reboot - this is not nice if your system is supposed to shutdown automatically (screenshot??). I install the text editor gedit and a Firefox extension called No Squint which makes the browsing on the TV more convenient by increasing the Zoom level. And I need alsa-tools-gui for my soundcard. Last system setting I am doing is enabling the VNC server, because I often need to administer my mythbox from another PC. Enable it in the Mythbuntu Control Centre and enter a password followed by a restart (screenshot??). automatically login??

Already existing Ubuntu installation

For a standard Ubuntu installation I recommend to use the Mythbuntu Control Centre, which makes the various options easily accessible.

Enable the proprietary graphic driver (if available). In Ubuntu disable Compiz's effects (in Appearence > Visual Effects) as there are problems with the panels being always on top bugreport.

Watching Aontv with VLC - only if needed

For setting up an Internet and an IPTV connection, I use 2 network cards. Other scenarios with different router firmwares are possible. Since only the firmware 8.6.9.0 for the Thomson Speedtouch 585v7 was running flawlessly for me, I chose to buy a network PCI card for less than 10€. If you have a newer firmware you do not need the second network interface! However, please note that Aontv currently only allows two IPTV streams, and only if you own two settop boxes. You can watch a show with one settop box and record another program with your mythbox.

You can find out if you are able to watch IPTV and Internet with the same connection by trying to open this .m3u playlist with VLC. It often takes some time until the picture comes up, so don't be too impatient. If you don't see anything you should proceed with the method outlined below or maybe update the router's firmware further reading.

The plan is to have one card accessing the Internet while the second card uses the IPTV stream. As a consequence, the different areas for each card need to be defined, i.e. by creating static routes. Additionally, the two cards need to get static IPs for being identifiable. So let's start:

stefan@earl:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 00:24:01:31:71:8b  
          inet addr:10.0.0.38  Bcast:10.0.0.255  Mask:255.255.255.0
          ...
eth1      Link encap:Ethernet  HWaddr 00:0c:6e:34:0f:08  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          ...  

Comments & Troubleshooting

MythTV Setup

Before we start with configuring Mythtv, two more items need to be dealt with. First, a channel list for Aontv programs is required. You can use mine for a start or customize it to your preferences (e.g. channel number, channel name). The syntax of the .m3u file is pretty understandable and easy to be configured manually with a text editor. Just note that the @ sign is not needed for mythtv but for vlc. In addition, the XMLTVIDs I use in my file are only relevant for people who want to use the xmltv grabber for the Electronic Program Guide. You are also able to change these details in the backend (Channel Editor). Anyway, I recommend to use the provided file for the start.

Second, it is a good idea to create directories, where Mythtv stores its recordings. Create the directories on a larger partition: one directory for livetv and one for recordings. In my case I created /home/mythtv/livetv & /home/mythtv/recordings. Please keep in mind that the Mythtv Backend is run by the user mythtv and not by your own user account. As a result, user mythtv needs read and write permissions for these directories. Either set them by using the file manager: right click on the folder > Properties > Permissions or by using our friend the command line:sudo chown -R mythtv /home/mythtv/livetv and sudo chgrp -R mythtv /home/mythtv/livetv (adjust the path and the user to your situation!). The result should be owner and group: mythtv (create and delete files). (screenshot?? - sudo chmod 775 -R for mythweb ”.mpg does not exist on the host..”)

and now for the fun part:

The time has arrived to test your new Media Center. Start the frontend and hit Watch Livetv! The first channel should show up after little delay. Test as well the mythweb plugin by starting your browser and directing it to this link: http://localhost/mythweb (remote machines use the Backend's IP instead of localhost, e.g. http://10.0.0.2/mythweb). Why not start your first test recording? Go to mythweb and schedule a recording for a certain channel in the near future… leave your mythbox running… and then check if the recording worked. It did? Perfect!

Some tweaks for Mythtv

(?? Samba+Mythbuntu /etc/samba/smb.conf - path videos in backend and frontend)

Connect other frontends

In Ubuntu install the Fronted with the package of mythtv-frontend. For connecting remote frontends to your primary backend, you need to know the MySQL password. The easiest way to find this password is to look in the backend setup under General on the first page. Additionally, the IP address is required. We already configured the IP of the backend to be reachable via LAN in Mythtv. The IP was eth0 with 10.0.0.2 in my example. The details need to be included in the the remote computer's frontend.

You will be informed that your user needs to be added to the mythtv group when starting the frontend for the first time; confirm the dialog; log out and log in again.

Troubleshooting

If you cannot connect to a remote backend, then its MySQL installation is most likely not configured for remote connections. To change this:

Electronic Program Guide

The EPG used by the Aontv settop boxes is at the moment not to accessible by Mythtv. A good workaround is the usage of a free xmltv grabber, I chose: the TV Movie grabber. However, note that not all TV channels of Aontv are provided by this grabber (e.g. Puls 4). That is a limitation you must live with - or you go out there, find a solution and report it here. First of all, install some packages needed for using xmltv and compiling the grabber:

In the tables.cpp, the channels for the grabber are defined. The easiest way is simply to replace the file with this one here.

Alternatively, you can configure the grabber's channel list yourself. Each channel needs to be configured with an XMLTVID in the grabber and in the mythtv database. What we want to achieve is that the XMLTVIDs of the grabber match the XMLTVIDs of Mythtv, so the right program information can be linked to the right channel. In the file tables.cpp the XMLTVIDs of the grabber can be included. It is easy to edit the file with a standard text editor. Look at the already configured entries in the file and start to make your own; remove the entry NULL and insert your XMLTVID instead, e.g.

{ "Arte", NULL, "" , "010" }
{ "Arte", "arte-tv.com", "" , "010" }

Of course, only the channels provided by Aontv should get an XMLTVID (so remove unnecessary entries).

On the Mythtv side, XMLTVIDs can be entered and changed in the Channel Editor of the Backend. Following the above example, the XMLTVID for the channel Arte becomes arte-tv.com. XMLTVIDs may already be set in the .m3u file for Mythtv. If you used my .m3u file you can also use my tables.cpp, as the entries are already made and match those of my m3u file.

Once you replaced the tables.cpp, open a terminal, move into the newly extracted directory and compile the grabber by running (English howto, German howto):

Now, the grabber is compiled and installed. Next, start the Mythtv Backend Setup and select Video Sources:

Open a browser and surf to your web frontend. Click on Listings. If you see the names of lots of TV shows for the different channels, you did it!

For downloading EPG data automatically, enable the Automatic run mythfilldatabase option in the frontend Utilities > Setup > General. I changed the mythfilldatabase Program command to mythfilldatabase from usr/bin/mythfilldatabase. You may also disable the Run mythfilldatabase at time suggested by the grabber and define the time and frequency the grabber should run.

If the times of the TV show listings are not displayed correctly: open the backend setup, select General and change your local time zone to auto (or configure the hours manually if that doesn't work).

Problems & Troubleshooting

Wake On Lan

You probably don't want to stand up from your convenient couch and start your mythbox by using your own hands - how oldschool! After a few modifications, you are able to start your PC via network (English howto, German howto).

#!/bin/bash
wakeonlan 00:0c:6e:34:0f:08

Programmed Wake-Up - ACPI Wakeup

One of the disadvantages of the mythbox is that it must be running for recording. A 24/7 server is neither environmentally friendly nor economically friendly and it is not necessary. You can configure your mythbox to wake up just a few minutes before a recording is scheduled. Your motherboard has to support this feature, but hardly any modern motherboards is not capable of waking up by alarm. For boards manufactured after 2000 the wakeup at a specific time and date should work. Furthermore, the mythbox can be configured to automatically shutdown, if it has nothing to do - how nice!

See those links for further information on ACPI wakeup:
http://www.mythtv.org/wiki/ACPI_Wakeup
http://www.vdr-wiki.de/wiki/index.php/ACPI_Wakeup
https://help.ubuntu.com/community/MythTV/Install/WhatNext/ACPIWake - good article but outdated method: /proc/acpi/alarm

In my case only the old method of NVRAM is supported (I have an asus p4pe). I can therefore only report about this outdated method, which you can try if you are not successful with the approach presented above (more info here and here):

Check, if it works by setting the wakeup time to 10 minutes in the future :

/usr/sbin/nvram-wakeup -s $((`date +%s` + 10 * 60))

If you have troubles with permissions for /dev/mem then you probably need to use sudo.

So far so good. If the wakeup command requires administration rights, the mythtv user must be equipped with some special rights.

(?? check sudo)

# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults        env_reset

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL) ALL

# Uncomment to allow members of group sudo to not need a password
# (Note that later entries override this, so you might need to move
# it further down)
# %sudo ALL=NOPASSWD: ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
%mythtv ALL = NOPASSWD: /sbin/halt, /usr/sbin/nvram-wakeup

It's now time to configure Mythtv under Utilities > Setup > General. I always deselct the Block shutdown before…. Set a time for the seconds of idle time before the system is automatically brought down. Also, the time for the system to wait for the next scheduled recording and how many minutes before the recording the alarm is set. The wakeup time format is time_t for the nvram method and the command to set wakeup time is sudo /usr/sbin/nvram-wakeup -s $(($time +300)). The server halt command is a simple sudo shutdown -h now. In any case, take a look at the provided screenshot and read the explanations for the available options in Mythtv.

Remote Control via Lirc

What is missing for a true media center is a remote control. I recommend buying your own on the internet, but be sure to check for its compatibility with linux i.e lirc. I've bought a USB remote control for one of Microsoft's Media Center software, which I highly recommend (http://www.mythtv.org/wiki/MCE_Remote & http://www.oneweb.co.uk/mythtv/2009/02/configuring-your-mce-ir-remote/). English lirc howto German lirc howto.

In my case the configuration was easy using the Mythbuntu Control Centre. Under Infrared Devices select the configuration files for your remote; mine Windows Media Center remotes.

Customize the remote buttons to your hands. First, you must find out how the remote's buttons are recognized by your system. This information is found in the file /etc/lirc/lircd.conf. It is possible that this file only holds links to other configuration files of remotes, which you should read instead! In those .conf files a name is allocated to each button's infrared code, e.g.

      begin codes
          input                    0xD02F
          energy_saving            0xA956
          power                    0x10EF
          tvradio                  0x0FF0
          av_mode                  0x0CF3
          one                      0x8877

Similarly, in the ~/.lircrc file the buttons' names are allocated to actions or again links are provided to the actual files (e.g. the .lirc directory). In essence, the .lircrc defines what happens when a certain button is pressed. Each program may have its own file, per default mythtv's lirc commands are set in ~/.lirc/mythtv. Have a look at mine. As you can see, important variables are the name of the remote, the program the command is executed in, the button pressed and the action to execute. Just follow the example and use the keybindings of Mythtv for your own customized remote.

These keypresses are only active if mythfronted is running. If you want to start the program with the remote, you can use the irexec program, which simply executes commands on keypresses.

begin
  remote = mceusb
  prog = irexec
  button = Home
  config = mythfrontend &
end

The & sign is necessary to make irexec available during Mythtv. Then start irexec as daemon process by running irexec -d and let the system launch irexec after startup (list it under System > Preferences > Startup Applications in Ubuntu and under System > Session and Startup with the command irexec -d).

IR Transmitter

You have external devices like your TV or an amplifier you want to control with your mythbox's remote? With the necessary hardware (IR eye, transmitter), you can pass on custom IR commands to these devices. Just plug in your IR eye and point it to the IR receiver of your device in short distance.

include "/usr/share/lirc/remotes/custom/custom.conf"
#!/bin/bash
irsend SET_TRANSMITTERS 1
irsend SEND_ONCE RM-S325 vol+
begin
    remote = mceusb
    prog = irexec
    button = VolUp
    config = /home/stefan/Desktop/louder.sh
    repeat = 0
    delay = 0
end

Links

Aontv related

http://osalliance.com/netculture/project/multimediahome/summary - osalliance - where I learned about mythtv+aontv
http://lab.netculture.at/wiki/doku.php?id=utopia:mythtv#myth_server_lab_dornbirn - net culture lab wiki - valuable infos
http://www.dieschmids.at/ - fantastic site for aon and aontv related topics
http://xdsl.at/viewtopic.php?f=59&t=46556 - windows solution for static routes of aontv and internet
http://www.aontv.org/ - aontv wiki, check out the forum

Mythtv

http://www.mythtv.org/wiki/XMLTV