RPI4, HDHomerun, UK Freeview ...

Do you want advice about what hardware to buy for use with MythTV? Ask here.

Moderator: Forum Moderators

lynnux
Junior
Posts: 19
Joined: Thu Sep 05, 2019 10:16 pm
Great Britain

Re: RPI4, HDHomerun, UK Freeview ...

Post by lynnux » Sun Sep 29, 2019 10:55 pm

Great advice again Mike - thank you.
In no particular order:

frontend / backend connection: works fine now (intermittent network problem and typo in master setup)

>I hope OpenMax High Quality is just a typo
Compared with "Normal" maxing out 1 CPU, OpenMax Normal seemed to spread load across CPUs well, so did "High Quality" (yesterday) and I therefore assumed "High Quality" was actually "OpenMax High Quality". Today, at a hurried glance, that is not the case. Also I notice "Openmax Normal" doesn't play nice with mice, keyboards and desktops. Flicking between desktops, for example, works a few times and then leaves the keyboard and mouse dead. "High Quality" and "Normal" give no such problems. (With "High Quality" I'm currently getting stability, good picture quality, low idle cpu temps and silky smooth playback with cpugovernor = ondemand.)

For some unknown reason I lost all my program listings after I rebooted one time. I deleted the pesky USB Stick capture card and video source and all is normal again. I haven't adjusted the HDHR video sources as per your instructions yet though. I will do shortly. Thanks for the info.

Swap problems: I adjusted vm.swappiness (/etc/sysctl.conf) to 10 rather than the default 60 (crazy aggressive IMHO). Somewhere I found this comment:
"... for MariaDB databases, it is recommended to set swappiness to a value of 1" but I thought that was a bit too laid back. Anyway there's 0 swap after 5 hours so that's an improvement as it used to tick up at about 2MB / hr.

A few fun and games with the 3B+ frontend today. It's working OK on my old TV but yet to get picture size and position right on 4K TV. ALSA audio is fine on HDMI but unusably noisy on jack socket.

Bob

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

Re: RPI4, HDHomerun, UK Freeview ...

Post by MikeB2013 » Mon Sep 30, 2019 9:46 am

"For some unknown reason I lost all my program listings after I rebooted one time"

There is a race condition in that mythbackend can startup before networking is fully available. This mostly affects those with network tuners, but can have other side effects e.g. remote frontends not being able to connect to mythbackend.
Fortunately the solution on Raspberry Pi is easy just enable "Wait for network" in Raspberry Pi Configuration on each Pi and then reboot.

"A few fun and games with the 3B+ frontend today. It's working OK on my old TV but yet to get picture size and position right on 4K TV. ALSA audio is fine on HDMI but unusably noisy on jack socket."

There are some hints about jack audio https://www.mythtv.org/wiki/Raspberry_Pi
(that page needs some updates for Raspbian Buster and Pi4)

For size and positioning depending on you 4K TV. In raspberry Pi 3 /boot/config.txt (or use Raspberry Pi Configuration) try
turning off overscan, uncomment line "disable_overscan=1" (remove # at start of line)
setting resolution to 1920x1080p @50Hz, set hdmi_group=1 and hdmi_mode=31 (remove # at start of line if present)
(picture mode on the TV may also need to be set to "just scan" which has different names between manufacturers)

You can check the TV connection by running in a terminal session on Pi

Code: Select all

tvservice -s
e.g. mine shows

Code: Select all

pi@pi3-20190921:~ $ tvservice -s
state 0xa [HDMI CEA (31) RGB lim 16:9], 1920x1080 @ 50.00Hz, progressive
You can get a list of all modes supported by your TV

Code: Select all

tvservice -m CEA
for my LG 1080p TV mine gives

Code: Select all

pi@pi3-b-20190921:~ $ tvservice -m CEA
Group CEA has 15 modes:
           mode 1: 640x480 @ 60Hz 4:3, clock:25MHz progressive 
           mode 2: 720x480 @ 60Hz 4:3, clock:27MHz progressive 
           mode 3: 720x480 @ 60Hz 16:9, clock:27MHz progressive 
           mode 4: 1280x720 @ 60Hz 16:9, clock:74MHz progressive 3D:FP|TopBot|SbS-HH
           mode 5: 1920x1080 @ 60Hz 16:9, clock:74MHz interlaced 3D:SbS-HH
  (native) mode 16: 1920x1080 @ 60Hz 16:9, clock:148MHz progressive 3D:TopBot|SbS-HH
           mode 17: 720x576 @ 50Hz 4:3, clock:27MHz progressive 
           mode 18: 720x576 @ 50Hz 16:9, clock:27MHz progressive 
           mode 19: 1280x720 @ 50Hz 16:9, clock:74MHz progressive 3D:FP|TopBot|SbS-HH
           mode 20: 1920x1080 @ 50Hz 16:9, clock:74MHz interlaced 3D:SbS-HH
           mode 21: 720x576 @ 50Hz 4:3, clock:27MHz x2 interlaced 
  (prefer) mode 31: 1920x1080 @ 50Hz 16:9, clock:148MHz progressive 3D:TopBot|SbS-HH
           mode 32: 1920x1080 @ 24Hz 16:9, clock:74MHz progressive 3D:FP|TopBot|SbS-HH
           mode 33: 1920x1080 @ 25Hz 16:9, clock:74MHz progressive 
           mode 34: 1920x1080 @ 30Hz 16:9, clock:74MHz progressive 3D:TopBot|SbS-HH
For my LG 4K TV

Code: Select all

pi@pi4-20190926:~ $ tvservice -m CEA
Group CEA has 23 modes:
           mode 1: 640x480 @ 60Hz 4:3, clock:25MHz progressive 
           mode 2: 720x480 @ 60Hz 4:3, clock:27MHz progressive 
           mode 3: 720x480 @ 60Hz 16:9, clock:27MHz progressive 
           mode 4: 1280x720 @ 60Hz 16:9, clock:74MHz progressive 
           mode 5: 1920x1080 @ 60Hz 16:9, clock:74MHz interlaced 
  (prefer) mode 16: 1920x1080 @ 60Hz 16:9, clock:148MHz progressive 
           mode 17: 720x576 @ 50Hz 4:3, clock:27MHz progressive 
           mode 18: 720x576 @ 50Hz 16:9, clock:27MHz progressive 
           mode 19: 1280x720 @ 50Hz 16:9, clock:74MHz progressive 
           mode 20: 1920x1080 @ 50Hz 16:9, clock:74MHz interlaced 
           mode 21: 720x576 @ 50Hz 4:3, clock:27MHz x2 interlaced 
           mode 31: 1920x1080 @ 50Hz 16:9, clock:148MHz progressive 
           mode 32: 1920x1080 @ 24Hz 16:9, clock:74MHz progressive 
           mode 33: 1920x1080 @ 25Hz 16:9, clock:74MHz progressive 
           mode 34: 1920x1080 @ 30Hz 16:9, clock:74MHz progressive 
           mode 63: 1920x1080 @ 120Hz 16:9, clock:297MHz progressive 
           mode 64: 1920x1080 @ 100Hz 16:9, clock:297MHz progressive 
           mode 93: 3840x2160 @ 24Hz 16:9, clock:297MHz progressive 
           mode 94: 3840x2160 @ 25Hz 16:9, clock:297MHz progressive 
           mode 95: 3840x2160 @ 30Hz 16:9, clock:297MHz progressive 
           mode 98: 4096x2160 @ 24Hz unknown AR, clock:297MHz progressive 
           mode 99: 4096x2160 @ 25Hz unknown AR, clock:297MHz progressive 
           mode 100: 4096x2160 @ 30Hz unknown AR, clock:297MHz progressive 
Mike

lynnux
Junior
Posts: 19
Joined: Thu Sep 05, 2019 10:16 pm
Great Britain

Re: RPI4, HDHomerun, UK Freeview ...

Post by lynnux » Tue Oct 01, 2019 10:38 am

Thanks again Mike. With your help I have now got most things under control.
  • I have now fixed up backend settings for HDHR as per your guidelines and completely replaced my old PC box with the Pi4.
  • Without having to do anything special the picture sizing sorted itself out by HDMI magic once the cabling was sorted out.
  • I found one (non-mythtv related) nasty with LXDE/pcmanfm : On my system the file manager pcmanfm goes rogue after a while and hogs 100% of one CPU's time. I have now disabled it from autostarting ( /etc/xdg/lxsession/LXDE-pi/autostart ). It may have contributed to my swap problems.
  • Watching HD recorded programs last night was good. A bit less "snappy" in response to commands than the old box. Skipping adverts was generally OK but sometimes it took 10 or twenty seconds for the audio to come back; this was before I discovered the rogue pcmanfm problem. so I'll give it another go tonight. Ad skipping on SD content was fine.
  • I found swap was at 100%* (100MB of 100MB) at the end of the evening - I hope that the pcmanfm fix might have some bearing on this.
  • Scrolling down lists etc. in the frontend was often accompanied by flashing white areas as the screen redrew. I'm sure I've seen that's a problem. TBI
  • With the Pi4 + 4KTV I had to revert to "OpenMax Normal". I think "High Quality" resulted in a "Your hw isn't good enough" type of message on playback. Again pcmanfm might have had a bearing on this. The picture quality was fine though.
* Funny that - years ago, when I was building Unix kernels, if you got to 100% swap you were toast. Raspbian seems to keep smiling though!
Bob

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

Re: RPI4, HDHomerun, UK Freeview ...

Post by MikeB2013 » Wed Oct 02, 2019 9:49 am

"Scrolling down lists etc. in the frontend was often accompanied by flashing white areas as the screen redrew. I'm sure I've seen that's a problem. TBI"

You are correct, it is a known issue, and is not limited to Raspberry Pi running Raspbian Buster.

Mike

lynnux
Junior
Posts: 19
Joined: Thu Sep 05, 2019 10:16 pm
Great Britain

Re: RPI4, HDHomerun, UK Freeview ...

Post by lynnux » Fri Oct 04, 2019 4:05 pm

Thanks Mike, good to know.
  • I've now turned off swap completely and can watch Live TV fairly well without things really slowing down but it's still better to record then view.
  • Currently I'm trying to reduce the amount of jitter on playback of HDHR Freeview HD recordings on the 4K TV. (No problem on the old "HD Ready" TV.)
    Pan / dolly / zoom type scenes, credit rolls etc. jerk and are uncomfortable to watch.
    Observations:
    TV (on its own, no Myth at all) plays at 1080i@50Hz
    Pi4:
    CPU speed 1500MHz when playback starts, 600 at idle.
    config.txt:
    hdmi_group:0=1
    hdmi_mode:0=31 (1080p@50Hz) (tried 39 1080i@50Hz - no difference; TV's own OSD reports 3840x2160@30Hz during playback or GUI)
    arm_freq=1500
    disable_l2cache=1 (TBI)
    framebuffer_ignore_alpha=1
    framebuffer_swap=1
    gpu_freq=500
    gpu_freq_min=500
    gpu_mem=256 (tried 512 but no difference)
    Myth Frontend settings:
    Playback using Openmax Normal (anything else is worse)
    Separate GUI / playback sizes is OFF. TV reports 3840x2160@30Hz for GUI and playback. This gives the best performance, screen sizing for GUI and picture quality. Using a separate playback size (say 1920x1080) is worse.
    On screen source data shows FPS varies between 23 and 26 for source 1920x1080@25Hz. CPUs evenly loaded around 30% each.
    I've messed around with lots of settings but only ever get the same or worse picture and/or jitter.
Any thoughts gratefully received.
Bob

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

Re: RPI4, HDHomerun, UK Freeview ...

Post by MikeB2013 » Sun Oct 06, 2019 8:56 am

Playback of either HD or SD with TV reporting (assuming it is telling the truth) 3840x2160@30Hz is going to be terrible, likely with black band around the screen. Audio will be out of sync and for HD are many screen artifacts.

From your config.txt entries you seem to be using legacy graphics mode (like on Pi2 or Pi3) as your list does not have

Code: Select all

[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2
If using legacy graphics mode the entries should look like:

Code: Select all

[pi4]
# Enable DRM VC4 V3D driver on top of the dispmanx display stack
#dtoverlay=vc4-fkms-v3d
max_framebuffers=2

To get 4K up to 60Hz in either OpenGL or legacy graphics mode you need to add in /boot/config.txt

Code: Select all

hdmi_enable_4kp60=1
also change the line #disable_overscan=1 in /boot/config.txt to, this fixes the black band around the screen.
Note your TV Picture Mode for the HDMI input may need to be set to "Just Scan" (or whatever it is called on your TV, different names are used)

Code: Select all

disable_overscan=1
Now reboot

Check on the Pi4 using tvservice -s


There are two solutions:

1.If using OpenGL graphics (vc4-fkms-v3d), which is the default on Pi4.

Use Raspberry Screen Configuration utility to change Frequency to 50Hz

You can also use OpenMax Normal in OpenGL graphics mode by adding gpu_mem=256 to /boot/config.txt

2. If using legacy graphics on Pi4 (as on Pi2 or Pi3).
change
#hdmi_group=1
#hdmi_mode=1

To what you would like e.g.
hdmi_group=1
hdmi_mode=31 # 1920x1080 @ 50Hz 16:9, clock:148MHz progressive
hdmi_mode=96 # 3840x2160 @ 50Hz 16:9, clock:594MHz progressive


As far a using OpenMax Normal is concerned make sure of the following in mythfrontend>Setup>Video>Playback>Current Video Playback Profile>OpenMAX Normal>openmax & openmax>:
Max CPUs 4
Primary deinterlacer Linear Blend
Advanced (HW) will cause issues.

Mike

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

Re: RPI4, HDHomerun, UK Freeview ...

Post by MikeB2013 » Sun Oct 06, 2019 10:02 am

Forgot to mention, suggest remove the following from /boot/config.txt on Pi4:
arm_freq=1500
disable_l2cache=1 (TBI)
framebuffer_ignore_alpha=1
framebuffer_swap=1
gpu_freq=500
gpu_freq_min=500

There is a simple monitoring tool for the Pi bcmstat.sh
download with
wget https://raw.githubusercontent.com/Milho ... bcmstat.sh && chmod +x bcmstat.sh

run it
./bcmstat.sh

Use ctrl+c to stop it running

Mike

lynnux
Junior
Posts: 19
Joined: Thu Sep 05, 2019 10:16 pm
Great Britain

Re: RPI4, HDHomerun, UK Freeview ...

Post by lynnux » Tue Oct 08, 2019 11:06 pm

Hi Mike, thanks for bearing with me and your suggestions.

I've spent many hours trying all sorts of combinations of settings without much success.
Active boot.config settings:
$ grep -o '^[^#]*' /boot/config.txt
disable_overscan=1
hdmi_enable_4kp60=1
hdmi_group=1
hdmi_mode=31 <---- NOTE: This only affects LXDE display, It is overridden when Mythtv sets up its GUI and playback windows. Doesn't affect playback stutter.
dtparam=audio=on
[pi4]
dtoverlay=vc4-fkms-v3d
max_framebuffers=2
[all]
gpu_mem=256

Mythtv setup: as you suggest: Openmax Normal and Linear Blend interlacer. GUI 1920x1080 Playback 1920x1080 50Hz
  • I've also played with giving mythfrontend realtime privileges and nicing it down a bit but no joy.
  • I now get the TV reporting 1080p@50Hz when Mythtv is replaying a 1920x1080i@25Hz recording which seems right to me.
I tried updating the Pi4 from 4.19.66 to 4.19.76; no difference.
  • As a sanity check, I played the same recording (actually the opening credits from Doc Martin) with VLC at full screen. It was really smooth (just the same as watching direct TV) and with the same picture quality. So I know the Pi4 can do it.
  • I lashed up a Pi3B+ as a temporary frontend to the Pi4 and found exactly the same stutter.
  • On the Pi4 I used htop and bcmstat.sh (thank you), but could not see anything outrageously wrong except to say that IRQ/s and CPU usage was lower with VLC than Mythtv. (Have lost the output now otherwise would have given examples.)
  • Having played several HD recordings, I've just now found there's a problem with jumps and fast forward:
    FFwd X3 cuts the sound but plays video at normal speed; pressing play (or pause) during FFwd can be very random in its effect - it might resume playing with no sound, might skip on for a few more (position counter) minutes, might get horribly confused and display random frames before stopping / playing ... it never crashes though.
  • Jumps and FFwd work fine on SD recordings
I'm starting to suspect that audio/video sync may have a bearing on the stutter. I'm using ALSA:default. I shall investigate tomorrow.


Bob

Post Reply