I created this document while building a combo FE/BE so the instructions should be as accurate as possible.
The first part is common to both, so we will start there. We are going to build from source so the latest will always be available for the version we want to work with.
We will be building 'mythtv-light' so the software will be packaged as a .deb file that can be easily installed and upgraded. Specifically, we will be building the latest released version v33 (fixes/33) for RPi OS 64 bit.
However, you may find the version of v33 that you want from the link https://dl.orangedox.com/pCBmBm page for mythtv-light and you can use that. The latest are at: https://dl.orangedox.com/pCBmBm/1bO1JOe ... gB0yPsaTHe
I'll try to keep the v33 Bullseye folders up to date.
However, the instructions below are for v33 Bullesys 64 bit only and may or may not work on anything else.
The hardware being used in this example is:
RPI4 4GB RAM
USB3 to SATA Adapter based on the ASMedia ASM1153E controller
1TB SATA SSD
USB keyboard
FHD HDMI monitor
SiliconDust HDHomeRun Quatro networked ATSC 1.0 tuner (4 tuners) (HDHR)
Ethernet connected to the same network as HDHR with Cat-5e, but WiFi can work if yours is a very good connection.
Using the Raspberry Pi Imager 1.7.1 or newer, select the Bullesys 64bit Lite version since we will not be running a Desktop Environment. Flash the image directly to the SATA SSD using the adapter. Use the setting of Imager to select to enable ssh and assign a password.
On first boot, log into the RPI4 using 'ssh' and run "sudo apt update && sudo apt upgrade -y" to upgrade to the latest OS software. We recommend using ssh from another PC because this will be easier if we can cut-and-paste some of the commands.
Next run "sudo raspi-config" and set the following:
System Options -> Hostname
System Options -> Boot / Auto Login -> Console Autologin
Localization, for this example, set for en_US.UTF-8, America/New_York
If using WiFi, setup the wifi SSID and password.
We need to setup the dependencies and clone the repositories. You can get the background by looking at some MythTV wiki pages, but I'll give the instructions to follow from those pages.
https://www.mythtv.org/wiki/Build_from_Source
https://github.com/MythTV/packaging/tre ... /deb-light
https://github.com/MythTV/ansible
Get the dependencies:
Code: Select all
sudo apt install git ansible
git clone https://github.com/MythTV/ansible
cd ansible
./mythtv.yml --limit=localhost
cd
Code: Select all
mkdir ~/build
cd build
git clone https://github.com/MythTV/mythtv.git mythtv
cd mythtv
git checkout fixes/33
Code: Select all
cd ~/build
git clone https://github.com/MythTV/packaging.git
cd packaging
git checkout fixes/33
Code: Select all
cd ~/build/mythtv/mythtv
../../packaging/deb-light/build_package.sh
Go get a beer while it compiles. It could take a while (1 hour 56 minutes on RPI4 overclocked to 2.0Ghz), so maybe several beers.
Code: Select all
cd ../..
Code: Select all
sudo apt install ./mythtv-light_33.1-12-gc4b7e4c433-0_arm64_bullseye.deb
If you want a combo FE/BE, then we have to setup the backend now.
There is a utility to make this easier so clone the following repository:
Code: Select all
cd
git clone https://github.com/MikeB2013/pi-utils.git
cd pi-utils
Make the following changes:
Code: Select all
mythtv_git_branch=fixes/33
php_version="7.4"
Code: Select all
./pi-mythbackend-helper.sh
reboot
This must be run as user 'mythtv'
Code: Select all
sudo su mythtv
cd
tv_grab_zz_sdjson_sqlite --manage-lineups --config-file $HOME/.mythtv/SD.xmltv
Then select the "Initialize/update the local database"
Take the defaults on the next several questions until it exits.
Code: Select all
tv_grab_zz_sdjson_sqlite --configure --config-file $HOME/.mythtv/SD.xmltv
Select the Lineup. If you only have one it will be listed and you can reply yes.
Take the defaults until the command exits.
Code: Select all
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
Confirm your lineup.
Choose which channels are selected. Walk thru the channels and select yes or no.
When you're done with the list of channels, just exit.
Exit back to user 'pi' with 'exit'
At this point we are done with ssh and now will run from the RPI4 console.
Now setup the backend with:
Code: Select all
pi-utils/run_mythsetup.sh
Under Job Queue (Backend-Specific) I uncheck 'Allow Transcoding Jobs' and 'Allow Commerical Detection Jobs'. The RPI4 is not good at transcoding and Commerical detection also affects performance. Your mileage may vary.
You can make other changes if you want.
Under 2. Capture cards, select New Capture Card 4 times since we have a 4 tuner HDHomerun. The first select of New Capture Card takes some time comparied to the next 3, so wait.
At each New Capture Card entry select HDHomeRun Networked Tuner then press the right arrow and check the tuner you want to use and then right arrow on Recording Options and uncheck Use HDHomeRun for active EIT scan since we are using SchedulesDirect for EPG.
Repeat for the other tuner entries.
Under 4. Video Sources, select New Video Source. It will take a few seconds.Then select the new entry for New Video Source and then select Video Source Name and enter 'SD' which is what we used in our XMLTV setup. Note upper-case 'SD'
For Listings Grabber select Multinational (Schedules Direct JSON Web Service with SQLite D...
Then ESC and save and exit.
Under 5. Input connections select 'MPEG2TS' under Input Name and select 'SD' under Video Source.
Then only on the first Input Connections go to Scan for Channels and go to the bottom and select Scan.
Insert All
ESC and save. Then set the other Input conections up the same, but don't scan for them.
The rest of the default settings of Input connections should work and also allow multi-channel recording for subchannels like 5.1 and 5.2 on the same tuner.
Use 6. Channel Editor if you have some channels you don't want displayed.
Under 7. Storage Group you should fill out at least Default but can do more to suit your needs. Walk the folders for Default to /srv/mythtv/recordings. All of our storage directories in this case are under /srv/mythtv/.
reboot
Now we need to put in some delay mechanism to make sure the HDHomerun tuners are on the network before mythtv-backend.service starts up. There are many ways to do this but the easiest to setup on the RPI4 is setting up a service that waits for a ping of a networking device like the HDHR tuner and have the mythtv-backend.service wait for that service. There is a discussion with the full instructions to implement this service athttps://lists.archive.carbon60.com/myth ... 986#625984
The instructions are cut down to what we will use. First become root user:
Code: Select all
sudo su
Code: Select all
cd /usr/local/bin
wget http://www.jsw.gen.nz/mythtv/wait-until-pingable.py
chmod u=rwx,g=r,o=r wait-until-pingable.py
cd /etc/systemd/system
mkdir mythtv-backend.service.d
chmod u=rwx,g=rx,o=rx mythtv-backend.service.d
cd mythtv-backend.service.d
wget http://www.jsw.gen.nz/mythtv/mythtv-backend-wait-until-pingable.conf
chmod u=rw,g=r,o=r mythtv-backend-wait-until-pingable.conf
cd ..
wget http://www.jsw.gen.nz/mythtv/local-network-pingable.service
chmod u=rw,g=r,o=r local-network-pingable.service
Use nano or your favorite editor:
nano local-network-pingable.service
Then save the changes and exit from nano or your editor and do these commands:
Code: Select all
systemctl enable local-network-pingable.service
systemctl start local-network-pingable.service
systemctl status local-network-pingable.service
Code: Select all
systemctl daemon-reload
exit
Now we need to create a command to start the frontend.
Create "~/run_mythfrontend.sh" containing the ONE line below:
Code: Select all
QT_QPA_EGLFS_ALWAYS_SET_MODE="1" QT_QPA_PLATFORM=eglfs QT_QPA_EGLFS_KMS_CONFIG=./pi_mythfrontend.json mythfrontend --noupnp --logpath /tmp
Code: Select all
{
"device": "/dev/dri/by-path/platform-gpu-card",
"outputs": [
{ "name": "HDMI1", "mode": "1920x1080@60" }
]
}
Now we can execute "./run_mythfrontend.sh" and setup and Audio and Video as below:
In Setup -> Audio -> Audio Output Device select "ALSA:hdmi:CARD=vc4hdmi0,DEV=0"
Setup Digital Audio and speakers base on your audio system.
In Setup -> Video -> Playback change what you want but the critical ones are:
Advanced Playback Settings -> Audio Read Ahead (ms) to your needs. Start by using 400.
Change the Current Video Playback Profile to OpenGL Normal and drill down to change Max CPUs to 4 and Deinterlacer Quality (single rate) to Low quality. Do the same for Deinterlacer quality (double rate).
Performance settings.
The RPI4 standard settings are all you need for a good picture. However, you can improve the FPS jitter statistics by overclocking. I have found that the RPI4 can be overclocked and still be reliable. Most all RPI4s can overclock to 2.0 Ghz. The unit in this case is the newest RPI4 stepping and by default on Bullseye runs at 1.85Ghz. More RPI4 overclocking information at https://magpi.raspberrypi.com/articles/ ... erry-pi-4
I overclocked it as follows:
edit /boot/config.txt
add these lines to the file:
Code: Select all
arm_freq=2147
over_voltage=6
gpu_freq=750
Since we are using a SSD we need to setup automatic trim once a week. The service that controls this is fstrim.service/timer.
Use 'lsusb' to find the vendor and product IDs for your USB3-SATA adapter. Mine is an ASMedia ASM1153E controller (Eluteng adapters) and "lsusb" shows:
Code: Select all
Bus 002 Device 002: ID 174c:55aa ASMedia Technology Inc. ASM1051E SATA 6Gb/s bridge, ASM1053E SATA 6Gb/s bridge...
Code: Select all
# ASMedia ASM1153E controller (Eluteng adapters)
ACTION=="add|change", ATTRS{idVendor}=="174c", ATTRS{idProduct}=="55aa", SUBSYSTEM=="scsi_disk", ATTR{provisioning_mode}="unmap"
Code: Select all
sudo systemctl enable --now fstrim.timer