Raspberry Pi

From MythTV Official Wiki
Jump to: navigation, search


Overview

The Raspberry Pi is cheap and can be a decent frontend for a MythTV backend. The Raspberry Pi is a credit-card sized computer that costs around $30 barebones. Once you add a case, power supply and SD card it will run about $55. It supports HDMI output for audio and video, as well as composite video and analog stereo. When using HDMI it also supports CEC so that you can use the TV remote control to control MythTV. This is very convenient for places where you cannot have a full size computer, such as kitchen. With its case, the Raspberry Pi is about the same size as the DTA devices from cable companies.

As of version 0.28, MythTV frontend is supported on Raspberry Pi 2 and Pi 3. There is also an unofficial release of 0.27 that works on Raspberry Pi 2.

For Raspberry Pi 4 only MythTV from version 30 is supported using Raspbian Buster. A MPEG 2 licence is not required.

Mythbackend Requirements

The remote MythTV backend must be configured to accept connections over the local network.

Check using mythtv-setup on the remote MythTV backend that in

1. General->Host Address Backend Setup:
Security PIN (required) is set to 0000
Primary IP address /DNS name is set to the real IP address e.g. 192.168.7.148 and not 127.0.0.1, use the drop down to select the real IP address and then restart mythtv-backend.

Kodi is a multimedia package that has very good support for Raspberry Pi and has a plugin that supports some mythtv frontend features but is not a full replacement for the official MythTV frontend.

MythTV frontend

Operating System

The Raspberry Pi supports several Linux variants.

Raspbian

This is the original operating system for Raspberry Pi and supports all features of MythTV frontend.

For installable packages see MythTV Light.

Ubuntu

Several flavors of Ubuntu are available for Raspberry Pi.

  • Ubuntu Server
  • Xubuntu
  • Lubuntu
  • Ubuntu Mate

When using Ubuntu you can use the Mythbuntu PPA to download the latest package.

When running on Ubuntu some MythTV features do not work (these all work with Raspbian):

  • CEC does not work. You cannot use a TV remote to control MythTV.
  • OpenGL ES does not work. On-screen displays have to use softblend which can cause jerkiness in the video and audio.
  • There are reports that HDMI Audio does not work well.
  • There is a report that recent builds of MythTV do not work at all.

Arch Linux

There is a version of Arch Linux for Raspberry Pi.

Setup on Raspbian

First you need to have a MythTV backend set up on your local network. The Raspberry Pi will function as a remote frontend. It is best to use a wired connection, rather than Wi-Fi, especially if you are playing High Definition content.

Changes in recent versions of Raspbian

Versions of Raspbian dated 2018 and later have some changes that affect MythTV.

  • The "OpenMax High Quality" playback profile may suffer from jerky playback. Trying to debug with -v playback causes worse slowdowns so is not recommended. If you have jerky performance or audio breakup when not using verbose logging, switch to the "OpenMax Normal" profile. The only difference in the profiles is the presentation of the OSD display.
  • A different setup is needed for ALSA digital passthrough (Dolby digital through an external sound system). See below.
  • Analog audio may give crackles and pops. There is an easy fix for that. See below.

Frontend Setup on Raspbian

This information is built upon the current release of Rasbian & mythtv v31 (May 2020)

  1. Download & install your chosen version of Raspbian. This section will focus on the 'Raspbian Buster with desktop' release
  2. Update the OS to the latest release by sudo apt update && sudo apt -y full-upgrade. This includes the latest stable eeprom and firmware.
  3. Reboot
  4. Install the latest MythTV Light package.
  5. In the interest of minimizing overhead enter sudo raspi-config > 3 Boot Options > Desktop / CLI > select 'B2 Console Autologin'. The full GUI can be manually launched if required by running startx from terminal but typically not needed once your FE is configured.
  6. Run QT_QPA_PLATFORM=eglfs mythfrontend & configure your new Frontend.
  7. For autostarting the FE, ensure you are logged in as your intended mythtv user, crontab -e and add @reboot sleep 10 && QT_QPA_PLATFORM=eglfs mythfrontend --logpath=/tmp/. The sleep delay appears to be required as i found the FE would stutter if started too quickly. using $HOME/.profile is not recommended as this would also trigger for SSH sessions. Please note that you can't use the QT options if you are running an X server (GUI Desktop environment).
    1. If you have issues, add QT_QPA_EGLFS_ALWAYS_SET_MODE="1" before QT_QPA_PLATFORM... the full command is as follows:
      QT_QPA_EGLFS_ALWAYS_SET_MODE="1" QT_QPA_PLATFORM=eglfs mythfrontend
    2. Autostarting mythfrontend via crontab gave me problems with keystrokes being passed to the console. I solved this by removing the crontab, and adding QT_QPA_PLATFORM=eglfs mythfrontend --logpath=/tmp/ to /etc/rc.local
  8. Amend the default swappiness: sudo nano /etc/sysctl.conf and add vm.swappiness=5 to the end. This will ensure swapping will only occur after RAM usage hits 95% rather than the default value of 60 swappiness (40% ram usage).
RPi3 Specific
  1. Purchase and install an MPEG-2 License Key from the Raspberry Pi Store. Only for Raspberry 3 and prior.
  2. add your decoder licences to /boot/config.txt as per official rasbpberry documentation.
  3. Add additional GPU ram: sudo nano /boot/config.txt and add gpu_mem=256 to the end of the file. Reboot for changes to take effect.
  4. Configure an appropriate Playback profile using V4L2. See below Video Playback Profile for a working profile
  5. Setup performance mode as described in System Performance. You can, for example, add the command line to $HOME/.profile to ensure it is always run.
RPi4 Specific
  1. Configure an appropriate Playback profile using MMAL or V4L codecs. See below Video Playback Profile for a working profile
  2. gpu_mem adjustments are not required (at least for 1080p60 content) as the rpi4 has it's own video memory which is sufficient.
  3. Manually enabling Fake KMS is not required as this is enabled by default with the current 2020-02 Raspbian release. dtoverlay=vc4-fkms-v3d should already be configured&enabled in /boot/config.txt
  4. If you see glitchiness during video playback and not using the EGLFS method of running mythfrontends as indicated above, try to disable the desktop/window environment and directly start mythfrontend, see Raspberry_Pi#Running_without_a_desktop_environment_or_window_manager.
  5. Also try overclocking to get a bit more performance.
  6. Also try a 64bit Linux install such as Raspberry Pi OS BETA 64-bit for even more performance. However, you may need to Build_from_Source mythtv until 64bit binary packages are available.
Raspberry Pi5 Specific
  1. Colorspace issue on Wayland, https://github.com/MythTV/mythtv/issues/855, this affects pi4 and pi5.
Quirks, Performance and Tuning

This section contains misc notes that are environment dependant or to aid in resolving common issues.

  1. [≤ v30] if "MythTV frontend" does not appear in the menu, run the following commands: rm ~/.cache/menus/* && lxpanelctl restart
  2. [≤ v30] When using "softblend" OSD renderer or "OpenMax Normal" profile, GPU memory must be at least 128 MB. When using another OSD renderer or "OpenMax High Quality" profile, GPU memory must be set as 256 MB or more. If you have stuttering performance, try increasing the GPU memory.
  3. sudo rpi-update is only required if you need pre-release/non-stable firmware releases. Stable Firmware is included via your regular apt upgrade/full-upgrade commands.
  4. If you encounter video or audio issues you might need to experiment with different mythfrontend Setup values, and /boot/config.txt values.
  5. If you notice general stability problems (application hangs - in particular when navigating between menus or starting/stopping playback) check the settings of the MySQL server on the backend. If it's running MySQL v5.7 or newer there is an issue with query caching when using multiple clients with different versions. Jessie currently comes with MySQL client v5.5. See Optimizing_Performance#MySQL_Database_Tweaks.
  6. With V31, when exiting from mythfrontend there is normally a seg fault. This is due to a bug in QT. This leaves your keyboard in an unusable state. To get your keyboard working again, press Alt-PrtSc-R or run command "kbd_mode -u". That command cannot be run from the keyboard, but could be added to a script running mythfrontend.
  7. For information on Audio setup, see the audio section below.
  8. Jumping forward or backward might cause audio to lag or stop for a few secs, continue to jump to get audio back. The audio sync gets messed up, you might need to restart the playback to get the audio to sync again. I don't know of a workaround.
  9. Still having problems, use the MythTV forum.

Video Playback Profile

For v31 & newer a change of playback profile is required. In mythfrontend, goto Setup > Video > Playback

  1. create new playback profile
  2. add entries as appropriate for below table

The below table is targeted at UK broadcast material which is progressive (576p) for all content except 1080 which is interlaced (1080i)

Playback Profile - v31 onwards
Rpi3 Rpi4
Tested to 1080p60
Width Range
Height Range
Video Formats
Frame Rate Range
Decoder V4L2 (Decode Only) MMAL (Decode Only)
Max CPUs 4 4
Deblocking Filter
Video Renderer OpenGL YV12 OpenGL YV12
Deinterlacer Quality (SR) Medium Medium
Prefer OpenGL Deinterlacer
Prefer Driver Deinterlacer
Deinterlacer Quality (DR) None Medium
Prefer OpenGL Deinterlacer
Prefer Driver Deinterlacer


Audio

On Raspberry Pi, ALSA and OpenMax are supported audio output renderers. ALSA supports stereo output through either analog or HDMI devices, as well as digital pass through of AC3 to a suitable receiver system. OpenMAX also supports both analog and HDMI devices, but audio / video synchronization does not work well with OpenMax Audio..

ALSA Audio

For stereo output, set the Audio device to "ALSA:default" to use the default output device. The default device is determined at boot time, or can be forced using the raspi-config utility. Alternatively select a specific ALSA device from the list. Make sure to select speakers as "Stereo". If you want to select Dolby Digital or DTS options follow the process described below in Digital Audio with ALSA.

If there is a hiss from the speakers, add this line to the /boot/config.txt:

disable_audio_dither=1

To enable the MythTV volume control, set "Mixer Device" to "ALSA:default" and mixer controls to "PCM".

Low volume from 3.5mm jack

If you are using an analog TV or one without HDMI audio, you can use the analog audio from the 3.5mm jack on the Raspberry Pi. On digital channels this may give a low sound volume through a TV set. You can get good results with a software pre-amplifier.

Create file .asoundrc in your home directory. Paste the content from here:

~/.asoundrc
pcm.!default {
	type hw
	card 0
}

ctl.!default {
	type hw
	card 0
}


# Set your DEFAULT device to the softvol plug-in
# NOT to a hardware card device
#
# The "!" means completely override the previous default
# Not just changing/adding to it.
pcm.!default {
  type plug
  slave.pcm "softvol"
}

# Configure softvol
pcm.softvol {
  type softvol

  # Send softvol's output to dmix
  slave {
    # pcm "dmix"
    # If you wanted to you could send the output to a card directly
    # But in most cases it's better to send it to dmix and let
    # dmix handle where to send it. You can add a whole extra section
    # to configure dmix and where it sends output, but I'm
    # not covering that here.

    ## Use Card 0 Device 0 instead of dmix
    pcm "hw:0,0"
    ## Use Card 2 Device 0 instead of dmix
    # pcm "hw:2,0"
  }

  # Add a control slider in your mixer interfaces
  # i.e. KMix and alsamixer
  control {
    name "Pre-Amp"
    card 0
    # i.e. card 0 or card 2
  }

  # Minimum dB when slider is at 0%
  min_dB -5.0

  # Maximum DB when slider is at 100%
  # 40 is too much
  max_dB 10.0

  # How many levels the slider should go through
  # i.e. how granular do you want your control to be
  resolution 12
}

Select ALSA:default as your sound device (you may have to key it in if it is not in the list)

Add these to your .profile or somewhere where they will run before you start the frontend:

amixer set PCM Playback 100%
amixer set Pre-Amp Playback  9

You can adjust the values as needed. You can also run alsamixer to see and adjust the pre-amplification.

Loud crackles and pops from 3.5mm jack

Versions of Raspbian from sometime in 2018 and later have a new improved audio driver. For whatever reason, it causes lots of loud crackles and pops in tha analog audio and gives no improvement. Fortunately it can be disabled. If you are experiencing loud crackles and pops add the following line to /boot/config.txt:

audio_pwm_mode=1

For information on the "improved" audio driver see https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=195178.

Digital Audio with ALSA

On Raspbian, ALSA audio performs better than OpenMax for AC3 & DTS 5.1 passthrough via HDMI. The latest version of Raspbian includes a device called ALSA:IEC958 if you are using hdmi audio. You can select this and setup digital audio as you would with any Linux system. On older versions of Raspbian or if the IEC958 device is not created you will need to define a new ALSA device, as follows. Paste the following into file $HOME/.asoundrc:

$HOME/.asoundrc
pcm.mythtv {
        @args [ CARD AES0 AES1 AES2 AES3 ]
        @args.CARD {
                type string
        }
        @args.AES0 {
                type integer
        }
        @args.AES1 {
                type integer
        }
        @args.AES2 {
                type integer
        }
        @args.AES3 {
                type integer
        }
        type hooks
        slave.pcm {
                type hw
                card "0"
                device 1
        }
        hooks.0 {
                type ctl_elems
                hook_args [
                        {
                                interface PCM
                                name "IEC958 Playback Default"
                                lock true
                                preserve true
                                value [ $AES0 $AES1 $AES2 $AES3 ]
                        }
                ]
        }
}

You can check the device availability using aplay -L. you should see a device listed as mythtv:CARD=ALSA.

Start MythTV, navigate to Setup->Audio and select ALSA:mythtv:CARD=ALSA from the list of available devices. Select AC3 / DTS as appropriate for your amplifier / TV and test to ensure passthrough is working as expected. No mixer is required and you may select either Stereo or 5.1 speakers, both should work.

This setup works with stereo output as well as surround sound passthrough, so this new device can be used instead of the ALAS:default even in cases where you have no digital surround system. In that case do not select AC3 or DTS in MythTV setup.

These are the old instructions pre-2018
sudo nano /usr/share/alsa/cards/bcm2835.conf

Paste the content from here:

#
# Configuration for the bcm2835 soc found on RPi
#

<confdir:pcm/iec958.conf>

bcm2835.pcm.iec958.0 {
	@args [ CARD AES0 AES1 AES2 AES3 ]
	@args.CARD {
		type string
	}
	@args.AES0 {
		type integer
	}
	@args.AES1 {
		type integer
	}
	@args.AES2 {
		type integer
	}
	@args.AES3 {
		type integer
	}
	type hooks
	slave.pcm {
		type hw
		card $CARD
		device 1
	}
	hooks.0 {
		type ctl_elems
		hook_args [
			{
				interface PCM
				name "IEC958 Playback Default"
				lock true
				preserve true
				value [ $AES0 $AES1 $AES2 $AES3 ]
			}
		]
	}
}

With this file you will select the new ALSA IEC958 device. This does not work with 2018 versions of Raspbian

OpenMAX Audio (not recommended)

With OpenMAX audio, the audio selection in raspi-config is not used. In MythTV frontend setup you can select OpenMAX analog or hdmi. If you select hdmi you can select digital options. See Digital Audio below. Digital Audio works better with ALSA.

When using OpenMAX audio, set "Mixer Device" to "OpenMAX" and mixer controls to "PCM".

If you hear no audio after selecting OpenMAX, check the volume control setting. Sometimes when switching audio devices the system defaults to zero volume. Unfortunately, it appears to reset the audio to zero every time you start a playback, so you may have to do this every time.

Digital Audio

Digital passthrough of Dolby Digital (AC3) and DTS can be selected when using ALSA:mythtv with the .asoundrc file listed above(see Digital Audio with ALSA), or with OpenMAX:hdmi (not recommended) selected. The custom .asoundrc file may not needed if you can rescan and select ALSA:*:CARD=*, example ALSA:sysdefault:CARD=vc4hdmi0. Also the speaker test doesn't seem to work even though digital audio is enabled, play a recording that has digital audio as your test instead.

  • Dolby Digital can be selected. This enables pass through of Dolby Digital audio to your TV or surround sound receiver. You need either a surround sound receiver or a TOSLINK output from your TV to pass the Dolby digital through to your surround sound system.
  • 5.1 or 7.1 speakers can be selected. If you do not select Dolby Digital, the system will use multi-channel PCM. You need a surround sound receiver that has HDMI input and supports multi channel PCM. Note that TOSLINK does not support multi-channel PCM.

When selecting Dolby Digital, if you select 5.1 or 7.1 channels, you may also have situations where MythTV uses multi-channel PCM. This happens if MythTV is doing any audio processing, for example software volume control or sound stretch. If you select Dolby Digital and are using TV speakers or using a cable from your TV to your surround system, you should select stereo speakers, even if you have 5.1 or 7.2 speakers. Dolby Digital surround sound will still be passed through to all of your speakers by your sound system.

In the audio setup the "Speaker Test" will only work on left and right speakers unless you have a surround sound receiver that has HDMI input and supports multi-channel PCM.

System Performance

To provide adequate system performance for smooth audio and video try these steps. Playing smooth video requires the full capacity of the Raspberry Pi, and getting the best results for your situation calls for finding the right combination of settings.

  1. Make sure you are using an OpenMAX Video Playback profile. Others, such as Normal or Slim will give very poor results.
  2. Set the Raspberry Pi into performance mode as follows:
    echo "performance" |sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
    This needs to be run after each reboot.
  3. If you are using a Raspberry Pi 2, overclock using the setting in raspi-config. Use setting High (High 1000MHz ARM, 500MHz core, 500MHz SDRAM, 2 overvolt). This will not damage your RPI2 or void the warranty.
  4. Use ALSA:Default or ALSA:mythtv as described above for audio rather than OpenMAX.
  5. If OpenMAX High Quality results in jerky audio or video, select OpenMAX Normal.
  6. Some releases of Raspbian include pulseaudio. Disable pulseaudio as follows. Edit /etc/pulse/client.conf. Uncomment the line autospawn=yes and replace the yes with a "no".
  7. Increase the GPU memory. If you are using features like HD, Digital Audio, OpenMAX High Quality it may be necessary to go up to 320MB. Higher screen resolutions need more GPU memory.
  8. Avoid the "-v playback" command line option. This causes jerky playback.

Subtitles

When displaying subtitles you may find that the video or audio becomes jerky. This is more likely with Raspberry Pi 2 than with Pi 3. If that happens go to Setup->Video->Playback->Playback Profiles (3/8) -> Edit. Change Osd Renderer to "threaded". This will cause a slower response to keyboard events but will give smoother audio and video with subtitles.

When playing recordings from USA TV you may find that subtitles are not available. To see the subtitles, edit the /boot/config.txt file and comment or remove the MPEG2 license, reboot. This may result in Jerky video with Raspberry Pi 2, but works well with Raspberry Pi 3. When running without an MPEG2 license on Raspberry Pi 2, set Osd renderer to softblend for least jerkiness.

On Screen Display

There are three OSD renderers available. Here are results of testing the various scenarios of on screen display renderers.

With MPEG2 license

With USA TV recordings you may not see any subtitles.

OSD Render When OSD is displayed Keyboard When Subtitle Displayed
Audio Video Audio Video
PI2 softblend Slight Jerk Jerky OK Smooth Jerky
PI2 opengl Smooth Smooth OK Smooth Jerky
PI2 threaded Smooth Smooth SLOW Smooth Smooth
PI3 softblend Smooth Smooth OK Smooth Smooth
PI3 opengl Smooth Smooth OK Smooth Slight Jerk
PI3 threaded Smooth Smooth SLOW Smooth Smooth
Without MPEG2 license

This may be used to support subtitles for USA TV, or just because you don't want to spend $2.50.

OSD Render When OSD is displayed Keyboard When Subtitle Displayed
Audio Video Audio Video
PI2 softblend Jerky Jerky OK Jerky Jerky
PI2 opengl Jerky(*) Jerky(*) OK Jerky Jerky
PI2 threaded Jerky(*) Jerky(*) SLOW Jerky Jerky
PI3 softblend Smooth Smooth OK Smooth Smooth
PI3 opengl Smooth Smooth OK Smooth Smooth
PI3 threaded Smooth Smooth SLOW Smooth Smooth

(*) - Jerky even without OSD display

Time Stretch

The 'Time Stretch' feature of MythTV allows for speeding or slowing playback of video and audio in a range from 0.5x to 2.0x.

The Raspberry Pi 2 and 3 have limited processing power. Slowdown will work for all values down to 0.5x. Speedup will work up to around 1.3 or up to 2.0 depending on the content and your setup.

The limiting factor on increasing speed is the video decoding. With 1080i at 30fps or 720p at 60fps the speedup can go up to around 1.3. Trying to go higher causes jerkiness and slowdown. With 720p at 30fps or 480p, speedup works fine up to 2.0x.

If you need to speed up HD content beyond what works you can first transcode to 720p or less at 30fps or less.

Remote Control with CEC

The Raspberry Pi supports CEC, so you can use your existing TV remote to control the MythTV frontend. If you connect to a CEC compatible Television set, you can use the TV remote control to control the Raspberry Pi. You will find that if the TV remote has play, stop, pause controls, that these can be used. Unfortunately many TVs which support CEC do not support the numeric keys.

To test and configure CEC, start up the MythTV frontend and navigate to Setup->Edit Keys. find any key and select a blank box at the bottom. Press enter. It will prompt you to type a key. Press keys on your remote until one shows a response. Press escape when asked whether to assign it. This way you can see which keys are available. Now you can navigate in the Edit Keys and assign your remote keys. With Global Select, up, down. left, right you can control most of MythTV. Additional buttons can be set to Menu, Information, Play, etc.

MythTV version 30 includes options in Mythfrontend setup to set all of the options mentioned below, instead of using the command line.

If you are using a TV or display monitor that does not support CEC, the CEC feature of MythTV may cause the start of mythfrontend to be slow as it retries CEC. In that case you can disable CEC by adding this parameter to the mythfrontend startup command:

-O libCECEnabled=0

mythfrontend uses CEC to turn your TV on when it starts up and to turn it off after mythfrontend exits. To prevent it from turning off your TV when the frontend exists, add this parameter to the mythfrontend startup command:

-O PowerOffTVOnExit=0

The following other settings are available and can be set this way:

-O PowerOffTVAllowed=0
-O PowerOnTVAllowed=0
-O PowerOnTVOnStart=0

Autostart mythfrontend on the GUI Desktop

Put a file in ~/.config/autostart/

Name the file mythtv.desktop with the following contents (3 lines):

[Desktop Entry]
Type=Application
Exec=/usr/bin/mythfrontend --logpath /tmp

You can also start MythTV using cron when not running the GUI/Desktop/X server. See the instructions above. Other methods of autostarting, see this link.

Autostart MythTV on boot

I use the following script to start MythTV automatically on boot:

#!/bin/bash
#
# Run MythTV Frontend on Raspberry Pi 2 on Boot
#

# use "performance" mode to prevent the Pi from going into "power saving" mode
# where it slows down the CPU, and causing problems playing HD
echo performance | sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

# Use your MythTV Backend values here.
IPADDR=xxx.xxx.xxx.xxx
MACADDR=xx:xx:xx:xx:xx:xx

# Waits
WAITIP=7
WAITBACKEND=40

# Wake up MythTV Backend if not responding
ping -c 2 $IPADDR
if [ $? -ne 0 ]; then
  wakeonlan $MACADDR
  echo "Waiting $WAITBACKEND seconds for MythTV Backend to boot..."
  sleep $WAITBACKEND
fi

sudo ntpdate-debian

# Run mythfrontend
logrotate --state /home/pi/log/logrotate.state /home/pi/log/logrotate.conf
mythfrontend --logpath /home/pi/log

You can then call the above script from

~/.config/lxsession/LXDE/autostart

or

~/.config/lxsession/LXDE-pi/autostart

to autostart MythTV.

Running without a desktop environment or window manager

Info from Doug Larrick[1]

0. Please note that this is an alternative to simply running mythfrontend from the Linux commandline using EGLFS without an X server, see section Frontend Setup on Raspian.

1. Install 'matchbox-window-manager' package. This is a very lightweight window manager. Running a window manager is optional, you can simply launch mythfrontend from your .xsession without a window manager.

2. Set up to autologin to the pi account on boot in /etc/lightdm/lightdm.conf

3. Create a small script to restart mythfrontend if it exits; mine is in file /home/pi/bin/mythloop (must be set executable):

   #!/bin/bash
   while true; do
   mythfrontend
   sleep 3
   done

4. Create ~/.xsession file as follows:

   #!/bin/sh
   /home/pi/bin/mythloop &
   exec matchbox-window-manager #optional, if omitted, don't background mythloop.

5. If you experience a garbled screen, you may need to start the compositor before launching mythfrontend, add to your .xsession:

   /usr/lib/raspi-config/cmstart.sh &

Finally, once this is done and working, ssh into the Pi, run 'top' and sort by memory / cpu, and deconfigure or uninstall stuff that's consuming a significant amount of either.

Setup on Ubuntu

The same process as for Raspbian works with Ubuntu, with a few differences.

Audio

Use the Setup, Audio to select your audio device. On Ubuntu, PulseAudio is available and selecting PulseAudio:default works better than Alsa:default in this system. You may need to try different selections to find what is best in your environment.

CEC

In Ubuntu, MythTV seems to be unable to find the CEC device. This is an outstanding issue for which we do not have a solution yet.

Video Playback Profile

The "OpenMax High Quality" profile and the OpenGL based OSD display do not work on Ubuntu, so you will have only the "OpenMax Normal" features available.

Installing MythTV Backend and Frontend on a Raspberry Pi 4 With Ubuntu 23.04

Example steps are below for installing MythTV v33.1 on a Raspberry Pi 4 using an HDHomeRun tuner and SchedulesDirect.

You can use Raspberry Pi Imager v1.7.4 or higher and under "Choose OS", select "Other general-purpose OS" -> Ubuntu -> Ubuntu Desktop 23.04 (64-bit). The Imager program will download and flash the OS to your Storage device. Since you are going to need a lot of GBs to record TV, I'd say use a big SATA SSD with a USB3 to SATA adapter.

Plug in the SSD to the RPI4 and boot. The setup and update of Ubuntu is slow and not a good sign but after the upgrade it seems to be very responsive.

If your internet connection is via your RJ45 Ethernet, plug your HDHomerun tuner into your router.

If your internet connection is via your WiFi you can use your RJ45 Ethernet port to directly connect your HDHomerun tuner. If you use this method you will need to use the Network Settings to edit your Ethernet as follows:

In the IPv4 tab:

Set Method to Local-link only, and check the box for "Require IPv4 addressing for this connection to complete."

In the IPv6:

Set the Method to Disabled

When you install MythTV it will create a user account for 'mythtv'. If you want more control over this you can create it ahead of installation. Ubuntu has been known to change the default options of the adduser command between releases, so the following commands are used:

sudo addgroup --gid 200 mythtv
sudo adduser --ingroup mythtv --home /home/mythtv --shell /bin/bash --uid 200 mythtv

Also if you want to use mariadb instead of mysql this is the time to make that choice. To use mariadb do the following:

sudo apt install mariadb-server

Next add the MythTV PPA to your list of repositories.

sudo add-apt-repository ppa:mythbuntu/33

Then install MythTV with:

sudo apt install mythtv

The first run of mythtv-setup will add your user ($USER) to the 'mythtv' group.

So now run:

mythtv-setup

It will ask your permission to setup your user as a member of the mythtv group. Once this is done, just reboot to guarantee that your user is now in the mythtv group.

You'll need to setup your mythtv directories before completing setup. Here's a script to use /srv/mythtv as the storage area. Save this as create_directories.sh and make executable:

#! /bin/bash

# Globals
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 sports screenshots trailers music musicart" 

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 

}

#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 - please install MythTV-Light package"
    echo -e "For official builds (when available) 'https://www.mythtv.org/wiki/MythTV_Light'\n"
    echo -e "For test builds 'https://forum.mythtv.org/viewtopic.php?f=46&t=3221&start=15'\n"
    exit 1
fi

fn_setup_directories

exit 0

If you want to setup an EPG provider, do that now or just use EIT Video Source in mythtv-setup.

SchedulesDirect can be used via tv_grab_zz_sdjson_sqlite. XMLTV can be installed by:

sudo apt install xmltv

Then, the instructions on the XMLTV wiki page can be used. BUT make sure to run them as user "mythtv" by:

sudo su mythtv
cd

Exit back to your normal user and complete mythtv-setup.

mythtv-setup

At this point you can test this out by restarting the backend with:

sudo systemctl restart mythtv-backend.service

Then you can test out "mythfrontend." 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:

sudo --login systemctl edit mythtv-backend.service

Add or adjust the override file to include:

[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 hdhomerun_check.py in /usr/local/bin and make it executable, owner/group root.

At this point you should be able to boot the RPI4 and mythtv-backend.service should start and find the HDHR tuner. You can run mythfrontend as on any system and configure it for the RPI4 as has been documented elsewhere on the wiki and forum.

Additional optional steps can be found on the forum post at https://forum.mythtv.org/viewtopic.php?f=46&t=5409 by Jim A.

Kodi

Kodi is a multimedia package that has a MythTV plugin. Kodi and the plugin are not part of MythTV. They are a separate installable package. There are packages available that install a customized copy of Linux with the Kodi program.

Compatible With

The Openelec MythTV frontend currently states that it is compatible up to MythTv 0.28 and as it needs the API, then 0.27 is the minimum (Gerdesj (talk) 21:55, 30 August 2015 (UTC))

How to make it work

The steps you have to do are:

  • Install MythTV backend (0.27+) on a separate computer on your LAN.
    • Make sure you set a PIN for the API or set it to 0000
  • Install OpenElec or libreELEC to your Raspberry Pi.
    • Find (scroll down the list) and download the image file
    • Write the image to the SD card
    • On first boot Openelec will resize partitions
    • Run through the first run wizard to set host name etc
  • From within the XBMC/Kodi menu set up the PVR client to point to your MythTV backend.

Normal video playback runs smoothly. Menu navigation and TV program can be a bit laggy. One trick to increase Raspberry PI performance is to overclock the CPU/GPU. On the PI 2 this is unnecessary.

This is a good guide to enabling the PVR (MythTV) front end: kodi.wiki/view/MythTV_PVR#Connecting_Kodi_to_MythTV. Note that you must set a PIN on the backend or set it to 0000. If you don't use 0000 you will need to use the PIN to connect to the backend. The PIN is set in the General section of mythtv-setup.

Finding the plugin can be a bit challenging. On Openelec it is already installed but listed in the "disabled" plugins until you enable it.

More Information

You can purchase an MPEG2 hardware decoder license for Raspberry Pi 3 and earlier. Depending on your tuner this may help your recordings play. I have been able to play 1080p live TV from a DVBS2 connected backend on a PI 2 model B running current Openelec out of the box with no additional licenses or over clocking (Gerdesj (talk) 21:55, 30 August 2015 (UTC))

Other Links

  • Tarball by Curtis Gedak
 Built upon Raspbian Jessie for MythTV 0.27 using QT 5.4.0.  Supports
 both XCB (OpenMAX Normal) and EGLFS (OpenMax EGLFS).
See Mythfrontend Setup Tutorial (with MCE Remote Control).
  • MicroSD Image by Piotr Oniszczuk
 Built upon ArchLinux for MythTV 29 using QT 5.10.1 (recompiled so both: x11-xcb and EGLFS drawing methods are working)
More details are located on the MythtTV Offical Forums under the Platforms/Raspberry PI/Updated MiniMyth2 Rpi edition topic.
  • Raspberry Pi 4 MythTV installation walkthru by Jim A.

These builds work with High Definition (HD) 720p and 1080i content on a Raspberry Pi 2 Model B or better. There have been reports that earlier Raspberry Pi models might work with Standard Definition (SD) content and a lower gpu_mem setting.