Sunday, July 8, 2012

XBMC PVR How-to : Enhance your XBMC Media Center Experience with Live TV


*** Updated August 2012:  ***
- Debian/Ubuntu package 3.0
************************

The Goal:


Configuring Live TV on XBMC is a great way to complete your Media Center Experience, that's called "PVR" and will allow you to watch real Live TV on your XBMC Box!

For now, XBMC does not take in charge TV Backend functionality, it will only act as a frontend to a backend software that will manage the TV Tuner.

Please take a look on my Full XBMC post to help you installing and configuring XBMC:
xbmc-install-and-config-howto-for-linux

What you need:


  • A working XBMC installation embedded with PVR (if you used my post, PVR is part of XBMC compilation)
  • A TV Tuner: USB Tv tuner, PCI, HD HomeRun... I used an "Elgato Eye TV Diversity"
  • A Backend software to manage TV flow, i recommend you to use tvheadend

Step 1: Install the TV Tuner and check configuration

First, plug the TV Tuner to your Linux Box and check kernel log, if everything are right you should get this kind of message:

[30943.681707] dvb-usb: found a 'Elgato EyeTV Diversity' in cold state, will try to load a firmware
[30943.690351] dvb-usb: downloading firmware from file 'dvb-usb-dib0700-1.20.fw'
[30943.929564] dib0700: firmware started successfully.
[30944.432325] dvb-usb: found a 'Elgato EyeTV Diversity' in warm state.
[30944.432550] dvb-usb: will pass the complete MPEG2 transport stream to the software demuxer.
[30944.432693] DVB: registering new adapter (Elgato EyeTV Diversity)
[30944.700631] DVB: registering adapter 0 frontend 0 (DiBcom 7000PC)...
[30944.936519] DiB0070: successfully identified
[30944.936530] dvb-usb: will pass the complete MPEG2 transport stream to the software demuxer.
[30944.936749] DVB: registering new adapter (Elgato EyeTV Diversity)
[30945.106998] DVB: registering adapter 1 frontend 0 (DiBcom 7000PC)...
[30945.348653] DiB0070: successfully identified
[30945.348689] Registered IR keymap rc-dib0700-nec
[30945.349030] input: IR-receiver inside an USB DVB receiver as /devices/pci0000:00/0000:00:12.2/usb1/1-1/rc/rc1/input8
[30945.349535] rc1: IR-receiver inside an USB DVB receiver as /devices/pci0000:00/0000:00:12.2/usb1/1-1/rc/rc1
[30945.349911] dvb-usb: schedule remote query interval to 50 msecs.
[30945.349924] dvb-usb: Elgato EyeTV Diversity successfully initialized and connected.

You can see here that the kernel successfully identified the USB TV Tuner ind installed appropriated driver, i recommend you to double check Linux compatibility before buying your TV Tuner.

Step 2: Install tvheadend as the Backend for Live TV


Download and install the backend, we will use "tvheadend".
In my opinion, this a very good TV Backend that comes with a nice web interface.

So we will use the last version which is still running underdevelopment to get all tvheadend functionalities. Tvheadend is small and does not have much dependencies, so compilation will be easy.

(You can also install the version provided by your package system, on Debian derived systems: sudo apt-get install tvheadend)

Install tvheadend:

Source:
$ wget https://github.com/downloads/tvheadend/tvheadend/tvheadend_3.0_amd64.deb
$ sudo dpkg -i tvheadend_3.0_amd64.deb

Answer to installation questions, admin username and password.

After installation, you should find the process up (ps -ef - grep tvheadend) and an init script in "/etc/init.d/tvheadend".

Configuration files will be located in "/home/hts/.hts" and "/home/hts/.xmltv".

Step 3: Configure tvheadend

Connect to tvheadend web interface using your localhost URL (change localhost by appropriated backend IP or Hostname if required) :



Click on "Configuration" then "TVAdapters" and choose your adapter:


Scan for channels:

Select "Add DVB Networks By Location" and add your country and/or city, in my case i choosed defaults and my country to ensure i would get all channels.

Immediately after that, tvheadend will start to scan for channels.
Be patient, this will required a long time to end.
In "General" screen (middle right page), you will see the scan result and running "services". (which mean channels found by the adapter)

Take a look on "Multiplexes", if your antenna and your TV Tuner works fine you should see something like that:



When the scan process will be over, you will see channels in "Services":



Wait for the full process to end, then in "General", click "Map DB services to channels".

Additionally, edit others services and map them manually to channels.

Edit channels to end configuration:

Go in "Channels" panel and edit any channel to set channel number and so on.

If you want channels logo to appear in XBMC (and you will because that's pretty), we will have to use an apache instance for it, so create an apache instance, download channels logo (use google image) and save them to the root folder of the apache instance.

In a few words:

  • Edit new Apache service (don't forget to add the port if new in ports.conf) and tune to your needs:

<VirtualHost *:10000>
        ServerAdmin webmaster@localhost
        ServerName      xxxxxxxxxxxxxxx
        DocumentRoot /media/xbmc/logo
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
        LogLevel notice
        CustomLog /var/log/apache2/access.log combined
        ErrorLog /var/log/apache2/error.log
        ServerSignature On
</VirtualHost>


  • Restart apache and add channels logo pictures to the apache root folder
  • Ensure it works by get one logo as for an example with your web browser
  • In tvheadend "Channels" panel, configure the logo, configuration example:


You're done with tvheadend configuration, i recommend you to simply add it to your session automatic run. (if your are using a desktop session)

You may also simply write an initrc script shell to start and stop it as a service.

Finally configure the XML Grabber:

On Debian derived systems, install xmltv:

sudo apt-get install xmltv

Go to XML TV panel, select your country and follow instruction.


Step 4: Configure XBMC


Go back in XBMC and activate the PVR addon for tvheadend frontend (system>settings>add-ons>activated addons):


If you don't run tvheadend on same host, or if you wanted to set an admin user in tvheadend, configure it.

If you haven't changed anything, default configuration is fine and will work.



Save, and Go to "Live TV", XBMC will automatically get channels configuration, final result:




Everything works ^^ Take a look on time-shift function or record, some of them are still under improvement and may not be as stable as it should but work.

As a conclusion, your XBMC Media Center is now really complete, enjoy :-)

FAQ and issues:

  • Failing to start tvheadend with message of segmentation fault

I experienced this several time for unknown reasons after reboots, it was always caused by some king o epg file corruption.

I you experience this, just remove the file and restart:


rm ~/.hts/tvheadend/epgdb