Thursday, October 29, 2015

DVR with MythTV

I recently upgraded the computer that runs MythTV, the digital video recorder (DVR) software that I use for broadcast TV. Newegg had a sale on refurbished Dell PCs (just $99 when I got mine), which are underpowered for most uses, but just about perfect for dedicating to recording and playback of TV broadcasts. I had been using an even-lower-power Asus Eee Box (creatively named "eeebox" on my home network), which did the job but definitely had issues keeping up with demand at times. The new machine has double the processor speed and quadruple the RAM.
For receiving TV broadcasts, I use a HDHomeRun tuner, connected to my local Ethernet network. It's hooked up to a Leaf antenna for receiving over-the-air broadcasts. This all worked fine with the old machine, and there was no reason to change that part of the setup with the new one. (There's no reason you couldn't do this with a cable or satellite feed as well, as long as the tuner you use properly decodes the signal.)

Here's how I went from the fresh-out-of-the-box machine to a functioning DVR system:

  1. The new machine came with Windows pre-installed. I have no intention of running Windows on this system, but I went ahead and booted it up to make sure the hardware worked properly. Video output, mouse, keyboard, network connection...all good.
  2. My operating system of choice is Ubuntu Linux. Mostly just personal preference, as almost any major OS will work. I'm using the server version, since I don't need all the desktop applications that come with a desktop version. Downloaded the ISO install image, and put it on a USB stick for installation.
  3. Plugged the USB stick into the new machine and booted it up. In order to boot from the USB stick, you have to hold down a key (F12 in this case) to interrupt the boot-up process, and tell it to use the USB stick instead of the internal drives.
  4. Went through Ubuntu server install process. This guide is a pretty good overview. I chose to delete the existing partitions on my hard drive (they were just Windows, don't need that) and start fresh. I named the machine "LittleDell" for easy reference, and used the same user account name as on eeebox (just to make things simple). Near the end of the process, you need to choose software to install. I picked only the Base Server Software and OpenSSH options. I'll install anything else needed later on.
  5. After the reboot at the end of the install, LittleDell was up and running. Since I installed SSH, I could easily access it from my regular desktop. After copying over my .ssh directory from eeebox, enabling key-based login, access from one machine to another via SSH was a smooth process.
  6. Before installing MythTV, it's necessary to have a graphical environment, since the Myth setup process doesn't run in a terminal. I chose to install x2go server since I'm familiar with it. (Something like VNC would likely work just as well.) This nice tutorial shows how. With the x2go client on my regular desktop machine, I have access to the LittleDell desktop.
  7. It's also a good idea to shut down any existing MythTV installations on the local network before starting a new install, so I shut down the MythTV server on eeebox (including the MySQL server). If you leave it running, the new installation will helpfully try to connect to it...which we don't want.
  8. Finally, the MythTV installation itself, as documented here. Since I was using x2go, there was no need to use a remote desktop as that guide suggests; I just logged as the mythtb user and ran mythtv-setup directly:
    su -s -u mythtv
    cd ~

    Some notes for the setup process:
    • It's a good idea to manually turn off the Myth server before starting setup (sudo stop mythtv-backend). It will try to do this for you, but it doesn't always work right.
    • Change the IP address in the first General screen to the local LAN address (it should show up in the drop-down menu) rather than the default of This lets external clients (for instance, Kodi on a FireTV) connect.
    • It's a good idea to schedule program listing updates to happen automatically. There's a screen for this in the General settings. I enable it, and leave the default values - that gives me once-a-day updates. You can always run it more often if needed, by running /usr/bin/mythfilldatabase manually as the mythtv user.
    • When setting up capture cards, the HDHomeRun tuners should show up in the drop-down menu. You'll want to create as many entries as there are tuners (mine has two), since that will let you record multiple shows at once.
    • I use Schedules Direct to get my TV listing data. This is configured in the Video Sources section of Myth setup.
    • You'll need to create one Input Connection for each capture card. They can all be linked to the same Video Source. You need to scan for channels on the first one, but not all the others.
    • When you're done, you'll be prompted to run mythfilldatabase and/or start up the Myth server. I recommend saying no to both, and instead doing it manually (still as the mythtv user):
      sudo start mythtv-backend
      This way, if there's any problems, you'll be notified right away.
I also did a couple of additional optional steps:
  • Installed MythWeb as shown here, the remote web interface to the Myth server. This way I can schedule shows, see what recordings are available, view listings, etc from my computer, rather than going through Kodi. Much more user-friendly. 
  • Moved the mythtv data directories from /var/lib/mythtv to a different partition. Any disk partition with plenty of space will do, as long as it's separate from your root filesystem. (I used an external drive, thus the name /mnt/extdrive.) Shut down the Myth server, then do this:
    cp -rv /var/lib/mythtv /mnt/extdrive
    chown -R mythtv.mythtv /mnt/extdrive/mythtv
    sudo mv /var/lib/mythtv /var/lib/mythtv.orig
    sudo ln -s /mnt/extdrive/mythtv /var/lib

    Then you can restart the Myth server. Once you're sure that it's working, get rid of the original files with:
    sudo rm -rf /var/lib/mythtv.orig
    The reason for this is to make sure you have plenty of space for recordings. And if you do run out of space, it won't crash your system.
All told, 2-3 hours of work, of which about half was waiting on installers to finish. Not too bad for a functional DVR! 

No comments:

Post a Comment