Hardware-accelerated 4K video on RK3588 with Linux 7.0

Contents

Background

Collabora team has been doing amazing work. Now you don't need to use vendor BSP to use hardware acceleration. Now with upstream linux kernel 7.0, you can play 4K 60fps video with hardware acceleration without any vendor kernel patch.

First of all, thank you so much to my friend for lending me Odroid-M21 in this RAMpocalypse.

But how to do it?

I couldn't find a guide on how to actually run it on an upstream kernel. That's why I wrote this article.

I could get some hints from Collabora's blog post2. And this Github discussion3 was helpful too.

This is what you need

NOTE:

Some of these aren't needed if you just want decoding. It's done by VPU, so you might only need the upstream kernel. I'm focusing on playing video, which requires integration with GPU. And GPU needs some configurations.

These were enabled by default for me, but you might need to enable them yourself:

Or you can use ffmpeg/mpv instead of gstreamer. These patches add v4l2request support:

I believe you can do 'hardware decoding' without any patch with ffmpeg even on TTY. But you may be able to use it only for transcoding or whatever you need it for, but not for playing video AFAIK.

How to play it

v4l2-ctl -d /dev/videoN --list-formats-out
v4l2-ctl -d /dev/videoM --list-formats-out

With patched ffmpeg + mpv on wayland compositor that supports linux-dmabuf-v1:

mpv --hwdec=v4l2request --vo=dmabuf-wayland --hwdec-software-fallback=no bbb_sunflower_2160p_60fps_normal.mp4

--hwdec-software-fallback=no isn't necessary but it's useful for not making it fallback to software decoding.

But how to get board image?

crossdev-stages

You can build image with crossdev-stages. Making an image for RISC-V/ARM boards is usually not that convenient. It removes all the headache when you build an image for boards. It makes a container with hakoniwa and sets up a cross compiler environment with Gentoo Linux. Then you can build rootfs + linux + uboot + whatever automatically, designed so everything can be defined with config files.

I added multi-board support on top of Luca's original work. It used to only support RISC-V boards, now you can use ARM boards too.

Voilà!

Upcoming patches?

There are more works waiting for merge, like 4K 60fps HDMI output. This is really amazing work. You can check details in the resources at the bottom.

Mini VideoBox

I don't want this to just be playing with my Odroid-M2, I want to make it useful.

For future plan, I'm trying to make a 'Mini-VideoBox' someday. FOSDEM has a streaming device called videobox7, it's an amazing thing. I had a great chance to use and analyze it, and they also donated one to us, FOSS for All.

But it's bit big and it's for huge conferences. I'm more trying to make a streaming+recording device that can work standalone. Since RK3588 has HDMI input (Unfortunately Odroid-M2 uses RK3588S2 which has no HDMI input), this could be a perfect fit.

My plan is to build several mini-videoboxes for small meetups. I'd love to do this as a FOSS for All project, building it openly with the community. So people can record their talk and meetup painlessly. No OBS on their laptop, no capture card.

We need more time before all features land in the upstream kernel, but I believe it can be done someday.

Thank you!

Kudos to the Collabora team! And again, thanks to my friend C who lent me his Odroid-M2.

Other useful resources

Tags: Linux FFmpeg mpv GStreamer RK3588 Collabora