Ubuntu 12.04 MythTV

From Bit Binary Wiki
Jump to: navigation, search

DOCUMENT IN PROGRESS

Contents

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.

Note: If you run a VM don'se use the vm kernel as it does now support tv tuner cards.

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 <<EOF
APT "";
APT::Install-Recommends "false";
EOF
apt-get update
apt-get dist-upgrade

Reboot and remove old kernels and headers if necessary.

apt-get install deborphan debfoster apt-file python-apt lsb-release file iso-codes dialog cruft apt-rdepends reportbug
cat > /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
update-alternatives --config editor
There are 3 choices for the alternative editor (providing /usr/bin/editor).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /bin/nano            40        auto mode
  1            /bin/ed             -100       manual mode
  2            /bin/nano            40        manual mode
  3            /usr/bin/vim.basic   30        manual mode
  4            /usr/bin/vim.tiny    10        manual mode

Press enter to keep the current choice[*], or type selection number: 3
Note: Optionally remove ed and nano.

I don't use resolvconf

apt-get autoremove --purge resolvconf

Edit /etc/default/grub and add the quiet option

GRUB_CMDLINE_LINUX_DEFAULT="quiet"
update-grub
reboot

Tidy up /etc/network/interfaces e.g.

# The primary network interface
auto eth0
iface eth0 inet static
    address 10.39.41.8
    netmask 255.255.255.0
    gateway 10.39.41.254

And check /etc/resolv.conf 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 /etc/ntp.conf, 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 /etc/skel/.bash_aliases, add the following alias.

alias invoke-rc.d='service'             # ubuntu uses service
cp -R /etc/skel/. ~/

MythTV Backend Installation

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:                                                                          │
│                                                                                                                  │
│ ________________________________________________________________________________________________________________ │
│                                                                                                                  │
│                                                      <Ok>                                                        │
│                                                                                                                  │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

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 /etc/mysql/conf.d/my-huge.cnf 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/

#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.

#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?                                                                                          │
│                                                                                                                           │
│                                    <Yes>                                       <No>                                       │
│                                                                                                                           │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

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

/var/lib/mythtv/.mythtv/config.xml and /var/lib/mythtv/.mythtv/mysql.txt are symlinks to these files.

Warning: There is a bug that affects mythbackend starting properly http://code.mythtv.org/trac/ticket/11030

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?                                                                            │
│                                                                                                                             │
│                                     <Yes>                                        <No>                                       │
│                                                                                                                             │
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌────────────────────────────────────────────────────┤ 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?                                                                     │
│                                                                                                                                │
│                                      <Yes>                                         <No>                                        │
│                                                                                                                                │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

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

The imdb scraper needs to be added to http://<addressofmythweb>/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)                      ↓                   │ 
│                      ...                                                                                      │ 
│                                                                                                               │ 
│                                                                                                               │ 
│                                                    <Ok>                                                       │ 
│                                                                                                               │ 
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌──────────────────────────────────────────────┤ 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                                                                                        │ 
│                     ...                                                                                         │ 
│                                                                                                                 │ 
│                                                                                                                 │ 
│                                                     <Ok>                                                        │ 
│                                                                                                                 │ 
└─────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

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
#This configuration has been automatically generated via
#the Ubuntu LIRC package maintainer scripts.
#
#It includes the default configuration for the remote and/or
#transmitter that you have selected during package installation.
#
#Feel free to add any custom remotes to the configuration
#via additional include directives or below the existing
#Ubuntu include directives from your selected remote and/or
#transmitter.

#Configuration for the Windows Media Center Transceivers/Remotes (all) remote:
#include "/usr/share/lirc/remotes/mceusb/lircd.conf.mceusb"
include "/usr/share/lirc/remotes/devinput/lircd.conf.devinput"

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,

#!/bin/sh

killall mythfrontend.real

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 /etc/asound.conf 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

/etc/default/nodm is configured as follows:

# nodm configuration

# Set NODM_ENABLED to something different than 'false' to enable nodm
NODM_ENABLED=true

# User to autologin for
NODM_USER=mythtv

# xinit program
NODM_XINIT=/usr/bin/xinit

# First vt to try when looking for free VTs
NODM_FIRST_VT=7

# X session
NODM_XSESSION=/etc/X11/Xsession

# Options for the X server
NODM_X_OPTIONS='-nolisten tcp'

# If an X session will run for less than this time in seconds, nodm will wait an
# increasing bit of time before restarting the session.
NODM_MIN_SESSION_TIME=60

Edit ~/.xsession, 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 &
#arandr
sleep 10
exec mythfrontend
#exec mythtv-setup
#exec xterm

And ~/.xsessionrc

# -*- shell-script -*-
# Sourced as:
#  /bin/sh
#    /etc/X11/Xsession
#      /etc/X11/Xsession.d/40x11-common_xsessionrc

# Timezone
TZ=Australia/Melbourne; export TZ

# Tell Qt to anti-alias text
QT_XFT=1; export QT_XFT

# Don't start ssh-agent
SSHAGENT=
Personal tools