xnux.eu - site map - news

Hardware video acceleration on PinePhone

PinePhone has a mainline Linux support for HW accelerated video decoding for H264, H265 and MPEG2 codecs.

Linux driver is currently in the staging area, because v4l2-requests API (universal Linux API for stateless HW video codecs) had not been stabilized, y­et.

That means two things:

Good, efficient video playback solution on PinePhone would involve:

All of the above has proper Linux kernel support in version 5.7, and the only thing that's missing is wiring this together in some userspace program.

Firefox 76 accelerated video

In Linux, there are several common userspace APIs for accelerated video decodeing, out of which cedrus has support for libva via libva-v4l2-request plugin.

This has a potential to support recently added libva based video decoding acceleration in Firefox. The problem is that libva-v4l2-request is not actively maintained, is out of sync with kernel API changes, and thus doesn't work out of the box.

You can try accelerated video decoding in Firefox by running Firefox with:

export LIBVA_DRIVER_NAME=v4l2_request
# If you compile your own libva-v4l2-request and install in /usr/local/
#export LIBVA_DRIVERS_PATH=/usr/local/lib/dri
# You have to identify correct devices for cedrus, these are just examples.
# Check /sys/class/video4linux/*/name and /sys/bus/media/devices/*/model
export LIBVA_V4L2_REQUEST_VIDEO_PATH=/dev/video0
export LIBVA_V4L2_REQUEST_MEDIA_PATH=/dev/media0
export MOZ_ENABLE_WAYLAND=1

firefox

Then you'll need to enable widget.wayland-dmabuf-vaapi.enabled in about:config. You'll need to run Firefox under some wayland compositor for this to work.

Don't expect it to work well or at all.

mpv

You can try to use cedrus from mpv, using:

export LIBVA_DRIVER_NAME=v4l2_request
# If you compile your own libva-v4l2-request and install in /usr/local/
#export LIBVA_DRIVERS_PATH=/usr/local/lib/dri
# You have to identify correct devices for cedrus, these are just examples.
# Check /sys/class/video4linux/*/name and /sys/bus/media/devices/*/model
export LIBVA_V4L2_REQUEST_VIDEO_PATH=/dev/video0
export LIBVA_V4L2_REQUEST_MEDIA_PATH=/dev/media0

mpv --hwdec=vaapi-copy --vo=drm video.mp4

If your libva-v4l2-request, this should play the video in Linux console (no X or wayland running).

Custom solution using ffmpeg

Kwiboo's ffmpeg has direct suport for v4l2 requests. It should be possible to make a custom video player optimized for PinePhone using this version of ffmepg.

And that's what I'm working on intermitten­tly… :)