Backend on Pi 4

jfabernathy
Senior
Posts: 118
Joined: Wed Feb 18, 2015 2:37 pm
United States of America

Re: Backend on Pi 4

Post by jfabernathy » Sat Aug 10, 2019 6:54 pm

MikeB2013 wrote:
Sat Aug 10, 2019 5:41 pm
Jim.

You should be fine with HDHR Duo based on a test I have just run:

pi 4 (4GB) MythTV Version : v31-Pre-546-g3a918bd11d-dirty
storage 1TB USB 3 hard disk, with Raspbian Buster running on this (micro sd card only used for boot)

network tuner VBOX 3442 2x DVB-T2 tuners

7 simultanous HD recordings 4 recordings on 1 tuner, 3 recordings on the other tuner.
I used HD channels as they use much more network bandwidth than SD.
mythfilldatabase running Schedules Direct tv_grab_zz_sdjson with no-allatonce switch

All whilst watching previously recorded HD program on mythfrontend, playback using openmax with gpu_mem=320 (not the default vc4-fkms-v3d)
Playback of SD channels also works.

Kodi (17.6) from Raspbian repository is problematic at present.

Mike
Can you explain more about just using the micro SD card for the boot? In my application I'll use the USB3 ports for 256GB Flash Keys. Once the RP3/4 is booted it's going to run mostly out of RAM since mythtv-backend is all that is running. Where is setting up the SD card to do this documented?

I find that if I want a RP3 to do Kodi, I use 18.3. If it's a FE only I use LibreELEC 9.1.002. Very stable

Jim A

jfabernathy
Senior
Posts: 118
Joined: Wed Feb 18, 2015 2:37 pm
United States of America

Re: Backend on Pi 4

Post by jfabernathy » Sun Aug 11, 2019 2:14 pm

MikeB2013 wrote:
Wed Jul 10, 2019 10:46 am
Just for information.
...

You can use any of the Raspbian Buster versions, but when running totally headless (no hdmi connection, or keyboard/mouse), so it is mythbackend only, I use Raspbian Buster Lite. You need to be careful when running mythtv-setup. On my Pi4 it hangs. Killing the process has not effect, trying a reboot command (sudo reboot), still hangs, ssh connections get logout, but the Pi4 does not reboot. It required a hard poweroff i.e. unplug power.

I found two solutions to this:
1. put hdmi_ignore_cec=1 in /boot/config.txt on Pi4 and reboot for it to take effect.
or --not recommended
2. run mythtv-setup with -O libCECEnabled=0 switch i.e. mythtv-setup -O libCECEnabled=0

TIP: If running totally headless, you can force ssh at initial boot by creating an empty file named ssh in /boot/ on the microSD card before you put it into the Pi4. This way you don't need to temporarily connect a monitor, keyboard to Pi4. As long as the Pi4 has an ethernet connection and can get an ip address you are good to go via ssh.


Mike
I really appreciate these tips above. Very helpful.

MikeB2013
Senior
Posts: 429
Joined: Mon Jul 25, 2016 4:16 pm
Great Britain

Re: Backend on Pi 4

Post by MikeB2013 » Sun Aug 11, 2019 4:15 pm

jfabernathy wrote:
Sat Aug 10, 2019 6:54 pm

Can you explain more about just using the micro SD card for the boot? In my application I'll use the USB3 ports for 256GB Flash Keys. Once the RP3/4 is booted it's going to run mostly out of RAM since mythtv-backend is all that is running. Where is setting up the SD card to do this documented?

I find that if I want a RP3 to do Kodi, I use 18.3. If it's a FE only I use LibreELEC 9.1.002. Very stable

Jim A
mythbackend is constantly writing to disk, and even more so when recording, mariadb is also doing some disk writing as well and of course the operating system will be doing its thing as well.

Here in UK, roughly 2GB per hour per recording for HD, 0.7GB per hour SD for OTA, satellite can be much higher for HD.

Whilst there are many posts around on how to move rootfs from microSD card to an external drive, a lot of them are old and out of date, and in many cases very manual. I have a helper script (attached, just download it, unzip and make sure it is executable) which does most of it.

You just need to start with a working Pi4 install, copy the helper script over to it (put it in /home/pi/)
If using an external hard disk power down Pi BEFORE connecting to a USB port,

You should be ok connecting a single SSD or several USB flash drives to USB ports whilst Pi is powered, assuming official power supply (for Pi4, 1.2A is available over the 4 USB ports).

Everything is done in a terminal session either locally or via SSH.
I use lsblk command to view partition and mount point information.

Code: Select all

pi@raspberrypi:~ $ lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda           8:0    1 57.3G  0 disk 
└─sda1        8:1    1 57.3G  0 part /media/pi/f88f7e1a-e0f2-4348-a185-f89955eeffa7
mmcblk0     179:0    0 14.7G  0 disk 
├─mmcblk0p1 179:1    0  256M  0 part /boot
└─mmcblk0p2 179:2    0 14.4G  0 part /
The above shows default for /boot (mmcblk0p1) and / (mmcblk0p2)
If flash drive/Hard disk/SSD shown in MOUNTPOINT, usually sda1 (unless you have more than 1 external drive or the external drive has more partitions) in /media/pi/ it needs to be unmounted before running the helper script (script will abort if it finds mounted disk in /media/pi/).
e.g.

Code: Select all

sudo umount /media/pi/*
now run the script, WARNING all data on target will be destroyed.

Code: Select all

sudo ./pi-SDtoHD-helper.sh -d /dev/sda 
after you reboot
you should see from lsblk

Code: Select all

pi@raspberrypi:~ $ lsblk
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda           8:0    1 57.3G  0 disk 
└─sda1        8:1    1 57.3G  0 part /
mmcblk0     179:0    0 14.7G  0 disk 
├─mmcblk0p1 179:1    0  256M  0 part /boot
└─mmcblk0p2 179:2    0 14.4G  0 part /media/pi/rootfs
MOUNTPOINT / is now on sda1, /boot is still on mmcblk0p1 (the micro SD card)
The old / (mmcblk0p2) has been automounted on /media/pi/rootfs, I just ignore it

Mike
Attachments
pi-SDtoHD-helper.sh.zip
(1.62 KiB) Downloaded 29 times

jfabernathy
Senior
Posts: 118
Joined: Wed Feb 18, 2015 2:37 pm
United States of America

Re: Backend on Pi 4

Post by jfabernathy » Sun Aug 11, 2019 4:45 pm

Mike, Wow, thanks. This and the other script will get a workout on Wednesday when my Pi4, 1TB SSD and adapter arrive.

I built a USB Flash boot system on a RP3B+ which is simple so I know the script that builds the mythtv backend after mythtv-light is installed works great. Obviously the performance of the RP3B+ is lacking, but it will record an HD problem. In the USA, the HD programs usually take about 6GB per hour on the 4 major OTA networks, CBS, NBC, ABC, and Fox.

Thanks again.

jfabernathy
Senior
Posts: 118
Joined: Wed Feb 18, 2015 2:37 pm
United States of America

Re: Backend on Pi 4

Post by jfabernathy » Wed Aug 14, 2019 12:04 pm

Okay, I have Raspbian Buster up and running on my Raspberry Pi 4 B with 4GB ram. I installed mythtv-light per the instructions and used the scripts attached in this thread to move the rootfs to a USB3-SATA-SSD drive and to install the rest of mythtv needed for a backend.

For initial testing I have Raspbian set to a 1080P screen but on a 4K TV. I've recorded 4 simultaneous HD ATSC programs from a HDHR Quatro, but with no other activity on the frontend. The recordings were done perfectly. Later playback showed as least as smooth as a Shield TV, meaning pretty damned good.

I later tried recording 2 HD shows at once and watching a previously recorded program at the same time. Seems to work fine. Still tweaking the setting some.

Thanks for all the help
Jim A

jfabernathy
Senior
Posts: 118
Joined: Wed Feb 18, 2015 2:37 pm
United States of America

Re: Backend on Pi 4

Post by jfabernathy » Sun Aug 18, 2019 12:04 pm

After working with the mythtv FE/BE on my Pi 4 I've noticed one thing not working. The script that MikeB2013 wrote to install all the rest of the stuff you need to run Mythtv backend installed the mythconverg_backup.pl to be run daily.

It is not running daily the best I can see. I can manually run:

sudo /etc/cron.daily/mythtv-database # the backup compressed file gets created in "/srv/mythtv/recordings"

so is there some service that needs to be enabled?? cron is enabled and running.

MikeB2013
Senior
Posts: 429
Joined: Mon Jul 25, 2016 4:16 pm
Great Britain

Re: Backend on Pi 4

Post by MikeB2013 » Sun Aug 18, 2019 12:53 pm

jfabernathy wrote:
Sun Aug 18, 2019 12:04 pm
After working with the mythtv FE/BE on my Pi 4 I've noticed one thing not working. The script that MikeB2013 wrote to install all the rest of the stuff you need to run Mythtv backend installed the mythconverg_backup.pl to be run daily.

It is not running daily the best I can see. I can manually run:

sudo /etc/cron.daily/mythtv-database # the backup compressed file gets created in "/srv/mythtv/recordings"

so is there some service that needs to be enabled?? cron is enabled and running.
Jim,

I thought I fixed that problem in my script, but obviously not on mythtv-light Buster 30.
Most of my testing has been done on mythtv master built from source, where there is a change in mythtv packaging to packaging/deb/debian/mythtv-database.cron.weekly (I just put the file renamed to mythtv-database in /etc/cron.daily instead of /etc/cron.weekly ). This change has not been backported to mythtv packaging fixes/30.

Can you try replacing the contents of /etc/cron.daily/mythtv-database with the following:

Code: Select all

#!/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"
DEBIAN="--defaults-extra-file=/etc/mysql/debian.cnf"
USER="mythtv"

/usr/bin/mysqlcheck $DEBIAN -s $DBNAME

if [ -e "/etc/default/mythtv-backend" ]; then
   . /etc/default/mythtv-backend
fi

if [ "$USER" = "" ]; then
   CMDPREFIX=""
else
   CMDPREFIX="sudo -H -u $USER"
fi

$CMDPREFIX /usr/share/mythtv/mythconverg_backup.pl

/usr/bin/logger -p daemon.info -i -t${0##*/} "$DBNAME checked and backed up."

# End of file.
A reboot after this is recommended, but is probably not required.

I need to setup my pi4 with mythtv-light 30 Buster and have a closer look at what is happening or not!

Mike

jfabernathy
Senior
Posts: 118
Joined: Wed Feb 18, 2015 2:37 pm
United States of America

Re: Backend on Pi 4

Post by jfabernathy » Sun Aug 18, 2019 1:50 pm

MikeB2013 wrote:
Sun Aug 18, 2019 12:53 pm
jfabernathy wrote:
Sun Aug 18, 2019 12:04 pm
After working with the mythtv FE/BE on my Pi 4 I've noticed one thing not working. The script that MikeB2013 wrote to install all the rest of the stuff you need to run Mythtv backend installed the mythconverg_backup.pl to be run daily.

It is not running daily the best I can see. I can manually run:

sudo /etc/cron.daily/mythtv-database # the backup compressed file gets created in "/srv/mythtv/recordings"

so is there some service that needs to be enabled?? cron is enabled and running.
Jim,

I thought I fixed that problem in my script, but obviously not on mythtv-light Buster 30.
Most of my testing has been done on mythtv master built from source, where there is a change in mythtv packaging to packaging/deb/debian/mythtv-database.cron.weekly (I just put the file renamed to mythtv-database in /etc/cron.daily instead of /etc/cron.weekly ). This change has not been backported to mythtv packaging fixes/30.

Can you try replacing the contents of /etc/cron.daily/mythtv-database with the following:

Code: Select all

#!/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"
DEBIAN="--defaults-extra-file=/etc/mysql/debian.cnf"
USER="mythtv"

/usr/bin/mysqlcheck $DEBIAN -s $DBNAME

if [ -e "/etc/default/mythtv-backend" ]; then
   . /etc/default/mythtv-backend
fi

if [ "$USER" = "" ]; then
   CMDPREFIX=""
else
   CMDPREFIX="sudo -H -u $USER"
fi

$CMDPREFIX /usr/share/mythtv/mythconverg_backup.pl

/usr/bin/logger -p daemon.info -i -t${0##*/} "$DBNAME checked and backed up."

# End of file.
A reboot after this is recommended, but is probably not required.

I need to setup my pi4 with mythtv-light 30 Buster and have a closer look at what is happening or not!

Mike
Okay, recommended change done and rebooted. I'll assume it's working and will check tomorrow to see if the backup occurred. If not I'll post again.

Thanks, your 2 scripts are saved a bunch of work.

Jim A

MikeB2013
Senior
Posts: 429
Joined: Mon Jul 25, 2016 4:16 pm
Great Britain

Re: Backend on Pi 4

Post by MikeB2013 » Thu Aug 22, 2019 7:40 am

pi-mythbackend-helper.sh script updated in original post viewtopic.php?f=46&t=3232&p=15773#p15773

Fixes daily backup issue on mythtv-light 30.

I just use mythtv packaging master now, as it works for the few files needed on mythtv-light 30

Re-run the script, ignore any errors - they are not harmful, and it will update the mythtv-database file in /etc/cron.daily/

Mike

jfabernathy
Senior
Posts: 118
Joined: Wed Feb 18, 2015 2:37 pm
United States of America

Re: Backend on Pi 4

Post by jfabernathy » Thu Aug 22, 2019 11:08 am

My database backups have been working daily since I made your recent change. To put the backups in the right place I remembered to run mythtv-setup->Storage locations and create a group locations for database backups. Now all my daily backups are going there and not in my Default group, which was set for recordings location.

Mythtv combo FE/BE on Raspberry Pi 4B with 4GB, 1TB SSD, with rootfs is as good as my production mythtv-backend with a Shield TV frontend. Other than having 8TB of mirrored RAID storage, the Pi does everything. Since I never record more than 4 HD shows at once on the production system, the Pi can do that nicely with a HDHR Quatro.

Thanks again.
Jim A

jksj
Junior
Posts: 62
Joined: Thu Feb 13, 2014 7:53 pm
Great Britain

Re: Backend on Pi 4

Post by jksj » Fri Aug 23, 2019 7:53 am

Mythtv combo FE/BE on Raspberry Pi 4B with 4GB, 1TB SSD, with rootfs is as good as my production mythtv-backend with a Shield TV frontend. Other than having 8TB of mirrored RAID storage, the Pi does everything. Since I never record more than 4 HD shows at once on the production system, the Pi can do that nicely with a HDHR Quatro.
I have got annoyingly close to perfect playback on a Pi 4 but never quite there. Currently suffering from minor tearing use ffmpeg decode and linear blend for 1920i 50Hz. What video parameters are you using.

jfabernathy
Senior
Posts: 118
Joined: Wed Feb 18, 2015 2:37 pm
United States of America

Re: Backend on Pi 4

Post by jfabernathy » Fri Aug 23, 2019 9:56 am

jksj wrote:
Fri Aug 23, 2019 7:53 am
Mythtv combo FE/BE on Raspberry Pi 4B with 4GB, 1TB SSD, with rootfs is as good as my production mythtv-backend with a Shield TV frontend. Other than having 8TB of mirrored RAID storage, the Pi does everything. Since I never record more than 4 HD shows at once on the production system, the Pi can do that nicely with a HDHR Quatro.
I have got annoyingly close to perfect playback on a Pi 4 but never quite there. Currently suffering from minor tearing use ffmpeg decode and linear blend for 1920i 50Hz. What video parameters are you using.
Configuration:

Setup Raspbian to operate at 1080P on my 4K TV. Better picture that 4K native for Mythtv for me.

Configure mythtv-setup for my HDHR tuners as any backend is configured

Create $HOME/.asoundrc file for Digital Audio with ALSA per https://www.mythtv.org/wiki/Raspberry_Pi

Configured mythfrontend using setup wizard for Audio- ALSA:mythtv:CARD=ALSA, Video- OpenMAX normal. Selected Mythbuntu 30.1 theme.

That's it. Works fantastically at recording shows on multiple tuners while watching previously recorded show.

Note! use the fan regardless of which case you pick.

jksj
Junior
Posts: 62
Joined: Thu Feb 13, 2014 7:53 pm
Great Britain

Re: Backend on Pi 4

Post by jksj » Fri Aug 23, 2019 4:38 pm

Thanks for the response, I will retry that configuration but it has always given me a picture that shows slight judder when panning. I am guessing that the difference might be in the broadcast format, presumably yours is not interlaced?

jfabernathy
Senior
Posts: 118
Joined: Wed Feb 18, 2015 2:37 pm
United States of America

Re: Backend on Pi 4

Post by jfabernathy » Fri Aug 23, 2019 5:32 pm

Some recordings are 1080i and some are 720p

MikeB2013
Senior
Posts: 429
Joined: Mon Jul 25, 2016 4:16 pm
Great Britain

Re: Backend on Pi 4

Post by MikeB2013 » Mon Aug 26, 2019 8:42 am

kojaked wrote:
Sat Jul 13, 2019 5:20 am
Dare I ask: how well does commercial flagging work on a Pi 4?
Commercial flagging runs ok for h264 recordings but not for mpeg2 (DVB-T and ATSC) where it fails with segmentation faults.
These segmentation faults seem to be arm architecture related.

I raised a mythtv trac ticket for DVB-T on this https://code.mythtv.org/trac/ticket/13476

I don't use commercial flagging, I just use 30 second forward skip to run past commercials.

Mike

Post Reply