How I installed MythTV v31 on my RPI 4
The purpose of this blog is to create a repeatable set of instructions so I can duplicate my basic installation of Raspberry PI OS and MythTV on a Raspberry PI 4 so I can start my tests with the same baseline every time.
The hardware is:
- Raspberry Pi 4 with 4GB DRAM from Canakit as a starter kit.
- StarTech/Eluteng SATA to USB Cable - USB 3.0 to 2.5” SATA III Hard Drive Adapter
- Samsung 860 QVO 1TB Solid State Drive (MZ-76Q1T0) V-NAND, SATA 6Gb/s
- SiliconDust HDHomeRun Connect Quatro tuner
- It helps keep things stable with your system if you set your AP/router to automatically assign the same IP to a device each time it boots. Having the HDHR Quatro and the RPI 4 always have their same IP each time they boot solves a lot of problems before they happen.
- Install the Raspberry Pi Imager on a Linux, Mac, or Windows 10 computer.
- Use the Raspberry Pi Imager to get the latest Raspberry Pi OS. Since my RPI4 will be dedicated to MythTV, I used the Lite version of the OS. The Imager will write the OS to your boot memory device. In my case the RPI4 has the latest bootloader flashed to the eeprom so I plugged in the USB3 SATA adapter with the SSD drive into my Windows laptop and imaged the SSD with the Lite image.
- Install the USB4 SATA SSD into one of the USB3 slot on the RPI4.
- Plug in a HDMI TV and Keyboard/mouse, and LAN cable.
- Turn on the RPI 4
- After booted, use sudo raspi-config to configure the regional stuff, set wait on network at boot, and turn on ssh.
- Reboot.
- Install 'git' with sudo apt install git
- Download a bunch of great PI utility scripts. git clone https://github.com/MikeB2013/pi-utils.git
- Now install Mythtv-light by: ./pi-utils/pi-setup_mythtv_31.sh
- There are some questions to answer. I picked so the backend scripts were installed and auto boot into mythfrontend was installed. After this is done, I temporarily comment out $HOME/run_mythfrontend.sh in .bashrc until I'm finished with setup.
- At this point the mythtv frontend is installed so now I want all the stuff needed for the backend. Use the pi-utils script pi-mythbackend-helper.sh to do this.
- The script has sudo commands when needed so run as 'pi'
- After the script ends you need to reboot.
Mythtv-setup for HDHR tuners with OTA EPG Program Guide
- Run ./run_mythsetup.sh and start with the General settings
- In Host Address Backend Setup, set Security PIN (required) to "0000"
- In Capture cards I created 4 new tuners, all set for HDHomeRun Networked Tuner. I selected the same Tuner IP address for all 4 since my HDHR is a Quatro and has 4 tuners. If you only have one HDHR box, then you'll only see one HDHR Tuner IP to select.
- On the first tuner I set Record Options -> Use HD HomeRun for active EIT scan to selected, but set it to Unselected for the other 3 tuners. This helps balance the EPG scanning vs. the locked tuners for other applications.
- In Video Source, I created 1 new source named OTA and for Grabber I selected Transmitted guide only (EIT)
- In Input connections, I edited the first input. I selected MPEG2TS in Input name list. In Display Name I put HDHR1. In Video Source I selected OTA and then scanned for channels.
- Once the Scan was complete I inserted all, exited and saved.
- I setup the other 3 Input connections but did not run scan for them. They should be set the same except for the Display name where I used HDHR2-4.
- In Channel Editor I made some channels not visible and saved.
- In Storage Groups I set the Default to /srv/mythtv/recordings and DB Backups to /srv/mythtv/db_backups. You can setup the other storage group directories if you want.
- Exit setup which restarts mythtv-backend.service.
- Now you can run mythtv frontend with: ./run_mythfrontend.sh
- Once in the frontend I went to setup and changed:
- In Setup Wizard -> Audio Configuration I selected ALSA:hw:CARD=b1,DEV=0
- I also selected Dobly Digital, etc and 5.1 Speakers.
- In Video I selected MMAL, Standard Decoder and OpenGL software.
- At this point video and audio will work from the tuners. My optional settings are:
- In General -> Shutdown/Reboot Settings -> Customize exit menu options I chose "Show quit"
- In Theme Chooser I chose Mythbuntu 30.1
- In Video -> Playback -> General Playback -> Automatically mark a recording as watched to selected
- In Video -> Playback -> General Playback -> Action on playback exit to Always prompt (excluding Live TV)
- In Video -> Playback Groups -> Default Group -> Skip ahead to 60 and Skip back to 15.
- I don't run Commercial flagging since that doesn't work well for my usually recorded programs so I edit the default recording rules to not post process commercial flagging.
Change to using an EPG from Schedules Direct via XMLTV json.
With the RPI 4 in the state as setup above I started this sequence of instructions to switch from OTA to Schedules Direct for my EPG.
- Switch to user 'mythtv' by: sudo su mythtv and then cd $HOME
- Follow the help on the mythtv xmltv wiki page at https://www.mythtv.org/wiki/XMLTV#Setup_with_tv_grab_zz_sdjson_sqlite
- Run the commands:
- tv_grab_zz_sdjson_sqlite --manage-lineups --config-file $HOME/.mythtv/SD.xmltv
- Enter login info for Schedules Direct
- Enter 5 to initialize the database
- Take the defaults and exit.
- Run the command:
- tv_grab_zz_sdjson_sqlite --configure --config-file $HOME/.mythtv/SD.xmltv
- Answer yes to the lineup you want to use and no to the others, then take the defaults and exit
- Run the commands:
- tv_grab_zz_sdjson_sqlite --days 0 --config-file $HOME/.mythtv/SD.xmltv
- tv_grab_zz_sdjson_sqlite --manage-lineups --config-file $HOME/.mythtv/SD.xmltv
- Select Manage database lineup channel selection. Then Choose which channels are selected.
- Now go through and pick yes or no on the channels you want data on.
- You may have to do the option 5 again if you missed a channel or selected wrong,
- exit
- Switch back to user 'pi' by :exit
- Run the mythtv-setup by: ./run_mythsetup.sh
- In General -> Job Queue (Backend-Specific) -> I deselected Allow commercial Jobs and Allow transcoding jobs. (not needed for me)
- In General -> Program Schedule Downloading Options -> Automatically update program listings -> Guide Data Program execution start/end I set them to 2 and 5
- In General -> Program Schedule Downloading Options -> Automatically update program listings -> Run guide data program at time suggested by the grabber I deselected.
- I've never had the problem of running out of memory while mythfilldatabase is running, but some have, so I've add the Guide Data Argument option: --no-allatonce
- On Capture cards deselect the "Use HD HomeRun for Active EIT scan" in Recording Options for any tuner you had it enabled on.
- In Video Sources Delete all video sources. Then add a New video source.
- In the Video Source make the Video source name match what was done in XMLTV setup which is "SD"
- Select Listing grabber to be Multinational (Schedules Direct JSON web services with SQLite...
- Save and exit.
- In Input Connections go through each and select Video Source "SD" and only do the scan in the first Input Connection.
- In Channel Editor you may need to revisit any changes done before as the rescan will have undone them.
- Exit which restarts the mythtv-backend.service.
- The next step may not be necessary because on my RPi4 starting the mythtv-backend.service triggers the mythfilldatabase to run when you exit. So you may want to wait for 5 minutes to see if the EPG fills automatically.
- Switch back to user 'mythtv' and run "mythfilldatabase"
- Once mythfilldatabase completes, exit back to user 'pi'
- Run the mythfrontend by: ./run_mythfrontend.sh and see how the guide has changed. 18 days of data.