Just updated kernel to 6.0.9 by adapting the manjaro patches, and I saw that rk3399 hardware video decoding is now supported in the kernel.
Note, there are two ways of hardware video decoding, one is to use the mali GPU, and the other is to use the on-chip video decoder, which is more efficient. In this post I’m talking about the latter case.
To leverage this capability:
- Make sure the kernel is recent (go 6.0!), and enable the following options:
- CONFIG_VIDEO_HANTRO=m
- CONFIG_VIDEO_HANTRO_ROCKCHIP=y
- CONFIG_VIDEO_ROCKCHIP_VDEC=m
- Build and the ffmpeg fork that supports the rockchip vdec:
- Arch/Manjaro: AUR (en) - ffmpeg-v4l2-request-git
- Other distros: upstream: GitHub - jernejsk/FFmpeg – but try to follow the build process in AUR PKGBUILD file.
- Persuade your package manager that this fork provides both ffmpeg and ffmpeg4.4
- try ffmpeg:
- without hw dec:
ffmpeg -i input.mp4 -f null - -benchmark
- with hw dec:
ffmpeg -hwaccel drm -i input.mp4 -f null - -benchmark
- mpv
- the distro package may have been statically linked to ffmpeg, so it won’t work out of the box. I use the aur version: AUR (en) - mpv-git
- the custom build will be linked against our modified ffmpeg
mpv --hwdec=drm test.mp4
- this setting can be stored in config files
- In my tests, I tried to playback a 1080p h264 video. Without hw dec: saturates one big core and 50% load on other cores with high frequency; With hw dec: total cpu utilization <10%, can play smoothly at gear 2 (2 little cores @ 800MHz)
- It not only decodes, but goes directly to blit the video onto the screen. The cpus are very happy about this.
- chromium
works out of the box. neat!cap it to gear 2, play something on youtube and observe!- update: nope, that’s GPU decoding. Need to enable V4L2 codec for chromium. See: https://groups.google.com/a/chromium.org/g/chromium-dev/c/JUKeQBTG85w
- moonlight (game straeming)
- works after recompile & link with custom ffmpeg. You’ll see rkvdec related debugging logs in the console output.
Tested not working:
- 4k mkv: rkvdec gives up, fallback to gpu decoding
- freerdp: need further investigate how to enable hw codec
- vlc: need further investigate how to pass
-hwaccel drm
to it
To verify it’s working for one software, launch it, and then watch /proc/interrupts
and see if rkvdec interrupt number grows.
So… clockworkpi team, please incorporate this into future OS images. It’s a matter of “working vs. works great”!