pi4 on ubuntu for mythtv-backend

For discussion of topics specific to MythTV on Raspberry Pi devices
Post Reply
mythpi3
Newcomer
Posts: 10
Joined: Tue Jun 28, 2016 3:56 am
United States of America

pi4 on ubuntu for mythtv-backend

Post by mythpi3 »

Seems like some folks here are getting interested in using the pi's as a backend. My first experience (a few years ago) was running an OTA backend on my pi3. It ran fairly well, with the biggest drawback being some glitch related to ffmpeg causing it to be unable to generate thumbnails. It used a boot partition on SD card to bootstrap the rest of the system on the USB drive.

That said, I just recently upgraded to run on a pi4-2GB, and after running a few days, figured I'd mention some things I found in case they help anyone out.

First, my setup:
pi4-2GB with Western Digital 2TB Black My Passport Ultra Portable External Hard Drive - USB 3.0
Flirc raspberry pi 4 case (for some heatsinking)
Micro Connectors Micro-USB 5V/2.5A Power Adapter with on/off Switch
Ubuntu Server 20.04.1 LTS
HDHomeRun Extend (configured for MPEG2 only, no compression)

First, I really wanted to boot from the USB hard drive. Mostly just to 'simplify' the setup, and because I 'should' be able to with the pi4. That said - usb booting still has some rough edges. Sure, if you buy a recent pi4 with up-to-date firmware maybe it won't be an issue, but I had to start Raspbian on an SD card to get things updated enough to even have a chance. There are other tutorials and instructions to try to get you up to speed on that.

Once my Pi4 was up-to-date and capable of USB boot, my next issue was that although Ubuntu Server claims pi4 support, they don't really claim pi4-boot-from-hdd support. So the 64-bit version requires some manual decompression of the kernel to make it work, and then some scripting to ensure that any kernel updates get similarly decompressed (lest your pi4 cease to boot after an update due to the vagaries of 64-bit arm kernel compression and uboot.) I waited about 6 months for this situation to get resolved, and then got impatient and just went ahead and did the decompression and set up the script, since pi4-hdd boot seems to be a fairly secondary concern for most folks. I followed these instructions, starting from step 11 (since my pi was already firmware-updated): https://medium.com/@zsmahi/make-ubuntu- ... f15c66acd4

Since my pi4 was already firmware updated, I was able to use the Raspberry Pi Imager to write the Ubuntu Server 20.04.1 image right to the USB drive (and then decompress the kernel as mentioned above, while the drive was still attached to my laptop. The auto-decompress script I set-up once the pi booted). Don't forget to add an ssh file in the boot directory if you're trying to login remotely, as I was.

Once ubuntu was running, installing mythtv-backend-master was fairly straightforward. This is probably my main reason for going with ubuntu - the packagers and configuration seems to 'just work' better than any other experience I've had with mythtv before. Even after updates, things seem to be fairly smooth.

I had to migrate a database backup from my old server, and then figured out that mythtv31 doesn't support Schedules Direct data-direct anymore. So getting XMLTV channel grabbing up and running was the worst part of the experience by far. It was a major pain, and your experience may vary depending on where you are and what channel info service your using. But my main takeaway for the pi was: You may need to use the --no-allatonce command switch for mythfilldatabase (put it in mythtv-setup options, and remember to use it on any manual runs.) Without the switch, I found that mythfilldatabase would update for the first tuner, and then the process was getting killed. Turns out, mythfilldatabase with XMLTV tries to digest all the channel listings data at once (basically) and gobbles up tons of memory. Given that I only have about 50 OTA channels available from my listings source, I imagine this is even more terrible for someone with lots of channels from a cable provider or something. So on the pi, with limited memory, you may need the --no-allatonce switch to get XMLTV grabbers to run properly and not kill your pi.

Also: Don't try to delete and re-scan for channels in order to add XMLTV channels. It can make a big mess of things. Just update the XMLTV id's for your channels manually, if you must. Also, also: be sure to create a database backup before you start mucking with XMLTV and channels. It could save your bacon (I had to restore after trying the delete/rescan option and seeing that it was going to muck-up a bunch of stuff.) Another nice thing about the ubuntu packages is they have the myth backup/restore scripts handily installed in /usr/share/mythtv/mythconverg_backup.pl (use the --verbose switch to see what it's doing or where it's failing.) You need to make sure you have a config.xml script in your /home/<yourusername>/.mythtv/ directory, also. You can probably find an example in /home/mythtv/.mythtv/ if you need one.

My bonus reward for setting up XMLTV is that now my server is giving me channel icons, which actually look pretty cool.

I also hack in an allow all for the apache2 config for mythweb to not require passwords for IP's on my LAN (maybe a questionable security practice, but it's not exposed to the internet and saves me some aggravation.)

That's most of what I remember, hopefully it helps save someone some trouble. In short, for a modest amount of channels, the Pi4 seems to be a fairly capable low-power backend. As well as it has served me, I do keep getting surprised by the fact that although myth-backend using an HDHR tuner is fairly lightweight, there are still a few areas where mythtv very much expects some beefy hardware and if you push it too hard, it's still possible to bog-down and knock over a raspberry pi with it. Hopefully someone will do the work necessary to make mythfilldatabase play a bit nicer on resource limited systems - so far as I can tell, it seems to be the biggest resource user right now.

Good luck.
User avatar
jfabernathy
Senior
Posts: 577
Joined: Wed Feb 18, 2015 2:37 pm
Location: Raleigh, NC
United States of America

Re: pi4 on ubuntu for mythtv-backend

Post by jfabernathy »

This gives me something to play with today :D
I did the Ubuntu 20.04 on Pi thing a while back but had to build from source to get mythtv working. Sounds like it's better now.

I did take your --no-allatonce point to heart and added it to my setup on Raspberry PI OS Lite. I've also added it to my instructions for building.
https://mythtv-rp4.blogspot.com/2020/11 ... rpi-4.html
User avatar
jfabernathy
Senior
Posts: 577
Joined: Wed Feb 18, 2015 2:37 pm
Location: Raleigh, NC
United States of America

Re: pi4 on ubuntu for mythtv-backend

Post by jfabernathy »

@mythpi3 I tried this this morning and it mostly worked, but for some reason after adding the ppa:mythbuntu/31 and installing 'mythtv' with sudo apt install mythtv I ended up with the gdm and all the GUI stuff which doesn't seem to work. I was trying to change to console boot only when something got hosed and I had to start over.

So did you only do an sudo apt install mythtv-backend???
User avatar
jfabernathy
Senior
Posts: 577
Joined: Wed Feb 18, 2015 2:37 pm
Location: Raleigh, NC
United States of America

Re: pi4 on ubuntu for mythtv-backend

Post by jfabernathy »

On my second attempt, which was successful I did a couple of things.
1. After I booted Ubuntu 20.04 from the USB3 SSD I changed the password as required and let it sit while the unattended upgrades did their thing. After all that completed, I then added the ppa:mythbuntu/31 and installed 'mythtv'.

I then forced the system to boot to console by:

Code: Select all

sudo systemctl set-default multi-user.target
I got the backend working first with just EIT EPG using my HDHR Quatro tuners. but then installed XMTLV per the wiki as I've done before. The key being to switch to user 'mythtv' by

Code: Select all

sudo su mythtv
cd $HOME
I used the tv_grab_zz_sdjson_sqlite instructions as I always do, just cutting and pasting.

I could never get any frontend, mythfrontend or kodi to work.

It seems to be a stable backend but I see no difference in performance from the normal mythtv v31 on Raspberry Pi OS lite (32bit).
mythpi3
Newcomer
Posts: 10
Joined: Tue Jun 28, 2016 3:56 am
United States of America

Re: pi4 on ubuntu for mythtv-backend

Post by mythpi3 »

I did not have to add any sources (just using the default ubuntu repos.) I also used the default repo version for XMLTV, even though it's likely a bit out of date, but seems to be updated enough that it is functioning. Again, mostly because I've found in the past that once I go 'off repo' it tends to make upgrading properly much more of a chore and much more likely to result in a broken backend that I then have to sort out, versus just sticking with whatever is in the repo leads to a better long-term experience.

When I installed myth, I just installed mythtv-backend-master (sudo apt update; sudo apt install mythtv-backend-master), as I needed the backend and database only. I only use separate frontends (mostly osmc on other raspberry pis.) I thought mythbuntu was discontinued, so maybe that's bringing in something old or out of date. If you just use mythtv-backend, I think it omits the database, which would likely cause issues.

For what it's worth, using Xming as a remote x-server works well enough (kinda sluggish) to be able to use mythtv-setup, even without an x-server and frontend installed on the pi4 backend machine.

Good to hear your experience - it seems like there's no ultra smooth pathway to install myth on these pi's, but the experience now is way better than it was 10+ years ago, even on a full-fledged X86 machine. My only complaint this time around was that the XMLTV setup seemed like a bit of a step back compared to the simplicity of the SchedDirect data direct setup that had been integrated fairly well.
User avatar
heyted
Senior
Posts: 301
Joined: Sun Jun 08, 2014 2:14 am
Location: South Florida
Contact:
United States of America

Re: pi4 on ubuntu for mythtv-backend

Post by heyted »

The MythTV version from the Mythbuntu PPA typically has many important fixes.
Ted | My blog
mythpi3
Newcomer
Posts: 10
Joined: Tue Jun 28, 2016 3:56 am
United States of America

Re: pi4 on ubuntu for mythtv-backend

Post by mythpi3 »

Interesting to hear. I guess I was just thinking of the standalone Mythbuntu OS, which I had used a number of years back. I do have a fairly simple setup (backend only, HDHomerun simplifies lots of things, only about 25 channels OTA) so haven't run into any issues with the standard ubuntu mythtv packages, but I'll keep in mind that the Mythbuntu PPA is still being maintained if I run into any.
Post Reply