[A06] Mainline hardware video decoding tested working!

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:

  1. 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
  1. Build and the ffmpeg fork that supports the rockchip vdec:
  1. try ffmpeg:
  • without hw dec: ffmpeg -i input.mp4 -f null - -benchmark
  • with hw dec: ffmpeg -hwaccel drm -i input.mp4 -f null - -benchmark
  1. 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.
  1. chromium
  1. 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”!

10 Likes

I can also confirm hardware decoding seems to work on kernel 6.0 with mpv 0.35 and ffmpeg from the linked repo.

1 Like