Monday, September 2, 2019

Using a TiVo Roamio Remote with MythTV on Ubuntu

Instructions are shown below for setting up a TiVo remote to control an HTPC that has MythTV installed.  An HTPC is a computer that is connected to a home theater system or simply a single TV.  MythTV is media center software for an HTPC that is mainly used to watch and record TV content.  Ubuntu is one of the most popular Linux operating systems.  I used a TiVo Roamio remote, but this can be done with other TiVo model infrared (IR) remotes with some possible minor differences.

Hardware


A TiVo remote can be purchased here on Amazon.  Alternatively, one can be purchased used together with a TiVo from eBay or various other sources for very little money.  An Inteset USB external IR receiver works great with a TiVo remote, and one can be purchased here on Amazon.

Software Setup


The following steps can be used to set the TiVo remote to work with a specific TV and optimize the remote for use with MythTV:
  1. Open a web browser and visit TiVo's instructions here to make the remote control the TV power, volume, mute and input directly.
  2. Open a terminal and type "sudo apt install ir-keytable" without the quotes.
  3. Copy /lib/udev/rc_keymaps/rc6_mce to a folder in your home folder just to make a backup copy of the original.
  4. Make another copy of rc6_mce in your home folder.
  5. Open the rc6_mce file in your home folder in a text editor, erase all content, and replace the content as shown below.
  6. Open a terminal, and enter "sudo cp ./rc6_mce /lib/udev/rc_keymaps/rc6_mce" without the quotes.
  7. Open a web browser, and visit http://BACKEND.IP.ADDRESS.HERE/mythweb/settings/mythtv/keys
  8. Under Jumpoints Editor, enter "=" for Main Menu and ";" for Live TV.
  9. Under Keybinding Editor, delete "F5" for Menu Blue and MenuEPG, enter "F5" for Add bookmark, delete "B" for Toggle active PIP/PBP window, and enter B for Jump to the start of the recording.
Replacement entries in new rc6_mce file:

# table tivo, type: NEC
0x3085d028 KEY_1
0x3085d029 KEY_2
0x3085d02a KEY_3
0x3085d02b KEY_4
0x3085d02c KEY_5
0x3085d02d KEY_6
0x3085d02e KEY_7
0x3085d02f KEY_8
0x0085302f KEY_8
0x3085c030 KEY_9
0x3085e014 KEY_UP
0x3085e016 KEY_DOWN
0x3085e017 KEY_LEFT
0x3085e015 KEY_RIGHT
0x3085c031 KEY_0
0x3085c033 KEY_ENTER
0x3085c032 KEY_ESC
0x3085f00d KEY_EQUAL
0x3085c036 KEY_S
0x3085e019 KEY_ENTER
0x3085d024 KEY_DOT
0x3085e011 KEY_SEMICOLON
0x3085d023 KEY_P
0x3085d021 KEY_P
0x3085e01e KEY_UP
0x3085e01f KEY_DOWN
0x0085301f KEY_DOWN
0x3085708d KEY_ESC
0x3085d022 KEY_COMMA
0x3085d020 KEY_R
0x3085e013 KEY_I
0x3085b044 KEY_W
0x3085e018 KEY_D
0x3085e01a KEY_F5
0x3085d025 KEY_K
0x3085d026 KEY_PAGEUP
0x3085d027 KEY_PAGEDOWN
0x30859060 KEY_M
0x30859061 KEY_B
0x30859062 KEY_SLASH
0x30859063 KEY_H

Key Descriptions

Key descriptions while watching live TV, watching a recording and global as applicable:
  1. Jump to main menu (=)
  2. Jump to live TV (;)
  3. Directly control the TV power
  4. Show information (I)
  5. Directly control the TV input (also known as source)
  6. Switch between preconfigured zoom modes (W)
  7. Exit (Esc)
  8. Select (Enter)
  9. Navigate (arrow keys)
  10. Change channel (arrow keys up and down)
  11. Directly control the TV volume
  12. Show EPG (S)
  13. Directly mute and unmute the TV
  14. Record (R)
  15. Delete (D)
  16. Add bookmark (F5)
  17. Play (P)
  18. Sticky fast forward or skip forward one second while paused (.)
  19. Sticky rewind or jump back one second while paused (,)
  20. Pause (P)
  21. Jump to bookmark (K)
  22. Jump ahead (Page Down)
  23. Jump back (Page Up)
  24. Switch to the previous channel (H)
  25. Show pop-up menu (M)
  26. Cycle through channel groups and all channels in the program guide (/)
  27. Jump to the start of the recording (B)
  28. Select (Enter)
  29. Exit (Esc)

Friday, July 26, 2019

MythTV v30 Example Installation Steps with Ubuntu 18.04

I used the steps shown below to install MythTV v30 on Ubuntu 18.04.  MythTV is open source media center software for a home theater or television computer and is often used to watch and record TV content.  Ubuntu is one of the most popular Linux operating system distributions.  The steps below are based on the installation instructions found on the MythTV wiki and this blog post.

The MythTV frontend and backend was installed so the system can be used to watch and record TV content, and the system can be used by other MythTV frontends in my home.  An Asus H110T was used with Intel graphics.  A single hard drive was used for the operating system and all other files.  Also, an HDHomeRun Prime was used with Comcast Xfinity.  The guide data source is from SiliconDust and TVMaze, and this differs from the more commonly used Schedules Direct source.
  1. Install Ubuntu using the minimal install option.  The installation iso file and instructions for installing Ubuntu Desktop LTS can be found at https://ubuntu.com.
  2. Boot into Ubuntu and start Software Updater.
  3. Install all available updates.
  4. Reboot, and repeat steps two and three until Software Updater indicates there are no more updates.
  5. Set a static IP address:
    • Left click on the network icon on the top-right of the screen, left click on the right arrow next to the network connection, and left click Wired Settings.
    • Left click the gear icon next to the current working network connection.
    • Left click the IPv4 tab.
    • Left click Manual, and enter appropriate values for the address, netmask, and gateway.
    • Left click the toggle to turn automatic DNS off, and enter appropriate values for the DNS addresses.
    • The automatic routes can be left on.
  6. Reboot, start Firefox, and verify the connection is working.
  7. Left click the lower left Show Applications icon, and left click on Terminal.
  8. Install MythTV v30, plugins, and do some miscellaneous tasks by entering the following in the terminal:
    • sudo add-apt-repository ppa:mythbuntu/30
    • sudo apt install mythtv
    • sudo apt install mythplugins
    • sudo adduser $USER mythtv
    • mkdir -p $HOME/.mythtv
    • ln -s -f /etc/mythtv/config.xml ~/.mythtv/config.xml
  9. Reboot the PC.
  10. Setup the backend (part one):
    • In the terminal, enter "sudo systemctl stop mythtv-backend".
    • In the terminal, enter "mythtv-setup".
    • In General, set the security pin to 0000.
    • In General, set the IPv4 primary IP address to the address used in setting the static IP address above.
    • In Capture Cards, press enter with new capture card highlighted, press the down key to highlight new capture card, and press enter.
    • Select HDHomeRun networked tuner, press the right arrow key, press enter with use HDHomeRun... selected to enable it, and in Recording Options, deselect EIT scanning.
    • Repeat the above step three times for the three available tuners.
    • In Video Sources, create a new source, name it NG, set the listing grabber to no grabber, the CF table to default, and the network ID to -1.
    • In Input Connections, create three connections, name them Prime1, Prime2 and Prime3, set the name to MPEG2TS, and set the source to NG.
    • In Storage Directories, set the default to /var/lib/mythtv/recordings/, and set live TV to /var/lib/mythtv/livetv/.
    • Save, and press Esc to exit myth-setup.  Do not start the backend, and do not update the database when prompted upon exiting.
  11. Reboot the PC.
  12. Scan for channels and add channels to MythTV:
    • Start Firefox, and access the HDHomeRun Prime's web page interface by going to http://my.hdhomerun.com.
    • Left click HDHomeRun Prime.
    • Left click Channel Lineup.
    • Left click Detect Channels, and give it about 20 minutes to detect all channels.  The channel numbers should appear as the scan progresses.  Channels marked "DRM" will not work with MythTV.  With Comcast, only premium channels such as HBO are generally marked "DRM".
    • Add channels to MythTV using the hdhrchan2myth.py script.  The usage instructions can be found at here.
  13. Setup the backend (part two):
    • In the terminal, enter "sudo systemctl stop mythtv-backend".
    • In the terminal, enter "mythtv-setup".
    • In Channels, delete the channels that are not needed.
    • Exit myth-setup.  Do not start the backend, and do not update the database when prompted upon exiting.
  14. Reboot the PC.
  15. Set the sound output in Ubuntu:
    • Left click the lower left Show Applications icon, and left click on Settings.
    • In Sound, set the output to HDMI/displayPort-Built-in Audio.
    • Close the settings window.
  16. Change settings in systmed so the backend will not start until the network is up:
    • In the terminal, enter "sudo systemctl edit mythtv-backend.service".
    • Once the nano edit mode starts, add only the following two lines:
      • [Unit]
      • After=NetworkManager-wait-online.service
    • Save and exit from nano edit mode.
    • Edit /etc/mysql/mysql.conf.d/mythtv.cnf, and delete "#" before "bind-address=::" if it is there
  17. Setup the frontend:
    • Left click the lower left Show Applications icon, and left click on MythTV Frontend.
    • In Setup, select Setup Wizard.
    • In the wizard, choose an audio device, and select Test Speakers.  Change the audio device and test again until the test sound can be heard.  
    • Also in the wizard, choose VAAPI Normal for the video playback profile.  After this step, it should be possible to watch live TV.
    • In Video, select Playback.
    • Use the arrow keys to highlight Current Video Playback Profile, and press the right arrow key.
    • For the vaapi entry, deselect Deblocking filter, and set the primary and fallback deinterlacer to none.
  18. Install hdhrepg2myth using the directions shown here.
  19. Install mythrecmaze using the directions shown here.
  20. Automatically start MythTV when the computer starts:
    • Open Terminal and enter "gnome-session-properties".
    • Left click on Add and enter bash -c "sleep 20 && ./mythrecmaze.sh && mythfrontend --service" with the quotes included if mythrecmaze was installed.  Alternatively, enter bash -c "sleep 20 && mythfrontend --service" to just start the MythTV frontend.  No entry is needed for the backend.

Saturday, June 29, 2019

Hdhrchan2myth - Import Channels from HDHomeRun to MythTV

This small script can be used to add channels to MythTV from an HDHomeRun device.  It has been tested with only MythTV v30 on Ubuntu with an HDHomeRun Prime.  Also, it works with one HDHomeRun device and has not been tested with multiple HDHomeRun devices on the same network.

Before using this script, the channels must already be shown in the channel lineup by accessing the HDHomeRun's internal web page interface.  Scanning for channels and viewing the channel lineup can be done by opening a web browser and visiting http://my.hdhomerun.com.

Usage instructions:
  1. Download the latest release from https://github.com/heyted/hdhrchan2myth by clicking on releases.
  2. Extract hdhrchan2myth.py, and move the file to the /tmp folder (not a tmp folder in the home folder).
  3. Right click on the file, left click on properties, left click on the permissions tab, and select "allow executing file as a program."
  4. Open a terminal and enter the following:
    • sudo su mythtv
    • /tmp/hdhrchan2myth.py
    • exit
  5. All downloaded files can be deleted.