RPi4 & MATE - How to *actually* get video acceleration

(continued from the "Dedoimedo" thread - which was a nice article, but so far has apparently produced exactly zero cases of working video acceleration for anybody, and on closer examination clearly never will, because it isn't even trying to do that...)

So, yeah - after updating to 21.04 today, the pi still has no video acceleration. Time to abandon this dead end and move on...

The problem is the Ubuntu side of things, not the MATE side. So If you want MATE with working hwaccel, you HAVE to start with the Raspbian image. I'm sure that if you're sufficiently determined you could get it to work on Ubuntu by building the Pi Foundation's kernel tree instead (and possibly also making custom builds of ffmpeg, VLC, MPV, etc), but after burning a LOT of days on this already, I decided to take the easy way out instead.

  1. Install Raspbian. To be exact: I used 2021-03-04-raspios-buster-armhf
  2. Install MATE, via sudo tasksel

Now for the "fun" part... :roll_eyes:
Configuring lightdm to actually use MATE isn't difficult, but most of the search results you'll find will be either out of date (because lightdm's configuration gets a new set of random breaking changes every release) or just don't work.
The commands you need are sudo update-alternatives --config x-window-manager and sudo update-alternatives --config x-session-manager.

Once that's done, log out and back in, and you should have a MATE desktop.

The bad news is, it's a rather old version of MATE: only 1.20. The good news is, that's what shipped with 18.04, so you may be used to it anyway. Also, it doesn't have various 19.xx-and-later breakages, so it's actually less buggy than the current MATE release. (Unfortunately).
You will be missing a few really good pieces of MATE though: MATE Tweak, for example, appears to be Ubuntu-only; and most annoyingly, the hwsensors applet is also missing. Conky etc is an adequate replacement functionally, but is less attractive and much less convenient.

On the other hand, you get hardware video acceleration, and that's a more than fair tradeoff.

Accelerated video on the Pi is a long and complicated topic, and Pi's don't generally get a lot of use as desktops, so it's not especially surprising or unreasonable that Ubuntu hasn't bothered with it. What's puzzling is that, AFAICT, the kernel patches were mainlined in the kernel last autumn, so I can't understand how Ubuntu manages to not work, even if you rebuild the media players with MMAL support. :frowning:

Regardless, the difference is night and day. On Ubuntu, trying to play a 1080p h265 video pegs all 4 cores at 100%, with all the usual frame-dropping etc you'd expect. (Overclocking can help a surprisingly large amount, but ultimately it's still just always going to suck).
On Raspbian, the same video takes less than 50% of ONE core: and most of that is apparently spent in IO wait, since the amout of CPU charged to the process in sysmon is 6%. So, yeah, that's quite a lot better. :smiley:

There are plenty of LXDE leftovers scattered about. I haven't bothered removing them yet, but I doubtless will someday. If someone beats me to it for creating a list that can just be fed into an apt purge, feel free to add it to this thread.

Anyway, after seven OS installs/upgrades, and days spent reading through the Pi develper logs and wasted on random articles that were uniformly either irrelevant or flat-out wrong, I finally have a DE I like and video acceleration that works. It's not perfect, but it's far far better overall than any of the versions that came before it. :slight_smile:



In case you were curious: the Dedoimedo article is actually about getting OpenGL acceleration working. That's it. Nothing at all to do with video acceleration, other than that having a working GL layer lets VLC etc render into an OGL texture and use the HW to blit that onto the screen.

1 Like

Very good article @arQon.

I just have one question: Did you try using tasksel to "de-select" LXDE, then run sudo apt -p autoremove? That should get rid of the odds and ends of LXDE.

BTW, I too like Debian a lot. If you want to get a more up-to-date MATE, you can try taking your existing Raspbian system and upgrading to Bullseye (still considered Unstable, but hardly less stable than Ubuntu MATE) by:

(WARNING! These commands are NOT guaranteed to work for you! I'd strongly suggest you back up the system you have right now before you do the upgrade, since historically Debian upgrades have not always been completely smooth sailing. I do not take responsibility for any damage to your Raspbian setup if you do this and the procedure fails.)

sudo sed -Ei 's/buster/bullseye/g' /etc/apt/sources.list
sudo apt update
sudo apt dist-upgrade

Did you try using tasksel to "de-select" LXDE

No - in the end, I decided to leave it for a while.
I've built MATE from source before to fix or investigate various bugs, and if I do that on the pi someday I may actually want a second DE around for when I (inevitably :P) break something critical. (LXDE isn't much, but it'll let me run multiple terminals, and that's all I need from it).

It's a good suggestion though, thanks. I'll probably do it to "tidy up" once the pi retires to full-time HTPC duty.

Next on the list is investigating WHY v4l is such a disaster on the pi, and potentially seeing if I can create a vaapi shim for it. I suspect not, since vaapi has restrictions that I think technically make it impossible (because the "real" video core and the "media" video core are actually separate pieces) but it's worth investigating because obviously that fixes ALL the problems at once.

1 Like