MythTV

What is MythTV?
MythTV is a digital video recorder for watching and recording television. MythTV also contains plugins for viewing other home media, similar to what XBMC Media Center provides. MythTV is like a free open source alternative to Tivo and Windows Media Center.

Some of MythTV's features include:
 * Watch and record analog and/or digital TV, including HDTV.
 * Pause, skip, and rewind live TV shows.
 * Completely automatic commercial detection/skipping, with manual correction via an intuitive cutlist editor.
 * Intelligently schedules recordings to avoid conflicts.
 * Parental controls to keep your kids out of the good shows.
 * Schedule and administer many functions remotely via a web browser.
 * Flexible client/server architecture allows multiple frontend client machines to access content served by one or more backend servers (although the most common installation consists of a single computer running both the client and server together).

This wiki page doesn't contain any information about how to install, set up or configure MythTV. If you need further information about how best to do this, Mythbuntu is a good place to start. Mythbuntu is a community supported add-on for Ubuntu focused upon setting up a standalone MythTV based PVR system.

Integrated support via MythTV PVR add-on
Integrated MythTV support in XBMC is based on the PVR support that has now been merged in mainline XBMC (as of October 2012). More information can be found on PVR wiki page. There is a currently a MythTV client add-on along with support of other PVR backends through client add-ons for those backends.

Old-style myth:// protocol access
That said, the current support allows you to:
 * Navigate All Recordings, Movies and TV Shows separately - standard XBMC navigation grouped in a sensible way.
 * Playback recordings with automatic commercial skip - automatic commercial skip during playback that works as you expect with no fuss. Advanced options to help merge poorly flagged commercial breaks as well.
 * Add recorded Movies to the XBMC library - integrate your recorded Movies in MythTV with all your other movies so you can see them all in one place. Standard XBMC functionality with scrapers supported.
 * Watch and pause Live TV with direct channel navigation - change up or down channel with a single button press, or choose a channel number using the remote keypad.
 * Look at electronic program guide (EPG) - to see what is coming up on each channel
 * Delete recorded programs after watching - one place to watch and delete recorded programs

This limited source support is limited to playback of MythTV recordings. You need to schedule recordings via the new MythTV add-on or using mythfrontend or mythweb.

Versions of MythTV up to and including 0.24 are supported in the 11.0 release of XBMC Media Center (Eden). Version 0.25 of MythTV is currently only supported in trunk (see the "libcmyth" section of the MythTV PVR Addon article for details).

The functionality described on this page is for the 9.11 Camelot release of XBMC.

Setup
XBMC communicates with mythbackend using the Myth Protocol and MySQL database queries to the mythconverg database. This requires that the MythTV configuration is checked to ensure XBMC will be able to communicate with MythTV, which depends on whether XBMC is running on the same machine.

If you don't intend on using the Guide then the MySQL related configuration can be omitted. Access to the mythconverg MySQL database is only used to view the Guide.

Setup in MythTV
If XBMC Media Center and the MythTV backend will NOT be running on the same machine:


 * Check that the IP Address configured in MythTV can be accessed by the XBMC machine. The default IP Address for an installation of MythTV is 127.0.0.1 and must be changed so playback will work
 * 1) Run mythtv-setup
 * 2) Select General
 * 3) Check that the IP Address in Local Backend section is NOT set to localhost or 127.0.0.1. The IP Address must be resolvable from the XBMC Media Center machine, e.g. 192.168.1.3.
 * Check that the MySQL database being used by MythTV has been configured to allow external connections.
 * Generally this means ensuring that the bind-address is not set to localhost or 127.0.0.1 in /etc/mysql/mysql.cnf or one of the *.cnf files in /etc/mysql/conf.d/.

To ensure XBMC has proper access to the MythTV mysql database, run the following commands on the mysql server. Replace PASSWORD or xbmc with whatever you prefer, but keep the single quotes for syntax.

(enter mysql root password when prompted)

If you just want to restrict by IP subnet (in this example, the 192.168.1.x network):

It is very important that the IP Address is set correctly using mythtv-setup. The Myth Protocol used by XBMC Media Center uses the IP Address configured in the Myth TV backend to determine where to stream the recordings from. So, even if the IP address in the myth:// URL points correctly to the MythTV backend, there can still be playback problems if the correct IP Address isn't also set correctly using mythtv-setup.

Setup in XBMC
To communicate with a MythTV backend, add a new Source from the Videos section. The source should have a URL that looks like: myth://username:password@i.p.address This URL needs to be specified manually as many skins don't support the ability to configure a MythTV source.

username and password are the credentials for a user that has access to the MySQL mythconverg database on the MythTV backend. The username and password supplied in the URL are used to obtain EPG information from the MythTV database when using the Guide. If the username and password are not supplied a default of mythtv is used for both. The username and password are not used when watching recordings.

i.p.address is the IP address of the MythTV master server. A hostname can also be used, but it must be resolvable to an IP address on the XBMC Media Center machine.

When you select the newly added MythTV media source five folders will be listed:
 * All Recordings - to watch anything that has been recorded all in one folder.
 * Guide - to view the EPG for a channel
 * Live Channels - to display what is currently being aired
 * Movies - to list the movies that have been recorded
 * TV Shows - to list each series of TV shows that have been recorded



All Recordings
After choosing All Recordings a list of all recorded programs is presented. Standard XBMC functionality can be used to sort by date to see the most recent recordings, or sort by name to get all the shows from a given series grouped together.



Movies
After choosing Movies a list of all the recorded movies is shown.



If not all of the movies are shown, e.g. some still display in the TV Shows section, the Electronic Program Guide (EPG) being used by MythTV might not be very accurate. The EPG describes which programs are Movies and which are TV Shows. Use the  advanced setting to help with this problem. 85 minutes seems to work well.

TV Shows
After choosing TV Shows a list of all the recorded TV shows grouped by title is shown. This makes it easy to see what TV series or one-off programs have been recorded.

TODO: Update image.

After choosing a title, the list of recorded programs with that title is shown.

TODO: Update image.

Watching Live TV
After choosing Live Channels a listing of the channels used by MythTV is displayed.

When a channel is chosen, the currently playing TV show on that channel is shown.

It is possible to pause Live TV, but it is not possible to skip. To move up or down a channel when playing Live TV press the PageUp or PageDown button. Note that channel changes can take some time depending on the tuner hardware and configuration being used by MythTV.

Viewing the Electronic Program Guide (EPG)
After choosing Guide a listing of channels used by MythTV is shown.



When a channel is chosen, the listing of upcoming programs on that channel is displayed.



There is a future project to be able to schedule programs to record from the EPG similar to the functionality available in the MythTV frontend.

Adding Recorded Movies to the Video Library
Recorded movies can be added to the XBMC Video Library by setting the Content Type on the Movies directory and then choosing the appropriate Movie scraper.

Once the recorded Movies have been scanned to the Library, you can see and play them via the XBMC Movie Library.

NOTE: be sure to only set the content type for the Movies folder. XBMC doesn't understand how to add anything other than movies. If you choose a folder containing recorded TV Shows to be added to the library you may end up with all sorts of strange files in your XBMC library.

Automatic Commercial Skipping
Commercial breaks that have been flagged in MythTV are automatically skipped as of the 9.11 release (note that the option to turn EDL support on/off has now been removed). Prior to 9.11, automatic commercial skipping can be enabled by turning on Edit Decision List (EDL) support in XBMC Media Center through Settings -> Video -> Player -> Enable edit decision lists.

Each commercial break is only skipped once so it's possible to go back into any incorrectly flagged commercial break. Scene markers are also put in at the beginning and end of the flagged commercial breaks to further support navigation.

For more information about the configuration that is possible for commercial skipping, see the Edit Decision Lists wiki page.

Deleting Recorded Programs
The ability to delete recorded programs can be enabled through Settings -> Appearance -> View Options -> Allow file renaming and deletion.

Known Problems

 * Need to delete a recording twice for it to be removed if using a MythTV 0.20 backend. Deleting works as expected using a MythTV 0.21 backend.
 * Channel changes can take some time when using LiveTV.

Recordings Don't Play
For the myth:// protocol to play recordings, XBMC must be able to access the IP Address configured in the MythTV backend using mythtv-setup. This is necessary because of the way the Myth Protocol works. The Myth API gets the IP Address configured in the MythTV backend and uses that to stream recordings.

If a hostname was used in the IP Address configuration for the MythTV Local Backend, either the DNS server on the network needs to be able to resolve the hostname to an IP address, or a static hostname to IP address entry is needed on the XBMC machine. A static IP address mapping can be set in the /etc/hosts file in Linux or Mac OSX, or in the AdvancedSettings.xml file for the original XBox.

Even if you haven't used a hostname, it may be worth adding an /etc/hosts file entry, as it appears that the backend returns a hostname anyway sometimes (see ).

Double check that the Local Backend IP Address configured in the MythTV backend is not set to localhost or 127.0.0.1 if the MythTV backend is running on a different machine to XBMC Media Center.

Guide Doesn't Display Anything
Check that the username and password supplied in the myth:// URL are a username and password that have access to the mythconverg MySQL database. The guide information is obtained directly from the database.

If a username and password have not been supplied in the myth:// URL then the default of 'mythtv' will be used for both.

See Setup in XBMC for more information.

Live TV Doesn't Play
The libcmyth library used for to connect to MythTV from XBMC only enumerates the first 16 tuner devices when looking for available tuners. Trac - CMyth only enumerates 17 tuners

Depending on what was done when the MythTV backend was set up, it's possible that some Tuner ID's are > 17 in the mythconverg database (especially if tuners were added and deleted several times, or if multiplexing is being used for digital terrestrial tuners).

If this is the case, you may be able to see the Guide and all the stations displayed in XBMC, but XBMC may not be able to select a tuner for live TV playback.

This can be resolved by removing all the tuners through mythtv-setup (so they start at 0 when re-added), and then re-adding them, or reducing the number of multiplexed virtual tuners that are created for each physical digital terrestrial tuner.

If a only a green screen displayed but the audio is working fine. Use mythtv's frontend to change the encoder to mpeg4. The settings can be found in "Utilites/Setup- Setup - TV Settings - Recording Profiles - Software Encoders. Select Live TV, and change it's encoder from rtjpeg to mpeg4.

Audio Plays Out of Sync
If CPU utilization is close to 100% on any of the CPU cores then there could be audio sync problems.

Depending on the video card and driver being used, there could be significant CPU utilized when playing H264 video content. The advanced setting can be used to reduce the CPU utilization by reducing the quality of the output H264 video. Try setting it to 48.

History of MythTV support in XBMC
MythTV support in XBMC has been available since ~2004. It started life as a Python script for the original XBox that had functionality added by willing developers over the following years. Eventually the script moved to the current home at Sourceforge, and is now called xbmcmythtv. In late 2008 another script based solution arrived called MythBox.

In 2007 support for communicating with the MythTV backend was added directly to XBMC via a Source using the myth:// protocol. This project uses the cmyth library, which was built to use the network based Myth Protocol supported by MythTV.

In 2009, the Google Summer of Code - Unified PVR Frontend project was launched to provide added functionality to the existing myth:// protocol support (here is a historical MythTV frontend client built into XBMC forum thread).

In early 2011 the initial work from the GSoC for the unified PVR API was folded into a branch of xbmc, which was eventually pushed back to mainline XBMC in October 2012 and is scheduled to be released in Frodo/12.x: see PVR. This support will include a MythTV client.

myth:// Source
The myth:// source was released in early 2007. This project uses the network based Myth Protocol to communicate with the MythTV backend. It also accesses the MySQL database directly to get Guide information.

Although the myth:// source doesn't support all the functionality that the xbmcmythtv script supported, it is possible to play recordings, which is all many XBMC frontend systems need to support.

The native MythTV frontend client needs to be used to schedule recordings.

MythTV Python Scripts for XBMC
MythTV Python Scripts for XBMC that provide a python coded GUI for MythTV interface.

MythBox Script (Linux/Mac/Windows)
MythBox was released in late 2008 and is a XBMC script for MythTV that supports the most common frontend use cases:
 * Watching recordings with commercial skipping
 * Watching Live TV
 * Creating and editing recording schedules
 * Showing upcoming recordings
 * TV Guide
 * Tuner and job status
 * Fanart and episode meta data from tvdb.com, tvrage.com, themoviedb.org, imdb.com, and Google image search.
 * MythTV Backends: 0.21, 0.22, 0.23, 0.23.1

Myth2XBMC Script (Xbox)
Myth2XBMC heavily based on the original xbmcmythtv script and is only tested on the Xbox.

xbmcmythtv Script (Xbox)
Support for MythTV in XBMC started with this xbmcmythtv python script for XBMC on the Xbox. This project communicated with the MythTV mythconverg MySQL database to get information, and played recordings via a Samba share on the MythTV backend.

The last official release of the Python script was in May 2007 and supported version 0.20 of MythTV and protocol 34. Various unofficial releases were made available by some of the developers of xbmcmythtv, but appears to no longer be supported on an ongoing basis.

MythicalLibrarian and MythSExx
MythicalLibrarian and MythSExx are bash scripts which can be run on the MythTV server to create symlinks to the recorded files. The symlinks use the supported XBMC naming conventions so the standard filesystem scrapers can be used to scan recorded MythTV content into the XBMC Movie and TV Show libraries. They also generate the required EDL files to support commercial skip during playback.

MythicalLibrarian handles both TV episodes and Movies whereas MythSExx only handles TV episodes.