Linux Crumbs
Simbiotic - A Cyberpunk Thriller Novel

Using an Inexpensive Raspberry Pi 2 as a Cheap Frontend to MythTV with Kodi

Summary

NOTE: A newer tutorial is available for Installing LibreELEC 8.2.5 with MythTV PVR Client on a Raspberry Pi 2/3/3B+.

This tutorial describes the hardware required and the steps involved to install the OpenELEC implementation of the Kodi Media Center on a Raspberry Pi 2 computer. At completion of the steps you will be able to watch recordings from your MythTV Backend on a television connected to the Raspberry Pi 2 computer.

These steps were documented using a Raspberry Pi 2 Model B with a MythBackend server configured with Mythbuntu 14.04 which uses MythTV 0.27.

Update 2017-04-13: Add steps to enable subtitle parsing for closed captions.

Update 2016-05-01: Add config.txt overscan_scale=1 parameter as fix to kodi display beyond physical screen.

Update 2016-04-28: Add multiple MPG2 license keys to single line for shared microSD card.

Update 2016-03-18: Add MythTV style skip backward/forward configuration steps.

Contents

Background

There are a number of x86 based computers that can be used as frontends to a MythTV Backend. However since these cost significantly more than a Raspberry Pi 2 (RPi2) computer, I decided to try out an RPi2.

Two commonly used options to access recordings on a MythTV backend are:

  • MythTV Frontend
  • Kodi Media Center

Because Kodi on RPi2 appeared to be further along at time of writing, I chose to test and use Kodi with the PVR.MythTV add-on in this tutorial.

Figure 1: Kodi running on Raspberry Pi 2 in foreground

Kodi on Raspberry Pi 2

For fans of MythTV Frontend, much promising work is being done to port MythTV Frontend to RPi2. See Using an Inexpensive Raspberry Pi 2 as a Cheap Frontend to MythTV with MythFrontend. MythFrontend fans should be aware in Kodi that closed captioning does not work the same, and fast forwarding and rewinding works differently than in the MythTV frontend.

Note 1: The Raspberry Pi 2 has low power requirements (less than 10 watts) and worked well with HDMI to my Samsung 1920x1080 TV, and also with composite 4:3 video. However when I tested with my 1680x1050 monitor the edges of the display were not visible on the screen. I tried the Kodi System -> Video output settings but was unable to address this minor issue. I was finally successful using the overscan_scale=1 RPi2 config.txt parameter.

Note 2: If any of these limitations are deal breakers for you, then you might want to consider spending more to purchase a low end x86 or x86-64 based computer with either integrated Intel HD Graphics or discrete NVidia Graphics.

Hardware Component List

Following is a list of components and their costs in January 2016.

Category Component Cost
Computer Raspberry Pi 2 Model B (900MHz quad-core ARM CPU with 1 GB RAM) 45
Case Vilros Clear Plastic Case 10
Power Supply USB Power Supply (2000 mA) with Micro USB Cable 10
Storage Kingston 8 GB microSDHC Card (Class 10) with SD Adapter 5
Remote Control Rosewill Rosewill RRC-126 MCE Remote Control 30
Grand Total   $ 100

Note that you will also need an ethernet cable, and either an HDMI cable or a 3.5mm to RCA composite audio/video cable.

A. Configure MythTV Backend to Support Remote Frontends

If you have not already done so, follow the steps in Configuring MythTV Backend for Remote MythTV Frontends.

In the above link we make note of the IP Address, Ethernet Address, and MythTV Backend MySQL mythtv user password.

B. Download and Uncompress OpenELEC to microSD Card

Use the following instructions to download and write the OpenELEC image to the microSD card.

  1. Download OpenELEC disk image for RPi2:

    Visit OpenElec Mediacenter - Download

    At time of installation I downloaded OpenELEC-RPi2.arm-6.0.1.img.gz.

  2. Insert the MicroSD card into your computer.

  3. Determine the which /dev/device it is.

    dmesg | tail

    Example output:

    $ dmesg | tail
    [  227.218363] sdhci-pci 0000:01:00.2: PCI INT A -> GSI 16 (level, low) -> IRQ 16
    [  227.218396] sdhci-pci 0000:01:00.2: Refusing to bind to secondary interface.
    [  227.218413] sdhci-pci 0000:01:00.2: PCI INT A disabled
    [  227.218884] jmb38x_ms 0000:01:00.3: enabling device (0000 -> 0002)
    [  227.218906] jmb38x_ms 0000:01:00.3: PCI INT A -> GSI 16 (level, low) -> IRQ 16
    [  227.218931] jmb38x_ms 0000:01:00.3: setting latency timer to 64
    [  227.617315] mmc1: new SDHC card at address 0001
    [  227.617720] mmcblk1: mmc1:0001 SD8GB 7.32 GiB
    [  227.621661]  mmcblk1: p1 p2
    [  228.753036] EXT4-fs (mmcblk1p2): mounted filesystem with ordered data mode. Opts: (null)

    From above output the device is /dev/mmcblk1 (we ignore the partition portion p2).

    WARNING:   It is very important to identify the correct device. Use of the wrong device path can result in loss of data and/or the operating system.

  4. Ensure that the device is unmounted by checking the output from df to see if the device is in use.

    Example output:

    $ df
    Filesystem     1K-blocks    Used Available Use% Mounted on
    /dev/sda1        6734812 5612328    780368  88% /
    udev              499152       4    499148   1% /dev
    none              506428       8    506420   1% /tmp
    tmpfs             101288     844    100444   1% /run
    none                5120       0      5120   0% /run/lock
    none              506428      72    506356   1% /run/shm
    none              506428     572    505856   1% /var/log
    none              506428       0    506428   0% /var/tmp
    /dev/mmcblk0p1  15615056 1183088  14431968   8% /media/mmcard16gb
    /dev/mmcblk1p1    261868  111280    150588  43% /media/0F39-638F
    /dev/mmcblk1p2   7177771   83036   7094735   2% /media/0c0676d8-24f7-43c4-8bed-d19e6ea3a147

    If the device is in use then unmount each mount point.

    Using the example above we unmount two locations from mmcblk1:

    sudo umount /media/0F39-638F
    sudo umount /media/0c0676d8-24f7-43c4-8bed-d19e6ea3a147
  5. Write the image to the Micro SD Card.

    Be sure to use the correctly identified device! In this example the device path is /dev/mmcblk1.

    zcat ~/Downloads/OpenELEC-*.img.gz | sudo dd of=/dev/mmcblk1 bs=4M
    sync
  6. Remove the Micro SD Card.

C. Insert SD Card and Power on Raspberry Pi

At first power up the image will be resized to use the entire Micro SD card, and then the RPi2 will reboot.

  1. At Welcome to OpenELEC screen choose Next.

  2. At Hostname prompt change or leave name OPenELEC and choose Next.

  3. At Networking screen with Wired network listed choose Next.

  4. At Sharing and Remote Access screen under Configure Services enable SSH and disable Samba. Choose Next.

    Enable Samba if you wish to access Windows network shares.

    Note that username is root and pasword is openelec.

  5. At Thank you screen choose Next.

D. Enable MPEG-2 Hardware Video Decoding

If you have not already done so, purchase an MPEG-2 license key from the Raspberry Pi Store. Cost is ~2 British Pounds. The license key will be sent to the email address you provide (can take up to 72 hours).

Note that a VC-1 license key is also available, but it is not needed to view North American Over-The-Air content which is in MPEG-2 format.

  1. Lookup the IP Address in Kodi for the Raspberry Pi.

    Navigate to System -> System info.

    Make note of the IP address.

    In this example we will use 192.168.1.67.

  2. Open a terminal window on a different GNU/Linux computer and make a secure shell connection to the IP address of your Raspberry Pi.

    Be sure to use the IP address for your RPi2 on your network.

    ssh root@192.168.1.67

    The password is openelec all lowercase.

  3. In the SSH session mount the /flash directory with read and write privileges.

    mount -o remount,rw /flash
  4. Edit the /flash/config.txt file to add the MPEG-2 license key.

    nano /flash/config.txt

    Locate the decode_MPG2 line, remove the # and space at the front, and add your MPEG-2 license key.

    decode_MPG2=0x8ff5a5c7

    If you wish to share a microSD card image with multiple RPi2s then you can string together a maximum of 8 licenses. For example:

    decode_MPG2=0x8ff5a5c7,0xd4cb22af,0xe05b40bc,0xa54335b8
  5. Potential fix for overscan issue [Optional]

    If the edges of the kodi display are not visible on the physical screen, then try uncommenting the overscan_scale=1 config.txt parameter.

    overscan_scale=1
  6. Save and exit the editor with Ctrl+X.

  7. Return the /flash directory back to read only privileges.

    mount -o remount,ro /flash
  8. Reboot the Raspberry Pi. This will close the SSH session.

    reboot

If you wish you can check if the MPEG-2 decoder is enabled via an SSH connection with the following command:

vcgencmd codec_enabled MPG2

The MPEG-2 hardware video decoder should now be enabled.

E. Enable 3.5mm Headphone Jack Audio [Optional]

This step is only needed if you are connecting speakers or a composite audio/video cable to the 3.5mm headphone jack on the Raspberry Pi.

See also Kodi - MythTV PVR.

  1. Navigate right to System.

  2. Navigate down to Settings and press Enter.

  3. Navigate down to System and press Enter.

  4. Navigate down to Audio output and press right arrow.

  5. On Audio output device press Enter.

  6. Navigate down to HDMI and Analogue and press Enter.

  7. Press Escape twice to back out to main screen.

F. Set Time Zone Details

  1. Navigate right to System.

  2. Navigate down to Settings and press Enter.

  3. Navigate to Appearance and press Enter.

  4. Navigate to International and press right arrow.

    Set the following:

    Region:            # e.g., Canada
    ...
    Timezone country   # e.g., Canada
    Timezone           # e.g., America/Edmonton
  5. Press Escape two times to back out to main screen.

G. Install PVR.MythTV Add-on

  1. Navigate right to System.

  2. Navigate down to Settings and press Enter.

  3. Navigate down to Add-ons and press Enter.

    If First run help... window pops up, read the message then press OK to dismiss.

  4. Navigate down to Search, type in pvr and choose Done.

  5. Navigate down to PVR clients - MythTV PVR Client and press Enter.

  6. Navigate to Install and press Enter.

  7. On PVR clients - MythTV PVR Client press Enter.

  8. Navigate up to Configure and press Enter.

    Using your own MythTV Backend values for IP Address, Security Pin and Ethernet Address, set the following:

    MythTV Backend Hostname or IP           192.168.1.55
    ...
    MythTV Security Pin for API services    0000
    MythTV Backend Ethernet address (WOL)   00:0b:0e:0f:00:ed
    ...
    Conflict Handling       Prefer recording and stop Live TV

    Note be sure to use the same security pin as you set in the MythTV Backend.

  9. Navigate up to General tab.

  10. Navigate right to Advanced tab.

    Set the following:

     Enable commercial skips (EDL)           Dialog
  11. Navigate down to OK button and press Enter.

  12. Press Escape four times to back out to main screen.

H. Enable TV Menu on Main Screen

  1. Navigate right to System.

  2. Navigate down to Settings and press Enter.

  3. Navigate down to TV and press Enter.

  4. Press right arrow to highlight Enabled and press Enter.

  5. Press Escape twice to back out to main screen.

Note that after a short period of time your MythTV Backend should boot up. Next in Kodi a TV menu item should appear on the main screen between PICTURES and VIDEOS.

I. Enable Subtitle Parsing for Closed Captions [Optional]

  1. Navigate right to System.

  2. Navigate down to Settings and press Enter.

  3. Navigate down to Video and press Enter.

  4. Navigate down to Subtitles.

  5. Press right arrow to enter Videos - Settings area.

  6. Navigate down to Enable parsing for closed captions and press Enter to enable.

  7. Press Escape twice to back out to main screen.

J. Configure MythTV Style Skip Backward/Forward [Optional]

In the default Kodi configuration, skip steps progressively increase in value as the arrow key is pressed, and there is a 750ms delay before performing the skip action. The default skip steps are:

-30 min, -10 min, -5 min, -3 min, -60 sec, -30 sec, -10 sec, starts here, 10 sec, 30 sec, 60 sec, 3 min, 5 min, 10 min, 30 min.

This can be disconcerting to MythTV Mythfrontend users. The Mythfrontend default is -5s back and +30s forward.

To make the skip backward/forward experience closer (-10s/+30s) to Mythfrontend the steps are:

  1. Navigate right to System.

  2. Navigate down to Settings and press Enter.

  3. Navigate down to Video and press Enter.

  4. Navigate down to Settings level and press Enter.

    This will cycle the Settings level from Standard to Advanced.

  5. Navigate up to Playback and press Right Arrow.

  6. Navigate down to Skip steps and press Enter.

  7. Navigate up/down to each value that is not (-10s/+30s) and press Enter.

    The text colour should change from yellow to grey. This indicates the value will not be used in skipping.

    Check to ensure the -10 sec and 30 sec entries are yellow.

  8. Navigate right to OK and press Enter.

  9. Navigate down to Skip delay and press Enter 3 times.

    This will reduce the skip delay from 750 ms to None.

  10. Press Escape twice to back out to main screen.

  11. Optionally, return Settings level back to Standard.

    Note that we changed the Settings level from Standard to Advanced in step 4 above.

K. Watch MythTV Recordings

To watch MythTV recordings:

  1. Navigate left/right to TV.

  2. Navigate down to Recordings and press Enter.

  3. Navigate to the show you wish to watch and press Enter.

Note that you can bring up the playback menu with the M key or big green Start button on an MCE remote control.

Figure 2: Kodi displaying MythTV Recordings

Kodi displaying MythTV Recordings

L. Power Off Raspberry Pi

To power off your RPi2 use the following steps.

  1. Navigate down to power button icon in the lower left corner of the screen and press Enter.

  2. Navigate down to Power off system and press Enter.

Note 1: that reboot is available in a similar manner.

Note 2: If RPi2 is powered up and you are not actively watching recordings in Kodi, then Kodi will drop it's connection to the MythTV Backend and permit the Backend to power itself down (if so configured).

Conclusion

Congratulations. You should now have an inexpensive way to watch your MythTV recordings on a Raspberry Pi 2 computer using a Kodi remote frontend.

References

While researching how to use a Raspberry Pi 2 computer as a frontend to MythTV I found the following references useful:

Future Articles

In a future article, I plan to cover the following topic:

The Medusa Deception novel - free first in series
News   Documentation     Copyright (c) 2013-2024 Curtis Gedak

Get GParted at SourceForge.net. Fast, secure and Free
	Open Source software downloads Valid HTML 4.01! Correct CSS!