Setting Up an Inexpensive Raspberry Pi 2 as a Cheap Frontend to MythTV with MythFrontend
Summary
This tutorial describes the hardware required and the steps involved to install a pre-built version of the MythFrontend on a Raspberry Pi 2 model B computer. At completion of the steps you will be able to watch recordings from your MythTV Backend on a television connected to the Raspberry Pi 2 computer.
These steps were documented using a Raspberry Pi 2 model B computer with a MythBackend server configured with Mythbuntu 14.04 which uses MythTV 0.27. A faster and compatible Raspberry Pi 3 model B is available.
Update 2017-06-22: Add note indicating advanced hardware deinterlacing only working on Raspian versions up to 2016-05-27.
Update 2017-02-24: Note that the MythFrontend version number (e.g., 0.27.x) must match the MythBackend version number in order to work correctly. This tutorial works for MythTV 0.27.x. If your MythBackend is 0.28.x or higher then see also MythTV.org - Raspberry Pi.
Contents
- Background
- Using Raspberry Pi 2 with MythFrontend
- Hardware Component List
- Raspberry Pi 2 MythFrontend Set Up Steps
- A. Configure MythTV Backend to Support Remote Frontends
- B. Download and Uncompress Raspbian to microSD Card
- C. Boot Up Raspberry Pi 2
- D. Configure Raspbian
- E. Enable MPEG-2 Hardware Video Decoding
- F. Configure Sound
- G. Download MythTV Build and Transfer to RPi
- H. Install a Build of MythFrontend
- I. Configure MythFrontend via SSH
- J. Set Up lirc for MCE Remote Control
- K. Further Configure Mythfrontend
- L. Set MythFrontend to Auto-start on Boot
- Troubleshooting Audio and Video
- Conclusion
- References
Background
There are a number of x86 based computers that can be used as frontends to a MythTV Backend. However since these cost significantly more than a Raspberry Pi 2 (RPi2) computer, I decided to try out an RPi2.
Two commonly used options to access recordings on a MythTV backend are:
- MythTV Frontend
- Kodi Media Center
This tutorial will focus on using a Raspberry Pi 2 with MythFrontend. In another tutorial I covered using Kodi media center.
The MythTV recordings used in testing were 1080i and 720p MPEG-2 ATSC Over-The-Air TV shows recorded in Canada. The focus was on watching recordings, and not on other MythTV plugins. Test results follow:
Pros
- Recordings playback with smooth video and clear stereo sound.
- On Screen Display (OSD) works well if fade is disabled.
- Fast forward, rewind and commercial skip work well, though not quite as quickly as with my Intel Core i5 2500K MythTV combined Backend and Frontend.
- RPi2 has low power requirements (less than 10 watts).
- Playback worked well with HDMI to an LG 42" 16:9 LCD TV, and also with composite 4:3 video.
Cons
- North American ATSC recordings with closed caption subtitles do not display the subtitles with the OpenMAX EGLFS video playback profile. Subtitles do work with OpenGL High Quality video playback profile but there is occasional pixelation in the video playback.
- On Screen Display (OSD) disrupts audio if fade enabled.
- Menu navigation sometimes shows temporary "blocking" around text, noticeable when moving between different recordings when a TV show background is displayed.
- With a 1680x1050 (non-standard HD) LCD monitor the edges of the video image are not visible on the screen. With HD LCD TVs I was able to work around this issue using config.txt parameters. See Troubleshooting Audio and Video.
- Sometimes mytfrontend fails to exit and shutdown. Instead the mythfrontend main menu is left on the screen, a connection is left open to mythbackend, and the RPi does not fully shutdown.
Figure 1: Mythfrontend running on Raspberry Pi 2 (lower right)
Overall I found watching recordings using the Raspberry Pi 2 computer to be an enjoyable experience. :-)
NOTE: If any of these limitations are deal breakers for you, then you might want to consider spending more to purchase a low end x86 or x86-64 based computer with either integrated Intel HD Graphics or discrete NVidia Graphics.
Using Raspberry Pi 2 with MythFrontend
The steps in this tutorial set up a Raspberry Pi 2 computer with MythFrontend so that recordings can be viewed using the following sequence:
User Actions Automatic Actions
+-----------+ +----------+
| | | |
(1) Power on ----> | Raspberry | -> (2) Wake up | MythTV |
| Pi 2 | message sent -> | Backend |
| Computer | | Computer |
| | -> (3) Frontend | |
| MythTV | connects | |
| Frontend | to Backend ---> | |
| | | |
(4) Watch shows -> | | --> show requested --> | |
| | | |
| | <-- show data sent <-- | |
| | | |
(5) Exit with | | | |
Shutdown ---> | | -> (6) Frontend | |
| | disconnects --> | |
| | | |
(7) Power off ---> | | Backend can | |
| | power down | |
| | if idle -> | |
+-----------+ +----------+
Hardware Component List
Following is a list of components and their costs in January 2016.
Category | Component | Cost |
---|---|---|
Computer |
Raspberry
Pi 2 Model B (900MHz quad-core ARM CPU with 1 GB RAM) Note: a faster Raspberry Pi 3 Model B is available |
45 |
Case | Vilros Clear Plastic Case | 10 |
Power Supply | USB Power Supply (2000 mA) with Micro USB Cable | 10 |
Storage | Kingston 8 GB microSDHC Card (Class 10) with SD Adapter | 5 |
Remote Control | Rosewill RRC-126 MCE Remote Control | 30 |
Grand Total | $ 100 |
Note that you will also need an Ethernet cable, and either an HDMI cable or a 3.5mm to RCA composite audio/video cable. You might also desire a USB keyboard and mouse though this is not required.
Raspberry Pi 2 MythFrontend Set Up Steps
First, a huge Thank You to Lawrence Rust for his work to get MythFrontend working on the Raspberry Pi 2 computer.
These steps were gathered starting with Lawrence Rust's mythtv_for_rpi.txt document and by following the MythTV Raspberry Pi2 frontend testers mailing list thread posted on Nov. 17, 2015. My first setup used Lawrence's mythtv-v0.27.5-115-g00c0993-RPI2-jessie.tar.bz2 file dated December 23, 2015.
Second, a big Thank You to Peter Bennett for his work to further improve MythTV support. Peter has fixed several issues, and also provides MythTV Light debian packages for the MythTV 0.27.x and 0.28.x series.
My contribution is to compile Peter's raspi/0.27 git branch with Lawrence's mythtv_for_rpi.txt build process. The resulting tarball includes the MythTV suite with plugins, and adds EGLFS mode to the base XCB mode.
Why would you consider EGLFS mode?
Because EGFLS mode enables rock-steady On Screen Display (OSD) when
used with an openmax decoder and an opengl2 OSD renderer.
The steps are written so that you do not require a USB keyboard/mouse connected to the RPi computer, and can instead later use just an MCE remote control. Of course feel free to use a keyboard connected to your RPi. The steps indicate when commands can be issued directly on the RPi or via an SSH connection.
Note that this tutorial installs a pre-compiled build of MythTV for RPi. Building from source code is not covered.
A. Configure MythTV Backend to Support Remote Frontends
If you have not already done so, follow the steps in Configuring MythTV Backend for Remote MythTV Frontends.
In the above link we make note of, and will later need, the following information from the MythTV Backend computer:
- IP Address
- Ethernet Address also known as MAC address
- MySQL DB Password for mythtv database user
In this tutorial we will use the following values:
IP Address: 192.168.1.55
Ethernet Address: 00:0b:0e:0f:00:ed
MySQL DB Password: <mythtvpassword>
Be sure to use the values for your MythTV Backend computer.
B. Download and Uncompress Raspbian to microSD Card
-
Download full Raspbian Jessie disk image for Raspberry Pi.
Download ##-##-##-raspbian-jessie.zip.
Note that any full Raspbian Jessie image should work. When I wrote this tutorial I used 2016-02-09-raspbian-jessie.zip.
Update 2017-04-11: Recently I tried 2017-03-02-raspbian-jessie.zip on both a RPi2 and a RPi3. I discovered changes such as SSH being disabled by default, and pulse audio being used instead of alsa audio. I also found that display of 1080i (interlaced) content exhibited some jaggy lines. A workaround is to set the Primary deinterlacer to "Line double (HW)" instead of "Advanced (HW)". I have accounted for these changes in later notes.
Update 2017-04-13: Overall, in my opinion, watching MythTV recordings using the older 2016-02-09-raspbian-jessie.zip image has provided the best viewing experience on both RPi2 and RPi3. Since this image was released before the RPi3 was available, I think the only drawback is that it does not provide support for WiFi or Bluetooth.
Update 2017-06-22: Recently I read that advanced hardware deinterlacing works on Raspbian Jessie versions up to 2016-05-17 for those wishing to use a more recent version than 2016-02-09. Various versions of Raspbian can be downloaded from http://downloads.raspberrypi.org/raspbian/images/.
-
Insert the MicroSD card into your computer.
-
Determine the /dev/device path.
The device path is usually something like /dev/mmcblk0 or /dev/sdb.
dmesg | tail
Example output:
$ dmesg | tail [ 227.218363] sdhci-pci 0000:01:00.2: PCI INT A -> GSI 16 (level, low) -> IRQ 16 [ 227.218396] sdhci-pci 0000:01:00.2: Refusing to bind to secondary interface. [ 227.218413] sdhci-pci 0000:01:00.2: PCI INT A disabled [ 227.218884] jmb38x_ms 0000:01:00.3: enabling device (0000 -> 0002) [ 227.218906] jmb38x_ms 0000:01:00.3: PCI INT A -> GSI 16 (level, low) -> IRQ 16 [ 227.218931] jmb38x_ms 0000:01:00.3: setting latency timer to 64 [ 227.617315] mmc1: new SDHC card at address 0001 [ 227.617720] mmcblk1: mmc1:0001 SD8GB 7.32 GiB [ 227.621661] mmcblk1: p1 p2 [ 228.753036] EXT4-fs (mmcblk1p2): mounted filesystem with ordered data mode. Opts: (null)
From above output the device is /dev/mmcblk1 (we ignore the partition portion p2).
WARNING: It is very important to identify the correct device. Use of the wrong device path can result in loss of data and/or the operating system.
-
Ensure that the device is unmounted by checking the output from df to see if the device is in use.
Example output:
$ df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 6734812 5612328 780368 88% / udev 499152 4 499148 1% /dev none 506428 8 506420 1% /tmp tmpfs 101288 844 100444 1% /run none 5120 0 5120 0% /run/lock none 506428 72 506356 1% /run/shm none 506428 572 505856 1% /var/log none 506428 0 506428 0% /var/tmp /dev/mmcblk0p1 15615056 1183088 14431968 8% /media/mmcard16gb /dev/mmcblk1p1 261868 111280 150588 43% /media/0F39-638F /dev/mmcblk1p2 7177771 83036 7094735 2% /media/0c0676d8-24f7-43c4-8bed-d19e6ea3a147
If the device is in use then unmount each mount point.
Using the example above we unmount two locations from mmcblk1:
sudo umount /media/0F39-638F sudo umount /media/0c0676d8-24f7-43c4-8bed-d19e6ea3a147
-
Write the image to the Micro SD Card.
Be sure to use the correctly identified device! In this example the device path is /dev/mmcblk1.
unzip -p *-raspbian-jessie.zip | sudo dd of=/dev/mmcblk1 bs=4M sync
-
Remove the Micro SD Card.
C. Boot Up Raspberry Pi 2
-
Insert microSD card containing Raspbian Jessie into the RPi.
-
Power up / boot RPi.
With the default configuration, the RPi will boot to a graphical desktop.
-
Determine the IP address of the RPi.
There are many ways to determine the IP address of the RPi:
- With RPi keyboard connected, open a terminal window and run ifconfig eth0.
- Install and run Network Scanner on Android and look-up raspberrypi.home entry.
- Use trial and error to successfully connect to RPi using ssh pi@IPAddress substituting IP addresses in the range dynamically assigned by your router until you can login with password raspberry.
In this tutorial we will use 192.168.1.69 as the IP address for the RPi. Be sure to use the IP Address that you discover.
D. Configure Raspbian
Perform steps with either an RPi connected keyboard and a terminal window, or an SSH session (for example ssh pi@192.168.1.69 and provide password raspberry).
NOTE: Newer Versions of Raspbian disable SSH and enable pulse-audio by Default. |
-
Either:
A. Open a terminal window using a keyboard/mouse connected to the RPi.
Or:
B. Open a terminal window on a different GNU/Linux computer and make a secure shell connection to the IP address of your Raspberry Pi 2.
Be sure to use the IP address for your RPi on your network.
ssh pi@192.168.1.69
The password is raspberry all lowercase.
-
Use raspi-config to configure Raspian.
sudo raspi-config
Change the following settings:
1. Expand Filesystem # In newer Raspbian found under: # 7. Advanced Options # A1 Expand Filesystem 3. Boot Options B2 Console Autologin # If GUI needed use startx 5. Internationalisation Options # In newer Raspbian found under: # 4. Localisation Options I1 Change Locale en_CA.UTF-8 # Use your locale I2 Change timezone America - Edmonton # Use your timezone I3 Change Keyboard Layout Generic 105-key (Intl) PC # Use your keyboard English (US) # To fix tilde ~ key Right Alt (AltGr) No compose key Yes - Ctrl+Alt+BS to terminate X server 9. Advanced Options A3 Memory Split gpu_mem=256 A9 Audio 0 Auto # Pick only one of 1 Force 3.5mm ('headphone') jack # these options 2 Force HDMI # as appropriate.
Choose Finish and Yes to reboot.
E. Enable MPEG-2 Hardware Video Decoding
If you have not already done so, purchase an MPEG-2 license key from the Raspberry Pi Store. Cost is ~2 British Pounds. The license key will be sent to the email address you provide (can take up to 72 hours).
Note that a VC-1 license key is also available, but it is not needed to view North American Over-The-Air content which is in MPEG-2 format.
-
Edit the /boot/config.txt file to add the MPEG-2 license key.
sudo nano /boot/config.txt
Append the decode_MPG2 line at the end of the file, substituting your MPEG-2 license key.
----- begin MPEG-2 license line -----
decode_MPG2=0x8ff5a5c7
----- end MPEG-2 license line -----
If you wish to share a microSD card image with multiple RPis then you can string together a maximum of 8 licenses. For example:
decode_MPG2=0x8ff5a5c7,0xd4cb22af,0xe05b40bc,0xa54335b8
-
Save file and exit the editor with Ctrl+X.
-
Reboot the Raspberry Pi. This will close the SSH session.
sudo reboot
If you wish you can check if the MPEG-2 decoder is enabled via an SSH connection with the following command:
vcgencmd codec_enabled MPG2
The MPEG-2 hardware video decoder should now be enabled.
F. Configure Sound
Perform steps with either an RPi connected keyboard, or an SSH session.
-
Set ALSA sound to maximum volume (was 40, set to 100 using arrow keys).
alsamixer
Use Escape key or Back button to exit.
-
Test speakers produce sound.
speaker-test -c2 -twav
Note that the sound volume is very low if using unamplified speakers. To attain reasonable volume loudness I think either HDMI TV speakers or separate amplified speakers are required.
G. Download MythTV Build and Transfer to RPi
Note: These steps download the MythTV build to a non-RPi computer so that the tarball does not need to be re-downloaded if the RPi image is rebuilt. Optionally you can download the MythTV Build directly to the RPi.
-
Download MythTV build for RPi.
Download mythtv-v0.27.6-69-g41a2a8d-RPI2-jessie.tar.bz2.
Checksums
MD5SUM: 43dd1a86a25e0dec74655f60df245635 mythtv-v0.27.6-69-g41a2a8d-RPI2-jessie.tar.bz2 SHA1SUM: 7f6d6960417a57c622afb4ded1950b1647f7f973 mythtv-v0.27.6-69-g41a2a8d-RPI2-jessie.tar.bz2
-
Transfer MythTV build to RPi.
scp -p mythtv-v0.27.6-69-g41a2a8d-RPI2-jessie.tar.bz2 pi@192.168.1.69:/home/pi
H. Install a Build of MythFrontend
Perform steps with either an RPi connected keyboard, or an SSH session.
-
Extract MythTV tarball on Raspberry Pi 2.
export MYTHTVDIR=~/mythtv-rpi mkdir -p $MYTHTVDIR tar -C $MYTHTVDIR -xavf mythtv-v0.27.*-jessie.tar.bz2
-
Ensure package list is up-to-date.
sudo apt-get update
-
Install Jessie dependencies.
sudo apt-get install libudf0 libass5 \ libxcb-icccm4 libxcb-image0 libxcb-render-util0 libxcb-sync1 \ libxcb-randr0 libxcb-keysyms1 \ fonts-liberation libdate-calc-perl \ mysql-client libexiv2-13 libexif12 libcdio-cdda1 libfftw3-3
I. Configure MythFrontend via SSH
The initial configuration of mythfrontend is best performed via an SSH session so that you can see the mythfrontend start-up messages.
If you prefer you can start with step 3 directly on the Raspberry Pi without the ssh connection.
-
Power up / boot your MythTV Backend.
-
Remote shell into RPi.
ssh -YC pi@192.168.1.69
-
Setup mythfrontend with initial connection settings.
QT_QPA_PLATFORM=xcb\ LD_LIBRARY_PATH=$HOME/mythtv-rpi/lib\ QT_PLUGIN_PATH=$HOME/mythtv-rpi/plugins\ ~/mythtv-rpi/bin/mythfrontend -w -geometry 1280x720 -p
At setup I chose:
Country: Canada Language: English (Canada)
Choose Save.
On my MythTV Servers screen there were no servers listed so I chose Manual.
This restarted mythfrontend and I had to reselect Country and Language.
On the Database Configuration 1/2 screen set the following:
Hostname: <your MythTV Backend server IP address> Yes - Ping test server? Port: 3306 Database name: mythconverg User: mythtv Password: <your mythtv MySQL database password>
Note that you can get the mythtv MySQL password from the MythTV Frontend Setup General screen.
Choose Next and then Finish to save the values.
This restarted mythfrontend with the normal mythfrontend menu options.
Exit out of this Frontend with Escape key or Back button. At prompt Do you really want to exit MythTV respond with Yes, Exit now.
NOTE: If connected via ssh -YC then log out using exit command.
J. Set Up lirc for MCE Remote Control
These steps are required if you wish to use an MCE remote control.
If you don't have an MCE remote control then skip to the next section and use a USB keyboard attached to the RPi.
TIP: LIRC configuration files for those without Mythbuntu |
-
Install lirc package.
sudo apt-get install lirc
-
Copy the ~/.lirc/* files from your MythTV Backend PVR user account (mine is pvr).
mkdir ~/.lirc scp -p pvr@192.168.1.55:"/home/pvr/.lirc/*" ~/.lirc/
-
Copy the ~/.lircrc file from your MythTV Backend PVR user account (mine is pvr).
scp -p pvr@192.168.1.55:/home/pvr/.lircrc ~/
-
Copy the /etc/lirc/lirc.conf from your MythTV Backend PVR.
sudo scp -p pvr@192.168.1.55:/etc/lirc/lircd.conf /etc/lirc
-
Edit /etc/lirc/hardware.conf file.
sudo nano /etc/lirc/hardware.conf
Make it look like the following:
----- begin hardware.conf -----
# /etc/lirc/hardware.conf # # Arguments which will be used when launching lircd LIRCD_ARGS="" #Don't start lircmd even if there seems to be a good config file START_LIRCMD=false #Don't start irexec, even if a good config file seems to exist. #START_IREXEC=false #Try to load appropriate kernel modules LOAD_MODULES=true # Run "lircd --driver=help" for a list of supported drivers. DRIVER="default" # usually /dev/lirc0 is the correct setting for systems using udev DEVICE="/dev/lirc0" MODULES="" # Default configuration files for your hardware if any LIRCD_CONF="" LIRCMD_CONF=""
----- end hardware.conf -----
Save file and exit editor with Ctrl+X.
-
Fix problem with double presses for certain MCE remote buttons.
Create a file in /etc/udev/rules.d called remote-control-lirc.rules.
sudo nano /etc/udev/rules.d/remote-control-lirc.rules
Copy and paste the following line.
----- begin remote-control-lirc.rules -----
SUBSYSTEM=="rc", ATTRS{protocols}=="*lirc*" RUN+="/bin/sh -c 'echo lirc > /sys$env{DEVPATH}/protocols'"
----- end remote-control-lirc.rules -----
Save file and exit editor with Ctrl+X.
-
Reboot to activate LIRC for MCE remote control.
sudo reboot
K. Further Configure Mythfrontend
Perform steps with either an RPi connected keyboard, or an SSH session with MCE remote control.
-
Create ~/runFE.sh script to run mythfrontend.
nano ~/runFE.sh
Copy and paste the following lines.
----- begin runFE.sh -----
#!/bin/bash # # Run MythTV Frontend on Raspberry Pi 2 # # Requires "OpenMAX EGLFS" video playback profile export MYTHCONFDIR=~/.mythtv export MYTHTVDIR=~/mythtv-rpi QT_QPA_EGLFS_FORCE888=1 QT_QPA_PLATFORM=eglfs\ LD_LIBRARY_PATH=$MYTHTVDIR/lib\ QT_PLUGIN_PATH=$MYTHTVDIR/plugins\ PYTHONPATH=$MYTHTVDIR/lib/python2.7/site-packages\ $MYTHTVDIR/bin/mythfrontend
----- end runFE.sh -----
Save file and exit editor with Ctrl+X.
NOTE: How to Start MythFrontend in XCB mode
If you wish to try running mythfrontend in XCB mode instead of EGLFS mode, then the invocation is:
#!/bin/bash
#
# Run MythTV Frontend in XCB mode on Raspberry Pi 2
#
# Requires "OpenMAX Normal" video playback profile
export MYTHCONFDIR=~/.mythtv
export MYTHTVDIR=~/mythtv-rpi
QT_QPA_PLATFORM=xcb\
LD_LIBRARY_PATH=$MYTHTVDIR/lib\
QT_PLUGIN_PATH=$MYTHTVDIR/plugins\
PYTHONPATH=$MYTHTVDIR/lib/python2.7/site-packages\
startx $MYTHTVDIR/bin/mythfrontend
Be sure in step 6 to choose OpenMAX Normal video playback profile instead of OpenMAX EGLFS. -
Make ~/runFE.sh script executable.
chmod a+x ~/runFE.sh
-
Run mythfrontend.
./runFE.sh
-
Configure Frontend appearance setup.
Select Setup -> Appearance.
Ensure:
Paint engine: Qt
Choose Next 2 times then Finish.
Note screen will refresh back to top level menu.
-
Configure Frontend audio setup.
Select Setup -> Audio.
Ensure:
Audio output device: ALSA:default Digital Audio Capabilities Dolby Digital no DTS no E-AC-3 <no - greyed out> TrueHD <no - greyed out> DTS-HD <no - greyed out> Speaker configuration: Stereo Upconvert stereo to 5.1 surround <yes - greyed out> Upmix Quality: <Best - greyed out>
Choose Next.
Ensure:
Mixer device: ALSA:default Mixer controls: PCM Master mixer volume: 100% PCM mixer volume: 100%
Choose Finish.
-
Configure Frontend video setup.
Select Video -> Playback.
Choose Next 2 times to get to Playback Profiles (3/8).
Ensure (Add New if needed):
Current Video Playback Profile: OpenMAX EGLFS
Note 1: This profile is different than the OpenMAX Normal profile which is used with XCB mode.
Note 2: Currently the OpenMAX video playback profiles do not display North American ATSC closed captioning subtitles. If you choose OpenGL High Quality, then subtitles can be enabled while watching recordings, but there will be some video pixelation during playback. Video pixelation can be reduced by overclocking - see tip below.
Under Edit ensure:
Match criteria: >= W: 0 H: 0 Match criteria: <empty> W: 0 H: 0 Decoder: openmax Max CPUs: 1 Deblocking filter: yes Video renderer: openmax OSD renderer: opengl2 OSD fade: no
Choose Next and ensure:
Primary deinterlacer: Advanced (HW) Fallback deinterlacer: Fast (HW) Custom filters: <empty>
NOTE: Interlaced Playback with Newer Versions of Raspbian.
To avoid jaggy lines when playing 1080i interlaced content with newer Raspbian versions, such as my test with 2017-03-02-raspbian-jessie.zip, I had to change
Primary deinterlacer from:
Advanced (HW)
to:
Line double (HW)
.
Choose Finish.
Choose Next 5 times to get to Commercial Skip (8/8).
Ensure (my preference):
Automatically skip commercials: Off Commercial skip automatic rewind amount (secs): 1
Choose Finish to save and exit playback settings.
Use Escape key or Back button to return to the top level menu.
Try to watch a recording.
Use Escape key or Back button to return to the top menu and exit mythfrontend.
TIP: Suggested Over-Clock Settings for RPi2 Only |
L. Set MythFrontend to Auto-start on Boot
This section configures the RPi on boot to send a wake up call to the MythTV Backend and start mythfrontend on the RPi.
-
Install Wake-On-LAN command.
sudo apt-get install wakeonlan
-
Create ~/autostart.sh file.
nano ~/autostart.sh
Copy and paste the following lines:
----- begin autostart.sh -----
#!/bin/bash # # Run MythTV Frontend on Raspberry Pi 2 on Boot # # Use your MythTV Backend values here. IPADDR=192.168.1.55 MACADDR=00:0b:0e:0f:00:ed # Pause for RPi to boot to shell prompt sleep 3 echo "Waiting 7 seconds for IP network to start..." sleep 7 # Wake up MythTV Backend if not responding ping -c 2 $IPADDR if [ $? -ne 0 ]; then wakeonlan $MACADDR echo "Waiting 25 seconds for MythTV Backend to boot..." sleep 25 fi # Run mythfrontend /home/pi/runFE.sh
----- end autostart.sh -----
Be sure to use your own values for your MythTV Backend for the IP Address 192.168.1.55 and the Ethernet / MAC address 00:0b:0e:0f:00:ed.
Save file and exit editor with Ctrl+X.
-
Make ~/autostart.sh file executable.
chmod a+x ~/autostart.sh
-
Add /home/pi/autostart.sh script to /etc/rc.local file.
sudo nano /etc/rc.local
Add the following lines above the exit 0 line.
----- begin lines -----
# Run autostart.sh script on boot su --login pi -c '/home/pi/autostart.sh' &
----- end lines -----
Save file and exit editor with Ctrl+X.
Upon reboot, the mythfrontend should now automatically start.
Troubleshooting Audio and Video
There is a symbiotic relationship between audio and video on RPi. Improper audio settings can cause video stuttering, and incorrect video settings can cause disruptions in audio. Following are solutions to some problems I encountered.
Audio is Missing
Symptoms
-
Try to run alsamixer and receive error message.
alsamixer cannot open mixer: No such file or directory
-
Try to watch a recording in Mythfrontend and receive error message.
Audio Output Error: AOOSS: Error opening audio device (): eno:No such file or directory (2)
-
Try to force a specific audio output in raspi-config and receive error message.
There was an error running option A9 Audio
Solution
-
To load audio module for current session.
sudo modprobe snd_bcm2835
-
To load audio module each time the RPi boots do one of the following:
Either:
-
Edit /boot/config.txt file.
sudo nano /boot/config.txt
Copy and paste the following lines.
----- begin lines -----
# Enable audio (loads snd_bcm2835) dtparam=audio=on
----- end lines -----
Save file and exit editor with Ctrl+X.
Or:
-
Edit /etc/modules file.
sudo nano /etc/modules
Copy and paste the following line.
----- begin line -----
snd_bcm2835
----- end line -----
Save file and exit editor with Ctrl+X.
Reboot to load audio driver.
-
Video Display Extends Beyond Physical Screen
Symptoms
-
Not all of the video display can be seen because portions extend beyond the physical screen.
Figure 2: Example of video display problem. Top image shows portions of words missing. Bottom image is correct.
Solution
-
Use elinux.org video mode options in config.txt to force a specific resolution.
The following steps fixed the display problem on the 42" LG LCD TV shown in the pictures.
Edit /boot/config.txt file.
sudo nano /boot/config.txt
Copy and paste the following lines.
----- begin lines -----
#hdmi_drive=2 # Uncomment this hdmi_drive line if using sound via HDMI cable hdmi_group=2 # DMT hdmi_mode=39 # 1360x768 60 Hz
----- end lines -----
Save file and exit editor with Ctrl+X.
Reboot
-
Use the mythfrontend Setup -> Appearance menu to alter the GUI width (pixels) and GUI height (pixels) values to match the resolution you chose for /boot/config.txt.
GUI width (pixels): 1360 GUI height (pixels): 768 GUI X offset: 0 GUI Y offset: 0
These values worked well on the following displays:
- 1920x1080 60 Hz 42" LG LCD TV
- 1920x1080 60 Hz 28" Benq LCD monitor
- 1680x1050 60 Hz 22" Benq LCD monitor
-
Mythtv-Users forum member airdrummer reported that the following /boot/config.txt setting enabled the overscan parameters to work in EGLFS mode.
overscan_scale=1
See also Raspberry Pi Forum reference.
Conclusion
Congratulations. You should now have an inexpensive Raspberry Pi 2 computer that is able to playback MythTV recordings using Mythfrontend. :-)
References
While researching how to set up a Raspberry Pi 2 computer with MythFrontend I found the following references useful: