How to build a MythTV v33 system using EndeavourOS

For discussion of topics specific to MythTV on Raspberry Pi devices
Post Reply
User avatar
jfabernathy
Senior
Posts: 577
Joined: Wed Feb 18, 2015 2:37 pm
Location: Raleigh, NC
United States of America

How to build a MythTV v33 system using EndeavourOS

Post by jfabernathy »

These instructions are for those who want to play around with what I think is the best video playback performance you can get with MythTV on a Raspberry Pi 4 4GB. However, this is not the easiest way to get MythtV on a RPI4. For most people using MythTV on Raspberry PI OS or Ubuntu 23.04 might be better and easier to get installed. Guides for that are in this forum.

I will be installing Archlinux ARM on the RPI4, but since that is a real pain, I'll be using Endeavour OS ARM which ultimately gets you Archlinux ARM, but a lot easier to install.

The results will also have the advantage of allowing the user to have a full Desktop Environment and still be able to run mythfrontend when desired. In this case I'll be using KDE Plasma on X11, but with compositor off.

We are going to build MythTV fixes/33

The hardware being used in this example is:
RPI4 4GB RAM
USB3 to SATA SSD Adapter
1TB SATA SSD
USB keyboard
FHD HDMI monitor
SiliconDust HDHomeRun Quatro networked ATSC 1.0 tuner (4 tuners) (HDHR)
Ethernet connected to the HDHR with Cat-5e directly.
WiFi used for an Internet connection.

We will be following the instructions on installing EndeavourOS (EOS) ARM from https://arm.endeavouros.com/. However, you basically get the EOS bootable ISO for your x86_64 laptop or PC and boot the live version so nothing changes on you laptop. Once the EOS ISO has booted, there will be a Welcome window that shows options and one is the ARM installer. Make sure you have a network connection before clicking the ARM installer because this is a network install. You should also have your USB3 SATA SSD plugged in at this point. Once this completes you can remove the USB3 SATA SSD and plug it into your RPI4.

EOS ARM will boot your RPI4 into an Calamares type installer that lets you setup your credentials and choose your desktop environment. In my case I used KDE Plasma as I like it best and it's performance is very good on a RPI4 under X11 with compositor off. Plasma also is easier for setting up other aspects of living on my home network by managing the firewall, creating menu items, and allowing the Dolphin file manager browse the local LAN.

On first boot of the RPI4 after installation of Plasma, at the login page, select X11 because it will default to Wayland which doesn't work well on KDE Plasma and the RPI4. After logging in go to Settings and search for the setting compositor, then disable it on boot.

I overclocked my RPI4 as follows:

edit /boot/config.txt
add these lines to the file:

Code: Select all

arm_freq=2000
over_voltage=6
gpu_freq=750
Since my network is behind several firewalls, I turn off the firewall on EOS by running:

Code: Select all

sudo systemctl disable --now firewalld.service
To make the locat network browseable I do the following as suggested on the Archlinux Wiki.
https://wiki.archlinux.org/title/avahi# ... resolution
Edit /etc/nsswitch.conf and change the hosts: line to look like this:

Code: Select all

hosts: mymachines mdns_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] files myhostname dns
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 as Archlinux ARM is different when it comes to dependencies.
https://www.mythtv.org/wiki/Build_from_Source


Get the dependencies:

Code: Select all

 sudo pacman -S --needed python-pip exiv2 fftw jack lame libass libavc1394 \
       libbluray libiec61883 libpulse libsamplerate libva libvdpau libvpx \
       libxinerama libxml2 libxrandr qt5-script taglib x264 x265 \
       soundtouch git base-devel help2man libcdio libcec libmariadbclient \
       libxml2 lirc perl-dbd-mysql perl-io-socket-inet6 perl-libwww \
       perl-xml-simple perl-xml-xpath python-future python-lxml \
       python-mysqlclient python-requests python-simplejson yasm glew \
       mariadb mariadb-clients perl-dbd-mysql perl-io-socket-inet6 libzip python-pyqt5-webengine lzo
yay -S libhdhomerun 
yay -S perl-net-upnp
yay -S python-timeout-decorator 
yay -S python-requests-cache 
Occasionally you might see a failure for one of the packages installed from the Archlinux AUR using 'yay'. You may need to work the AUR website https://aur.archlinux.org/ for that package to see what maybe the problem.

Clone the MythTV repository and build from source. If you copy this whole block it should work but take ~2 hours to complete:

Code: Select all

mkdir ~/build
cd ~/build
git clone https://github.com/MythTV/mythtv.git mythtv
cd mythtv
git checkout fixes/33
cd mythtv
./configure --prefix=/usr --disable-vdpau --enable-opengl --disable-vaapi --arch=aarch64
make -j 4
sudo make install
At this point the MythTV software is installed and if you only want a frontend then you are done.

If you want a combo FE/BE, then we have to setup the backend now. The bash script below is what I use. It sets up the Database, mythtv user, directory structure, xmltv, daily backups service, mythtv-backend service, and mythfilldatabase service. You should save it as a .sh file and make it executable. Look for user names and email addresses to get notices or comment that part out. There is also a section of function calls that you can comment out what you don't want.

Code: Select all

#! /bin/bash
# Globals
mythtv_git_directory=/tmp/build
mythtv_git_branch=fixes/33
mythtv_password=mythtv    #if changed need to manually update /etc/apache2/sites-available/mythweb.conf
mythtv_storagegroup_path=/srv/mythtv/ # using /srv/mythtv in preference to /var/lib/mythtv/,
mythtv_storagegroups="banners coverart fanart recordings streaming videos bare-client db_backups  livetv  screenshots  trailers music musicart"

# this gets git source for mythweb and mythtv/packaging
fn_get_git()
{
mkdir -p $mythtv_git_directory
cd $mythtv_git_directory

#mythtv packaging - we only need a few files
git clone -b $mythtv_git_branch https://github.com/MythTV/packaging.git
git clone -b $mythtv_git_branch https://github.com/MythTV/mythtv.git
}


fn_setup_mythtv_user()
{
sudo useradd -m --groups optical,audio,video --home /home/mythtv --shell /bin/bash mythtv
# allow default user, to run mythtv-setup
sudo usermod -aG mythtv $USER

# create basic config.xml in /etc/mythtv/ same as ubuntu (mythbuntu ppa)/debian (built from source)
sudo mkdir -p /etc/mythtv/

sudo bash -c "cat >/etc/mythtv/config.xml" <<ENDOFSCRIPTINPUT
<Configuration>
  <LocalHostName>my-unique-identifier-goes-here</LocalHostName>
  <Database>
    <PingHost>1</PingHost>
    <Host>localhost</Host>
    <UserName>mythtv</UserName>
    <Password>${mythtv_password}</Password>
    <DatabaseName>mythconverg</DatabaseName>
    <Port>3306</Port>
  </Database>
  <WakeOnLAN>
    <Enabled>0</Enabled>
    <SQLReconnectWaitTime>0</SQLReconnectWaitTime>
    <SQLConnectRetry>5</SQLConnectRetry>
    <Command>echo 'WOLsqlServerCommand not set'</Command>
  </WakeOnLAN>
</Configuration>

ENDOFSCRIPTINPUT

sudo mkdir -p /home/mythtv/.mythtv/   # for mythtv user
sudo ln -s /etc/mythtv/config.xml /home/mythtv/.mythtv/config.xml
sudo cp $mythtv_git_directory/packaging/deb/debian/session-settings /etc/mythtv/
sudo chown -R mythtv:mythtv /home/mythtv/ /etc/mythtv

mkdir -p $HOME/.mythtv/  # for pi user
ln -s /etc/mythtv/config.xml $HOME/.mythtv/config.xml # for mythfrontend

sudo cp $mythtv_git_directory/packaging/deb/debian/41-mythtv-permissions.rules /lib/udev/rules.d/
sudo cp $mythtv_git_directory/packaging/deb/debian/30-mythtv-sysctl.conf /etc/sysctl.d/
echo -e "\nmythtv user setup"
}

fn_setup_xmltv()
{
# install repository version (gets required perl modules)
yay -S xmltv
sudo ln -s /usr/bin/vendor_perl/tv_* /usr/local/bin/
echo -e "\nxmltv has been installed and updated to latest version"

}

fn_setup_mariadb()
{
sudo pacman -S --needed mariadb
sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
sudo systemctl enable --now mariadb.service
sudo mysql_secure_installation

#setup timezone info
mysql_tzinfo_to_sql /usr/share/zoneinfo | sudo mysql -uroot mysql

sudo systemctl restart mysql

#setup mythconverg db
sudo mysql -uroot << ENDOFSCRIPTINPUT

CREATE DATABASE IF NOT EXISTS mythconverg;
CREATE USER IF NOT EXISTS 'mythtv'@'%' IDENTIFIED BY 'mythtv';
CREATE USER IF NOT EXISTS 'mythtv'@'localhost' IDENTIFIED BY 'mythtv';
SET PASSWORD FOR 'mythtv'@'%' = PASSWORD('$mythtv_password');
SET PASSWORD FOR 'mythtv'@'localhost' = PASSWORD('$mythtv_password');
CONNECT mythconverg;
GRANT ALL PRIVILEGES ON *.* TO 'mythtv'@'%' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'mythtv'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT
ENDOFSCRIPTINPUT

echo -e "\nmythconverg database created for user mythtv - password $mythtv_password"

}

fn_mythconverg_daily_backup()
{
# setup mythconverg daily backup, instead of weekly (personal preference)
sudo bash -c "cat >/etc/systemd/system/mythtv-database-backup.service" <<ENDOFSCRIPTINPUT
# This service unit is for backing up the mythtv database called mythconverg
#
[Unit]
Description=Backup MythTV Database 'mythconverg'
Requires=mysql.service
After=mysql.service

[Service]
Type=oneshot
ExecStart=/usr/local/bin/mythtv-database-backup.sh

ENDOFSCRIPTINPUT

sudo bash -c "cat >/etc/systemd/system/mythtv-database-backup.timer" <<ENDOFSCRIPTINPUT
# This timer unit is for mythtv-database-backup
#

[Unit]
Description=start mythtv-database-backup

[Timer]
Unit=mythtv-database-backup.service
OnCalendar=*-*-* 05:30:00
Persistent=true

[Install]
WantedBy=timers.target

ENDOFSCRIPTINPUT

sudo cp /tmp/build/mythtv/mythtv/contrib/maintenance/optimize_mythdb.pl /usr/local/bin/

sudo chmod a+x /usr/local/bin/optimize_mythdb.pl

sudo bash -c "cat >/usr/local/bin/mythtv-database-backup.sh" <<ENDOFSCRIPTINPUT
#!/bin/sh
# /etc/cron.weekly/mythtv-database script - check and backup mythconverg tables
# Copyright 2005/12/02 2006/10/08 Paul Andreassen
#                      2010 Mario Limonciello

set -e -u

DBNAME="mythconverg"
USER=jim
EMAILADDRESS="your-email-here@gmail.com"

/usr/bin/mysqlcheck -s \$DBNAME

BKUP_LOG=/tmp/backup-mythconverg.log

export MYTHCONFDIR=/home/\$USER/.mythtv/

/usr/local/bin/optimize_mythdb.pl | grep -v "^Analyzed:" 2>&1 >> \$BKUP_LOG

sudo --preserve-env --user=\$USER /usr/share/mythtv/mythconverg_backup.pl --rotate=5 --verbose 2>&1 >> \$BKUP_LOG

if [ \$? -eq 0 ]; then
    MSG="den-pc \$DBNAME Checked and Backed Up, RC=\$?"
else
    MSG="den-pc \$DBNAME Back Up Failed, RC=\$?"
fi

cd /srv/mythtv/db_backups
ls -l --directory --block-size=K * | tail -10 >> \$BKUP_LOG

#mail -s "\$MSG" \$EMAILADDRESS < \$BKUP_LOG

ENDOFSCRIPTINPUT

sudo chmod 755 /usr/local/bin/mythtv-database-backup.sh
sudo systemctl enable mythtv-database-backup.timer

echo -e "daily backup of mythconverg database has been setup"

}

fn_setup_mythfilldatabase()
{
sudo bash -c "cat >/etc/systemd/system/mythfilldatabase.timer" <<ENDOFSCRIPTINPUT
[Unit]
Description=MythTV mythfilldatabase timer.

[Timer]
OnCalendar=05:10:00
Persistent=true

[Install]
WantedBy=timers.target

ENDOFSCRIPTINPUT

sudo bash -c "cat >/etc/systemd/system/mythfilldatabase.service" <<ENDOFSCRIPTINPUT
[Unit]
Description=MythTV mythfilldatabase service.
Wants=mythtv-backend.service
After=mythtv-backend.service

[Service]
User=mythtv
Group=mythtv
Type=simple
ExecStart=/usr/bin/mythfilldatabase

[Install]
WantedBy=multi-user.target

ENDOFSCRIPTINPUT
sudo systemctl enable mythfilldatabase.timer
}



fn_setup_directories()
{
sudo mkdir -p $mythtv_storagegroup_path
cd $mythtv_storagegroup_path
sudo mkdir -p $mythtv_storagegroups
sudo chown -R mythtv:mythtv $mythtv_storagegroup_path
sudo chmod -R  2775 $mythtv_storagegroup_path
echo -e "\nDirectories setup.\n"
}

fn_setup_mythtv_backend_service()
{
#todo check if already exists and skip if it does with message, user may have modified it
# user should have created ovdrride file instead of modifying directly
# for now use -n (noclobber)

sudo cp -n $mythtv_git_directory/packaging/deb/debian/mythtv-backend.service /lib/systemd/system/
sudo systemctl enable mythtv-backend
sudo systemctl daemon-reload
echo -e "\nmythtv-backend.service has been setup and enabled \n"

}

fn_tidy_up()
{
# remove local packaging repositories

rm -fr  $mythtv_git_directory/packaging
rm -fr  $mythtv_git_directory/mythtv

}

#main
# make sure we are not root
RUNNINGAS=`whoami`
if [ $RUNNINGAS = "root" ] ; then
    echo "Please run as ordinary user, not with sudo"
    exit 1
fi

#check mythbackend has been installed, if not abort with message
MYTHBACKEND=`which mythbackend`
if [ -z "$MYTHBACKEND" ]; then
    echo -e "mythbackend not found"
    exit 1
fi

# to disable any fn_ call just put # in front
# change the order at own risk - not tested!
fn_get_git
fn_setup_mythtv_user
fn_setup_mariadb
fn_mythconverg_daily_backup
fn_setup_mythtv_backend_service
fn_setup_mythfilldatabase
fn_setup_xmltv
fn_setup_directories
fn_tidy_up


echo -e "\n**************************************************"

echo -e "\nIf running headless on Pi4, no monitor connected on hdmi port"
echo -e " put 'hdmi_ignore_cec=1' in '/boot/config.txt' and reboot"
echo -e "\nStorage Group directories have been created in '$mythtv_storagegroup_path'"
echo -e "Directories '$mythtv_storagegroups'"
echo -e "Use mythtv-setup Storage Directories to setup those required"
echo -e "\nFor mythtv prior to fixes/31, use systemctl commands to stop or start mythtv-backend"
echo -e "  To stop  'sudo systemctl stop mythtv-backend'"
echo -e "  To start 'sudo systemctl start mythtv-backend'"
echo -e "  Sometimes mythtv-backend maybe 'failed' by systemd, to re-enable use"
echo -e "   'sudo systemctl daemon-reload' followed by"
echo -e "   'sudo systemctl start mythtv-backend'\n"
echo -e "\nxmltv installed and updated to latest version"
echo -e "When using xmltv e.g. tv_grab_zz_sdjson"
echo -e "mythfilldatabase arguments should use '--no-allatonce'"
echo -e "\nmythconverg database password '$mythtv_password'"
echo -e "\nReferences:"
echo -e "  https://www.mythtv.org/wiki/Database_Setup"
echo -e "  https://www.mythtv.org/wiki/Build_from_Source"
echo -e "  https://www.mythtv.org/wiki/Systemd_mythbackend_Configuration"
echo -e "  https://www.mythtv.org/wiki/Setup_Storage_Directories"
echo -e "  https://www.mythtv.org/wiki/Mythfilldatabase"
echo -e "\nFinished setting up for mythtv-backend - Please reboot\n"
exit 0
The Electronic Program Guides (EPG) received over-the-air (OTA) are not ideal and we will not be using them here. We will be using SchedulesDirect (SD) EPG. XMLTV will be used to gather the EPG from SD. In this case, it will be for OTA ATSC 1.0 TV. We will use the XMLTV grabber called 'tv_grab_zz_sdjson_sqlite' and follow the instructions at:https://www.mythtv.org/wiki/XMLTV

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
You can at this point add a lineup to your account or use your existing lineup.

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
Take the default on database name/location.

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
Select 'Manage database lineup channel selection'
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 your normal user with 'exit' or ctrl-d

Now setup the backend with:

Code: Select all

mythtv-setup
Under 1. General -> Host Address Backend Setup set Security PIN to 0000 and Primary IP Address/DNS Name to the IP address of the RPI4 which you can find out by hitting enter and just select it.

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 should uncheck the automatic program guide update in the last General option as we will be using a systemd timer/service for that.

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

However, for mythtv-backend to start up properly after booting the RPI4, you are going to have to delay the startup of mythtv-backend until the HDHomerun tuners are discoverable.

Add an override to the mythtv-backend.service with:

Code: Select all

sudo --login systemctl edit mythtv-backend.service
Add or adjust the override file to include:

Code: Select all

[Service]
ExecStartPre=-/usr/local/bin/hdhomerun_check.py
Note the dash in the line above. That means that if the command fails, the backend will still start (so you
can watch recordings etc.) If you want to prevent the backend from starting, remove the dash.

You'll need to put the hdhomerun_check.py in /usr/local/bin and make it executable, owner/group root.

hdhomerun_check.py

Code: Select all

#!/usr/bin/python3
# -*- coding: utf-8 -*-

""" See if the HD Homerun box(s) are accessible and running

Requires Python 3.6 or later.

For backends started by systemd, use:

    sudo --preserve-env systemctl edit --force mythtv-backend.service

and enter or add as needed by your service:

    [Service]
    ExecStartPre=-/usr/local/bin/hdhomerun_check.py

Can be called with optional IP address(s) for users that
have multiple HDHRs that have STATIC addresses.

Use --help to see all options.

If run from the command line, then output will be to the screen.
Otherwise, a log file in /tmp named hdhr_discovery.log is made.
Changable with the --logfile switch.

Exit codes:

    0 = success (for *ALL* HDHRs if multiple IPs were specified)
    1 = no output from the hdhomerun_config discover command
    2 = IPv4 and IPv6 addresses found, disable IPv6 on NIC
    3 = logfile isn't writable, delete it and try again
    4 = keyboard interrupt
    5 x the number of HDHRs = HDHR is most likely not up

"""

__version__ = '1.28'

import argparse
import signal
import subprocess
import sys
from datetime import datetime
from os.path import basename
from os import _exit
from time import sleep


# pylint: disable=too-many-arguments,unused-argument
def keyboard_interrupt_handler(sigint, frame):
    ''' Handle all KeyboardInterrupts here. And, just leave. '''
    _exit(4)
# pylint: enable=unused-argument


def get_program_arguments():
    ''' Process the command line. '''

    parser = argparse.ArgumentParser(description='HDHR Access Test',
                                     epilog='*  Default values are in ()s')

    parser.add_argument('HOSTS', type=str,  default=None, nargs='*',
                        help='optional hostname(s)/IP(s) (%(default)s)')

    parser.add_argument('--attempts', default=20, type=int, metavar='<num>',
                        help='number of tries to find HDHRs (%(default)i)')

    parser.add_argument('--debug', action='store_true',
                        help='output additional information (%(default)s)')

    parser.add_argument('--logfile', default='/tmp/hdhomerun_check.log',
                        type=str, metavar='<lf>',
                        help='optional path + name of log file (%(default)s)')

    parser.add_argument('--sleep', default=1.5, type=float, metavar='<sec>',
                        help='seconds betweem attempts (%(default)s)')

    parser.add_argument('--version', action='version',
                        version='%(prog)s ' + __version__)

    return parser.parse_args()


def get_elapsed_time(start):
    ''' Calculate the time spent waiting for the HDHR to come up. '''

    delta = datetime.utcnow() - start
    rounded_delta = f'{delta.seconds + (delta.microseconds / 1000000):.3f}'
    return rounded_delta


def log_or_print(loglevel, message, output):
    ''' Add timestamp, log level then print to the selected location. '''

    print(datetime.now().strftime("%F %T.%f")[:-3], f'{loglevel:8}', message,
          file=output)


def last_message(loglevel, result, host, start, attempt, output):
    ''' Common success or failure message text. '''

    log_or_print(loglevel, f'{result} {"at " + host  + " " if host else ""}'
                 f'in {get_elapsed_time(start)} seconds '
                 f'and {attempt} attempt{"s"[attempt == 1:]}\n', output)


def check_one_device(host, args, output):
    ''' Try to discover the HDHR(s). '''

    attempt = 0
    command = ['hdhomerun_config', 'discover']
    start = datetime.utcnow()

    if host:
        command.append(host)

    for attempt in range(1, args.attempts+1):

        try:
            discovery_response = subprocess.check_output(
                command, text=True, stderr=subprocess.STDOUT).split()
        except subprocess.CalledProcessError:
            log_or_print('WARNING', f'{command[0]}: got no response, attempt: '
                         f'{attempt:2}', output)
            sleep(args.sleep)
            continue

        if not discovery_response:
            log_or_print('ERROR', f'No output from {command[0]}, aborting!',
                         output)
            sys.exit(1)

        if args.debug:
            log_or_print('DEBUG', f'Got: {" ".join(discovery_response)}',
                         output)

        if discovery_response.count('hdhomerun') > 1:
            log_or_print('ERROR', f'{command[0]}: more than 1 IP, aborting!',
                         output)
            sys.exit(2)

        if discovery_response[0] != 'hdhomerun':
            # Consider making this an ERROR and exiting not sleeping...
            log_or_print('WARNING', f'{command[0]} got an unexpected response:'
                         f' {" ".join(discovery_response)}',
                         output)
            sleep(args.sleep)
        else:
            last_message('INFO', f'Found HDHR {discovery_response[2]}', host,
                         start, attempt, output)
            return 0

    last_message('ERROR', 'No HDHR found', host, start, attempt, output)

    return 5


def main(args, output=None):
    ''' Control checking of one or more devices. '''

    log_or_print('INFO', f'Starting {basename(__file__)} v{__version__}, '
                 f'attempts={args.attempts}, sleep={args.sleep:.2f}', output)

    if args.HOSTS:

        return_value = 0

        for host in args.HOSTS:
            return_value += check_one_device(host, args, output)

    else:
        return_value = check_one_device(None, args, output)

    return return_value


if __name__ == '__main__':

    signal.signal(signal.SIGINT, keyboard_interrupt_handler)

    ARGS = get_program_arguments()

    if sys.stdin and sys.stdin.isatty():
        RETURN_VALUE = main(ARGS)
    else:
        try:
            with open(ARGS.logfile, encoding='ascii', mode='a') as file_obj:
                RETURN_VALUE = main(ARGS, output=file_obj)
        except PermissionError:
            print(f'Can\'t write to {ARGS.logfile}, aborting!')
            sys.exit(3)

    sys.exit(RETURN_VALUE)

# vim: set expandtab tabstop=4 shiftwidth=4 smartindent colorcolumn=80:
Now we need to create a command to start the frontend.
In KDE/Plasma you just right-click the Application launcher (Start button - left most button in panel) and Edit Application. You can follow the KDE instructions at this site if you don't know how to do this: https://docs.kde.org/trunk5/en/kmenuedi ... start.html


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).

The mythfilldatabase.service is set to run early in the morning. You can adjust that like any normal systemd timer. Since you don't want to wait to get an EPG, the first time you can get an update with:

Code: Select all

sudo systemctl start mythfilldatabase.service
Last edited by jfabernathy on Wed Oct 18, 2023 7:53 pm, edited 7 times in total.
User avatar
jfabernathy
Senior
Posts: 577
Joined: Wed Feb 18, 2015 2:37 pm
Location: Raleigh, NC
United States of America

Re: How to build a MythTV v32 system using EndeavourOS

Post by jfabernathy »

There have been some recent changes to the Mythtv dependency package qt5-webkit. First, it moved to the AUR which forces you to build it from the PKGBUILD file and that took forever. Second, now it will not build without locking up your RPI4. Not sure why.

However, I've found that other applications that depend on qt5-webkit now use python-pyqt5-webengine from the extra repository. So it does not need to be built.

After making this change to the mythtv dependencies, I successfully built Mythtv and have a working FE/BE combo. I did get a warning after the ./configure run about missing QT5 headers and that some plugins might not work. However, I have not found what does not work yet. I'll post more when I find out.

In the mean time I'll update the original post instructions to change the dependency.
User avatar
jfabernathy
Senior
Posts: 577
Joined: Wed Feb 18, 2015 2:37 pm
Location: Raleigh, NC
United States of America

Re: How to build a MythTV v33 system using EndeavourOS

Post by jfabernathy »

I have updated this topic with changes for MythTV v33. I also put in instructions for how to delay mythtv-backend launching until the HDHR tuner is online in the case where you use a directly connection from the HDHR to the RPI4's Ethernet port.
hamelg
Newcomer
Posts: 10
Joined: Fri Jan 03, 2020 8:57 pm
France

Re: How to build a MythTV v32 system using EndeavourOS

Post by hamelg »

jfabernathy wrote:
Sun Jan 01, 2023 8:25 pm
However, I've found that other applications that depend on qt5-webkit now use python-pyqt5-webengine from the extra repository. So it does not need to be built.
After making this change to the mythtv dependencies, I successfully built Mythtv and have a working FE/BE combo. I did get a warning after the ./configure run about missing QT5 headers and that some plugins might not work. However, I have not found what does not work yet.
Removing the qt5-webkit dependency has the negative effect of breaking the mythbrowser plugin. See this issue :
https://github.com/MythTV/mythtv/issues/327
User avatar
jfabernathy
Senior
Posts: 577
Joined: Wed Feb 18, 2015 2:37 pm
Location: Raleigh, NC
United States of America

Re: How to build a MythTV v32 system using EndeavourOS

Post by jfabernathy »

hamelg wrote:
Mon Jul 03, 2023 9:09 pm
jfabernathy wrote:
Sun Jan 01, 2023 8:25 pm
However, I've found that other applications that depend on qt5-webkit now use python-pyqt5-webengine from the extra repository. So it does not need to be built.
After making this change to the mythtv dependencies, I successfully built Mythtv and have a working FE/BE combo. I did get a warning after the ./configure run about missing QT5 headers and that some plugins might not work. However, I have not found what does not work yet.
Removing the qt5-webkit dependency has the negative effect of breaking the mythbrowser plugin. See this issue :
https://github.com/MythTV/mythtv/issues/327
Well, I've never heard of mythbrowser and obviously never used it. I do know that the official AUR for mythtv-git has switched away from the webkit and now use the webengine.

If I want a browser while I'm watching MythTV, I pull out my phone, tablet, or laptop.
User avatar
jfabernathy
Senior
Posts: 577
Joined: Wed Feb 18, 2015 2:37 pm
Location: Raleigh, NC
United States of America

Re: How to build a MythTV v33 system using EndeavourOS

Post by jfabernathy »

I was trying to follow my own guide to install mythtv on EOS recently when the build from source failed due to some recent changes in pip install. The latest versions of pip follow some changes that prevent users from install pip programs universally due to the system failures that could cause. See discussions everywhere about PEP 668.

This change is causing mythtv to be required to be installed via packaging. Ubuntu already has a way of doing this and mythtv can be installed on RPI4 or x86_64 using APT.

For Arch Linuix based distros like EOS there is an AUR package for x86_64. That AUR package can be modified for ARM.

When I use the AUR package I like to use "yay" so it will get all the dependencies, some of which or also an AUR package.

Code: Select all

yay -S mythtv-git --editmenu
yay will have the usually questions. On some of the packages it will tell you it's not available for aarch64 and ask if you want to try to build it anyway. Always answer yes.

When it ask which package to edit pick only "mythtv-git".

At the appropriate time it will pop up an edit window and you can edit the PKGBUILD file. For the RPI4 which is the aarch64 architecture. You need to change the following in the variable section at the start of the file:

Code: Select all

arch=('aarm64')
In the build section replace the --cpu option with the following:

Code: Select all

              --arch="$arch" \
Also replace the --enable-vaapi \ with:

Code: Select all

              --disable-vaapi \
              --disable-vdpau \
              --enable-opengl \
Save an exit and continue with the build like any AUR package. Works for me. When I need to update mythtv, I run the following:

Code: Select all

 yay -Sau mythtv-git --editmenu
and make the same edit changes.

FYI, you want to make v34 or Master, you also need to edit one line in the source section of the PKGBUILD file:

Code: Select all

    "git+https://github.com/MythTV/mythtv#branch=master"
User avatar
jfabernathy
Senior
Posts: 577
Joined: Wed Feb 18, 2015 2:37 pm
Location: Raleigh, NC
United States of America

Re: How to build a MythTV v33 system using EndeavourOS

Post by jfabernathy »

After testing the improvements I've seen in Ubuntu 23.04/10 and Raspberry Pi OS Debian 12 I rebuilt mythtv on EndeavourOS with it's latest updates.

EOS still produces the best picture with the least jitter even though all the above OS's have moved to Wayland and away from X11. EOS with KDE Wayland is a lot better than 6 months ago.

I update the original post to fix changes in the useradd command and I followed the build from the AUR using yay with the --editmenu options and not the build from source option originally posted.

My current test was with Master/v34 and I used the Web app instead of mythtv-setup to configure the backend.

The command I use to run mythfrontend is as follows:

mythfrontend --platform xcb --noupnp -O libCECEnabled=0

I created a KDE Menu application under Multimedia to launch it.
Post Reply