Backend on Pi 4

For discussion of topics specific to MythTV on Raspberry Pi devices
Post Reply
flitter
Newcomer
Posts: 12
Joined: Wed Aug 20, 2014 2:58 am
Australia

Backend on Pi 4

Post by flitter »

With the new Pi4 supporting much more RAM would it now be possible to use the Pi as a dedicated backend (or even just as a non-recording master backend?) (with no frontend installed)
jksj
Senior
Posts: 148
Joined: Thu Feb 13, 2014 7:53 pm
Great Britain

Re: Backend on Pi 4

Post by jksj »

I would expect it to be a full backend supporting any USB tuner that has drivers built into the kernel (would need an external disk drive obviously). I will try it this weekend an post the results.
kojaked
Newcomer
Posts: 9
Joined: Sat Jun 15, 2019 3:47 am
United States of America

Re: Backend on Pi 4

Post by kojaked »

I'm excited to learn if this is feasible. I have a backend running on a computer that is probably better suited as a NAS. If a Raspberry Pi 4 can handle it, that also expands the universe of people who could easily introduce MythTV to their homes.
jksj
Senior
Posts: 148
Joined: Thu Feb 13, 2014 7:53 pm
Great Britain

Re: Backend on Pi 4

Post by jksj »

The backend runs fine on a 2GB Pi 4. Recorded 3 HD channels 1080i to a usb2 hard drive from a DVB2 - USB2 tuner. I installed Rasbian and had the database on the SD card and recorded to an external USB2 drive. Would have been easier to put everything on the external drive, preferably USB3.

Running the frontend at the same time works-ish but is pushing it, needs a 4GB Pi 4. The frontend is hanging when exiting playback. The frontend runs fine on the same Pi4 without the backend present so I am fairly confidant its due to lack of memory.

Code: Select all

 
 Mem
              total        used        free      shared  buff/cache   available
Mem:        1803332      769496      281140       69408      752696      884144
Swap:        102396       32000       70396
Top
Tasks: 174 total,   2 running, 166 sleeping,   0 stopped,   6 zombie
%Cpu(s): 12.2 us, 19.8 sy, 24.1 ni, 42.8 id,  1.0 wa,  0.0 hi,  0.1 si,  0.0 st
MiB Mem :   1761.1 total,    272.7 free,    747.0 used,    741.3 buff/cache
MiB Swap:    100.0 total,     63.0 free,     37.0 used.    867.9 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                                         
 9270 mythtv    37  17  546544 256348  46152 R  97.4  14.2   8:45.20 mythcommflag                                                                    
10201 pi        20   0  884916 362844  98172 S  44.6  20.1   1:23.70 mythfrontend                                                                    
 4084 mythtv    20   0  609100  88320  47624 S  38.6   4.9   5:29.08 mythbackend
I built from source and then it took a day to get the backend running so a none trivial task. Installing a frontend on Pi is easy particularly when using Mythtv Light. However a Backend installation - database (used Maria) -adding mythtv as a user -configuring the recording folders was no more difficult than using any other OS - wth lots of googling.
User avatar
pgbennett
Developer
Posts: 503
Joined: Mon Apr 27, 2015 5:41 pm
United States of America

Re: Backend on Pi 4

Post by pgbennett »

mythtv-light does include the backend so it should not be necessary to build from source. Also the wiki guides should give all the info on setting up the database etc. although that info is in the "Build from source" article https://www.mythtv.org/wiki/Build_from_ ... tall_tasks
flitter
Newcomer
Posts: 12
Joined: Wed Aug 20, 2014 2:58 am
Australia

Re: Backend on Pi 4

Post by flitter »

jksj wrote:
Sat Jul 06, 2019 11:00 am
The backend runs fine on a 2GB Pi 4. Recorded 3 HD channels 1080i to a usb2 hard drive from a DVB2 - USB2 tuner. I installed Rasbian and had the database on the SD card and recorded to an external USB2 drive. Would have been easier to put everything on the external drive, preferably USB3.
That's fantastic news! Finally I can retire another piece of my old HTPC infrastructure and introduce a more distributed arrangement!

Thanks jksj!!!
MikeB2013
Senior
Posts: 519
Joined: Mon Jul 25, 2016 4:16 pm
Great Britain

Re: Backend on Pi 4

Post by MikeB2013 »

Just for information.

Running mythbackend on my Pi4 (4GB) works well.

I am using microSD card to boot into rootfs on a 1 TB USB 3 hard drive, so the microSD card is only used to boot.
Note this method is the only one available until boot from USB is available on Pi4 (it is being worked on).

I have it configured to use 1x USB DVB-T2 tuner (Astrometa), two network DVB-S/S2 tuners (VBOX 3345).
The DVB-T2 tuner is using EIT, with DVB-S/S2 tuners using xmltv (Schedules Direct tvgrab_zz_sdjson).
Note that you will likely need to set mythfilldatabase arguments to have "--no-allatonce" switch as mythfilldatabase can be very memory hungry.

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
kojaked
Newcomer
Posts: 9
Joined: Sat Jun 15, 2019 3:47 am
United States of America

Re: Backend on Pi 4

Post by kojaked »

Dare I ask: how well does commercial flagging work on a Pi 4?
MikeB2013
Senior
Posts: 519
Joined: Mon Jul 25, 2016 4:16 pm
Great Britain

Re: Backend on Pi 4

Post by MikeB2013 »

pgbennett wrote:
Sat Jul 06, 2019 12:38 pm
mythtv-light does include the backend so it should not be necessary to build from source. Also the wiki guides should give all the info on setting up the database etc. although that info is in the "Build from source" article https://www.mythtv.org/wiki/Build_from_ ... tall_tasks
Attached is a helper script (by product of my testing mythtv-light builds) to automate the setting up of mythbackend after mythtv-light (30 or 31pre) has been installed on a Pi 4 or a Pi 3.

EDIT 30 March 2020
The latest version of this script is now available from my github repository at https://github.com/MikeB2013/pi-utils

In brief, see comments in script for more details:

Installs mariadb-server, creates mythconverg database (password is mythtv) and sets daily backup
Installs mythweb
Installs xmltv
setup mythtv user for running mythbackend
setup various directories on the file system for recordings etc. uses /srv/mythtv/
setup logging with rotation
setup systemd mythtv-backend.service file
setup remote access

The script is provided "as is" but any comments are welcome.
Just download the file,unzip, make sure it is executable and run it.

Edit: 20200224 added libxml-simple-perl, changed git master to fixes/31
Edit : 20190822 attachment updated to fix issue with daily backup on mythtv-light 30

Mike
Attachments
pi-mythbackend-helper.sh.zip
added libxml-simple-perl, git master changed to fixes/31
(4.07 KiB) Downloaded 295 times
Last edited by MikeB2013 on Mon Mar 30, 2020 8:32 am, edited 4 times in total.
jksj
Senior
Posts: 148
Joined: Thu Feb 13, 2014 7:53 pm
Great Britain

Re: Backend on Pi 4

Post by jksj »

Thanks for the very useful looking script for setting up the backend, would have saved me hours.
Did you install a RTC? My Pi takes a good minute from power on to set the clock from the network. Calling sudo ntpdate-debian at start doesn't seem to work. BBC Sounds locks up when the clock is behind real time and I am presuming mythbackend would be affected.
MikeB2013
Senior
Posts: 519
Joined: Mon Jul 25, 2016 4:16 pm
Great Britain

Re: Backend on Pi 4

Post by MikeB2013 »

I have not installed RTC.

I am running stock Buster, I have not even enabled "wait for network" at boot, don't know if this will allow quicker time sync, probably worth a try.

I have not noticed any issues with time sync, but have not tested edge case where Pi is powered off and booted just after a scheduled recording is due to start.

Mike
jksj
Senior
Posts: 148
Joined: Thu Feb 13, 2014 7:53 pm
Great Britain

Re: Backend on Pi 4

Post by jksj »

Thanks for the response to the RTC issue. Presumably as there is no ACPI wakeup from a timer? You either leave it on all the time or manually power it up when needed.
Presumably a mains timer could be used for normal recording hours with a crontab to shut the Pi down before the power gets axed. Have you thought of anything better?
MikeB2013
Senior
Posts: 519
Joined: Mon Jul 25, 2016 4:16 pm
Great Britain

Re: Backend on Pi 4

Post by MikeB2013 »

No ACPI from a timer as there is no Real Time Clock.
The Pi is designed to be powered all the time and the power requirements are low. I keep mine powered all the time.

You can add a RTC see https://thepihut.com/blogs/raspberry-pi ... spberry-pi
User avatar
jfabernathy
Senior
Posts: 577
Joined: Wed Feb 18, 2015 2:37 pm
Location: Raleigh, NC
United States of America

Re: Backend on Pi 4

Post by jfabernathy »

MikeB2013 wrote:
Tue Jul 23, 2019 7:46 pm
pgbennett wrote:
Sat Jul 06, 2019 12:38 pm
mythtv-light does include the backend so it should not be necessary to build from source. Also the wiki guides should give all the info on setting up the database etc. although that info is in the "Build from source" article https://www.mythtv.org/wiki/Build_from_ ... tall_tasks
Attached is a helper script (by product of my testing mythtv-light builds) to automate the setting up of mythbackend after mythtv-light (30 or 31pre) has been installed on a Pi 4 or a Pi 3.
In brief, see comments in script for more details:

Installs mariadb-server, creates mythconverg database (password is mythtv) and sets daily backup
Installs mythweb
Installs xmltv
setup mythtv user for running mythbackend
setup various directories on the file system for recordings etc. uses /srv/mythtv/
setup logging with rotation
setup systemd mythtv-backend.service file
setup remote access

The script is provided "as is" but any comments are welcome.
Just download the file,unzip, make sure it is executable and run it.

Mike
Mike, I've been looking at your script and the internal bus speeds of the RP4 and bought a 4GB one. Do you thing the RP4 4GB would record 2 shows at once from a HDHR Duo while also using it as a frontend via Mythfrontend or Kodi to watch a previous recorded program??

Alternative is I could use my current RP3 B+ as a Kodi 18 FE using LibreELEC with the Mythtv PVR addon, then dedicate the RP4 B 4GB to Mythtv Backend only. If I could record 2 HDHR HD programs at once while playing a HD previous recorded program on the RP3 FE, that would be great.

Jim A
MikeB2013
Senior
Posts: 519
Joined: Mon Jul 25, 2016 4:16 pm
Great Britain

Re: Backend on Pi 4

Post by MikeB2013 »

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
Post Reply