Ubuntu 12.04 MythTV

DOCUMENT IN PROGRESS

Introduction
MythTV is a very powerful and flexible PVR/Media Server system with many features and can be a useful addition on your home network.

Outline
Installing and configuring MythTV is difficult. If you have never used it before it will take your hours, if not days to set it up depending on the spare time you have. I made this guide mainly as a reminder to myself about how I did it as I will eventually forget.

I usually use Debian but support for MythTV is better on Ubuntu, so I am using Ubuntu 12.04 LTS which should give me a few years of stable operation with little maintenance.

Enviroment
I run seperate Backend and Frontends.

Myth Backend is a virtual machine running on VMware ESXi5. I discovered that even though my server hardware is to old to support VT-d I could still pass through my NOVA-TD-500 Tuner PCI card from host to guest because it is actually a USB hub with 2 HD tuners that appear as USB devices and ESXi5 supports USB pass through. Great!

Myth Frontend runs on an old Asus A7V Notebook with DVI->HDMI link to my Television.

I will update this section with a bit more info in due course.

Quick Install Overview
Download the ubuntu-12.04-server-amd64 ISO and boot it.

The following is a quick run through.


 * Boot Screen
 * Language choose your language
 * F4 Install a minimal system
 * F6 Select Expert mode
 * Select Install Ubuntu Server Hit Enter


 * Choose Language
 * select a language: choose your language
 * Select you location: choose you country, territory or area
 * Configure locales: select you country to base default locale settings on, typically this will be the UTF-8 variant
 * Additional locales: add any additional locales
 * System locale: choose the default system locale if you have chosen multiple locales in the previous option


 * Configure the keyboard
 * Detect keyboard layout: No
 * Country of origoin for the keyboard: select your keyboard country of origin
 * Keyboard layout select your keyboard layout


 * Detect and mount CD-ROM
 * Modules to load: select any modules required


 * Load debconf preconfiguration file


 * Load installer components from CD
 * Installer components to load: select any components - I leave these empty


 * Detect network hardware
 * Modules to load: select any modules required


 * Configure the network
 * Auto-configure networking? No
 * IP address: set your computers ip address
 * Netmask: set your computers netmask
 * Gateway: set your computers gateway
 * Name server addresses: set your computers name servers
 * Is this information correct? Yes/No
 * Hostname: set your computers hostname
 * Domain Name: Input your local domain name


 * Set up users and passwords
 * Enable shadow passwords? Yes
 * Allow login as root? Yes
 * Root password: root password and verify
 * Create a normal user account now? No


 * Configure the clock
 * Set the clock using NTP? Yes
 * NTP server to use: leave as default and continue
 * Is this time zone correct? Yes/No


 * Detect disks
 * Modules to load: select any modules required


 * Partition disks
 * Partitioning method: Manual


 * Configure your disk formatting options.


 * Install the base system (It will install the base Ubuntu system packages)
 * Drivers to include in the initrd: generic: include all available drivers


 * Configure the package manager
 * Use a network mirror? Yes and select your closest mirror and proxy settings
 * Use restricted software: Yes
 * Use software from the "universe" component? Yes
 * Use software from the "multiverse" component? Yes
 * Use backported software? No
 * Services to use: Select security updates only


 * Select and install software
 * How do you want to manage ugprades on this system? No automatic updates
 * Choose software to install: Un-select all options


 * Install the GRUB boot loader on a hard disk
 * Install the GRUB boot loader to the master boot record? Yes


 * Finish the installation
 * Is the system clock set to UTC? No if multibooting with Windows, otherwise Yes
 * Installation complete: Continue

Quick Base Software Overview
apt-get install --no-install-recommends ssh tcpd openssh-blacklist openssh-blacklist-extra

cat > /etc/apt/apt.conf.d/10recommends < /etc/apt/apt.conf.d/90apt-file <<EOF APT::Update::Post-Invoke {"/usr/bin/apt-file update"; }; EOF

apt-get update

apt-get install vim vim-doc vim-scripts vim-addon-manager less

I don't use resolvconf

apt-get autoremove --purge resolvconf

Edit and add the quiet option

GRUB_CMDLINE_LINUX_DEFAULT="quiet"

update-grub reboot

Tidy up e.g.

auto eth0 iface eth0 inet static address 10.39.41.8 netmask 255.255.255.0 gateway 10.39.41.254
 * 1) The primary network interface

And check is correct.

apt-get install linux-firmware linux-firmware-nonfree apt-get install htop build-essential module-assistant linux-headers-generic tofrodos dosfstools fakeroot hdparm ntfs-3g rsync mlocate dkms pwgen \ bash-doc hwdata bzip2 p7zip rar unrar unzip zip p7zip-full lzop lzip lzma ntp fontconfig lshw hwinfo syslinux dnsutils sshfs screen telnet lsof \ bash-completion

Edit, add ntp servers.

server au.pool.ntp.org server ntp.cs.mu.oz.au

service ntp restart ntpq -p

wget -O /etc/skel/.profile "http://www.bitbinary.com/dotfiles/bash_.profile" wget -O /etc/skel/.bashrc "http://www.bitbinary.com/dotfiles/bash_.bashrc" wget -O /etc/skel/.bash_aliases "http://www.bitbinary.com/dotfiles/bash_.bash_aliases" wget -O /etc/skel/.bash_functions "http://www.bitbinary.com/dotfiles/bash_.bash_functions" wget -O /etc/skel/.bash_logout "http://www.bitbinary.com/dotfiles/bash_.bash_logout" wget -nc -O /etc/skel/.vimrc "http://www.bitbinary.com/dotfiles/vim_.vimrc"

Edit, add the following alias.

alias invoke-rc.d='service'            # ubuntu uses service

cp -R /etc/skel/. ~/

MySQL
apt-get install mysql-server

I did not set a root password when prompted 3 times by debconf.

┌─────────────────────────────────────────┤ Configuring mysql-server-5.5 ├─────────────────────────────────────────┐ │ While not mandatory, it is highly recommended that you set a password for the MySQL administrative "root" user. │ │                                                                                                                 │ │ If this field is left blank, the password will not be changed. │ │                                                                                                                 │ │ New password for the MySQL "root" user:                                                                          │ │                                                                                                                 │ │ ________________________________________________________________________________________________________________ │ │                                                                                                                  │ │                                                                                                              │ │                                                                                                                 │ └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Stop MySQL

service mysql stop

I have 4GB memory allocated to my backend and use the my-huge example mysql cnf file

zcat /usr/share/doc/mysql-server-5.5/examples/my-huge.cnf.gz > /etc/mysql/conf.d/my-huge.cnf

Edit and comment out the following options as I am not doing master master replication and don't need binary logs filling up /var/lib/mysql/


 * 1) log-bin=mysql-bin

Edit /etc/mysql/my.cf and comment out bind-address = 127.0.0.1 so MySQL binds to all network adapters.


 * 1) bind-address      = 127.0.0.1

Start MySQL

service mysql start

Myth Backend
I prefer to use the mythtv account and the usual home directory for mythtv, Ubuntu does this a little differently. So I create the user account manually beforehand.

useradd -d /var/lib/mythtv -m -s /bin/bash -u 999 -U -r -G video,audio,cdrom,adm mythtv

Install mythtv-backend and some recommended packages

apt-get install mythtv-backend mythtv-database libmyth-python libmythtv-perl ffmpeg transcode libdvdnav4 ghostscript \ sox mjpegtools twolame libavcodec-extra-53

┌──────────────────────────────────────────────┤ Configuring mythtv-database ├──────────────────────────────────────────────┐ │                                                                                                                          │ │ If any other computers (that includes other Front End machines) with MythTV will be used, this computer needs to be       │ │ configured to allow remote connections. │ │                                                                                                                          │ │ Note that this is a security risk, as both the MythTV and MySQL services will be exposed. Be sure to place this machine  │ │ behind a firewall. │ │                                                                                                                          │ │ If multiple interfaces are used, the first one listed in 'ifconfig' will be used. │ │                                                                                                                          │ │ Will other computers run MythTV? │ │                                                                                                                          │ │                                                                                                                  │ │                                                                                                                          │ └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

I update the default SQL password the mythtv, less secure but more convenient.

mysql -u root -p mysql

UPDATE user SET Password=PASSWORD('mythtv') WHERE user='mythtv'; FLUSH PRIVILEGES; quit

Edit the following files and update the password entry:

/etc/mythtv/mysql.txt /etc/mythtv/config.xml

and are symlinks to these files.

MythWeb
apt-get install mythweb libhttp-date-perl libmath-round-perl xfonts-terminus xfonts-terminus-dos xfonts-terminus-oblique ttf-mscorefonts-installer gsfonts-x11 \ ttf-dejavu ttf-liberation ttf-freefont ttf-droid

┌───────────────────────────────────────────────────┤ Configuring mythweb ├───────────────────────────────────────────────────┐ │                                                                                                                            │ │ MythWeb is the web interface of MythTV. It is possible to restrict access by enabling password protection. It is STRONGLY  │ │ recommended that you set a password if your MythWeb will be exposed to the World Wide Web. │ │                                                                                                                            │ │ Would you like to password-protect your MythWeb? │ │                                                                                                                            │ │                                                                                                                    │ │                                                                                                                            │ └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

┌────────────────────────────────────────────────────┤ Configuring mythweb ├─────────────────────────────────────────────────────┐ │                                                                                                                               │ │ If this computer's web service will only be used with mythweb, apache can be configured to redirect all requests directly to   │ │ mythweb. If you choose not to do this, then you can access mythweb from the /mythweb subdirectory. │ │                                                                                                                               │ │ Will you be using this webserver exclusively with mythweb? │ │                                                                                                                               │ │                                                                                                                       │ │                                                                                                                               │ └────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Reboot and you should be able to access mythtweb, could restart services but whatever works...

The imdb scraper needs to be added to http:// /mythweb/settings/video

Set the host and then update:

Path to imdb.pl on this webserver: /usr/share/mythtv/metadata/Movie/tmdb.py

MythTV Frontend Installation
apt-get install xorg mesa-utils xbase-clients xsel dbus-x11 xfonts-terminus xfonts-terminus-dos xfonts-terminus-oblique \ ttf-mscorefonts-installer gsfonts-x11 ttf-dejavu ttf-liberation ttf-freefont libgl1-mesa-dri

LIRC
apt-get install lirc

┌─────────────────────────────────────────────┤ Configuring lirc ├──────────────────────────────────────────────┐ │ If you choose a remote or transmitter, but already have a configuration file in /etc/lirc/lircd.conf, the    │ │ existing file will be renamed to /etc/lirc/lircd.conf.dpkg-old and the community configurations loaded into  │ │ /etc/lirc/lircd.conf. If you have a /etc/lirc/lircd.conf.dpkg-old file already, it will not be overwritten  │ │ and your current /etc/lirc/lircd.conf will be lost. │ │                                                                                                               │  │ Remote control configuration:                                                                                 │ │                                                                                                              │  │                      ...                                                                                      │  │                      Windows Media Center Transceivers/Remotes (all)                      ↓                   │ │                     ...                                                                                      │  │                                                                                                               │  │                                                                                                               │  │                                                                                                           │ │                                                                                                              │  └───────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

┌──────────────────────────────────────────────┤ Configuring lirc ├───────────────────────────────────────────────┐ │ IR transmitters can be used for controlling external devices. Some devices are considered transceivers, with  │ │ the ability to both send and receive. Other devices require separate hardware to accomplish these tasks. │ │                                                                                                                 │  │ IR transmitter, if present:                                                                                     │ │                                                                                                                │  │                     None                                                                                        │ │                    ...                                                                                         │  │                                                                                                                 │  │                                                                                                                 │  │                                                                                                             │ │                                                                                                                │  └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

If you need to reconfigure the remote run this:

dpkg-reconfigure lirc

Also this may be needed (adjust the kernel version where necessary)

ln -s /lib/modules/3.2.0-29-generic/kernel/drivers/staging/media/lirc /lib/modules/3.2.0-29-generic/kernel/drivers/staging/lirc

https://bugs.launchpad.net/ubuntu/+source/lirc/+bug/1004239

This configuration works but I had a mythtv .lircrc file already created from a previous frontend that used devinput rather than mce_usb, plus I was having some weird key repeat issues so I played around with the lirc config and got it working using devinput as follows:

/etc/lirc/hardware.conf

REMOTE="Windows Media Center Transceivers/Remotes (all)" REMOTE_MODULES="" REMOTE_DRIVER="devinput" REMOTE_DEVICE="/dev/input/by-id/usb-Topseed_eHome_Infrared_Transceiver_TS000zQ9-event-if00" REMOTE_SOCKET="" REMOTE_LIRCD_CONF="devinput/lircd.conf.devinput" REMOTE_LIRCD_ARGS="" TRANSMITTER="None" TRANSMITTER_MODULES="" TRANSMITTER_DRIVER="" TRANSMITTER_DEVICE="" TRANSMITTER_SOCKET="" TRANSMITTER_LIRCD_CONF="" TRANSMITTER_LIRCD_ARGS="" START_LIRCD="true" START_LIRCMD="" LOAD_MODULES="" LIRCMD_CONF="" FORCE_NONINTERACTIVE_RECONFIGURATION="false"

/etc/lirc/lircd.conf

# # include "/usr/share/lirc/remotes/devinput/lircd.conf.devinput"
 * 1) This configuration has been automatically generated via
 * 2) the Ubuntu LIRC package maintainer scripts.
 * 1) It includes the default configuration for the remote and/or
 * 2) transmitter that you have selected during package installation.
 * 1) Feel free to add any custom remotes to the configuration
 * 2) via additional include directives or below the existing
 * 3) Ubuntu include directives from your selected remote and/or
 * 4) transmitter.
 * 1) Configuration for the Windows Media Center Transceivers/Remotes (all) remote:
 * 2) include "/usr/share/lirc/remotes/mceusb/lircd.conf.mceusb"

The ~/.lircrc file...

begin prog = mythtv button = KEY_SLEEP config = end begin prog = mythtv button = KEY_RADIO config = end begin prog = mythtv button = KEY_AUDIO config = end begin prog = mythtv button = KEY_VIDEO config = F3 end begin prog = mythtv button = KEY_CAMERA config = end begin prog = mythtv button = KEY_PVR config = F1 end begin prog = mythtv button = KEY_EPG config = F2 end begin prog = mythtv button = KEY_TUNER config = F4 end begin prog = mythtv button = KEY_DVD config = F5 end begin prog = mythtv button = KEY_MUTE config = F9 end begin prog = mythtv button = KEY_VOLUMEUP config = F11 repeat = 1 end begin prog = mythtv button = KEY_VOLUMEDOWN config = F10 repeat = 1 end begin prog = mythtv button = KEY_MEDIA config = M end begin prog = mythtv button = KEY_CHANNELUP config = Up end begin prog = mythtv button = KEY_CHANNELDOWN config = Down end begin prog = mythtv button = KEY_EXIT config = Esc end begin prog = mythtv button = KEY_INFO config = I end begin prog = mythtv button = KEY_UP config = Up    repeat = 1 end begin prog = mythtv button = KEY_DOWN config = Down repeat = 1 end begin prog = mythtv button = KEY_LEFT config = Left repeat = 1 end begin prog = mythtv button = KEY_RIGHT config = Right repeat = 1 end begin prog = mythtv button = KEY_OK config = Enter end begin prog = mythtv button = KEY_RECORD config = R end begin prog = mythtv button = KEY_STOP config = Esc end begin prog = mythtv button = KEY_REWIND config = Left repeat = 3 end begin prog = mythtv button = KEY_PLAY config = Ctrl+P end begin prog = mythtv button = KEY_FASTFORWARD config = Right repeat = 3 end begin prog = mythtv button = KEY_PREVIOUS config = PgUp end begin prog = mythtv button = KEY_NEXT config = PgDown end begin prog = mythtv button = KEY_PAUSE config = P end begin prog = mythtv button = KEY_NUMERIC_1 config = 1 end begin prog = mythtv button = KEY_NUMERIC_2 config = 2 end begin prog = mythtv button = KEY_NUMERIC_3 config = 3 end begin prog = mythtv button = KEY_NUMERIC_4 config = 4 end begin prog = mythtv button = KEY_NUMERIC_5 config = 5 end begin prog = mythtv button = KEY_NUMERIC_6 config = 6 end begin prog = mythtv button = KEY_NUMERIC_7 config = 7 end begin prog = mythtv button = KEY_NUMERIC_8 config = 8 end begin prog = mythtv button = KEY_NUMERIC_9 config = 9 end begin prog = mythtv button = KEY_NUMERIC_STAR config = end begin prog = mythtv button = KEY_NUMERIC_0 config = 0 end begin prog = mythtv button = KEY_NUMERIC_POUND config = end begin prog = mythtv button = KEY_DELETE config = end begin prog = mythtv button = KEY_ENTER config = Enter end begin prog = irexec button = KEY_RED config = /var/lib/mythtv/.bin/kill-mythfrontend.sh end begin prog = mythtv button = KEY_GREEN config = end begin prog = mythtv button = KEY_YELLOW config = end begin prog = mythtv button = KEY_BLUE config = end begin prog = mythtv button = KEY_SUBTITLE config = end

I have a panic button assigned to the remote if/when mythfrontend might become stuck, this is probably more useful on standalone frontends. Create the following file:

/var/lib/mythtv/.bin/kill-mythfrontend.sh

And place this in in it,

killall mythfrontend.real
 * 1) !/bin/sh

Then make it executable.

chmod +x /var/lib/mythtv/.bin/kill-mythfrontend.sh

Install ALSA
apt-get install alsa-base alsa-utils

On my motherboard HDMI would not output sound. This was resolved as per https://help.ubuntu.com/community/SoundTroubleshootingProcedure#Step_17

I created and inserted

pcm.!default { type plug slave.pcm { type hw card 0 device 3 } }

Rebooted and HDMI audio was working.

Automatic Logon
Install nodm and configure it to logon the mythtv user automatically.

apt-get install nodm

is configured as follows:

NODM_ENABLED=true NODM_USER=mythtv NODM_XINIT=/usr/bin/xinit NODM_FIRST_VT=7 NODM_XSESSION=/etc/X11/Xsession NODM_X_OPTIONS='-nolisten tcp' NODM_MIN_SESSION_TIME=60
 * 1) nodm configuration
 * 1) Set NODM_ENABLED to something different than 'false' to enable nodm
 * 1) User to autologin for
 * 1) xinit program
 * 1) First vt to try when looking for free VTs
 * 1) X session
 * 1) Options for the X server
 * 1) If an X session will run for less than this time in seconds, nodm will wait an
 * 2) increasing bit of time before restarting the session.

Edit, adjust options where necessary.

xrandr --output HDMI2 --off --output HDMI1 --off --output DP2 --off --output DP1 --off --output VGA1 --mode 856x481 --pos 0x0 --rotate normal xsetroot -solid blue xset -dpms s off irexec & sleep 10 exec mythfrontend
 * 1) arandr
 * 1) exec mythtv-setup
 * 2) exec xterm

And

TZ=Australia/Melbourne; export TZ QT_XFT=1; export QT_XFT SSHAGENT=
 * 1) -*- shell-script -*-
 * 2) Sourced as:
 * 3)  /bin/sh
 * 4)    /etc/X11/Xsession
 * 5)      /etc/X11/Xsession.d/40x11-common_xsessionrc
 * 1) Timezone
 * 1) Tell Qt to anti-alias text
 * 1) Don't start ssh-agent