Headless VA-API hardware accelerated H.264 video encoding with vaapih264enc?

Matthew Thyer matthew.thyer at adelaide.edu.au
Mon Sep 17 22:19:59 UTC 2018


I've simply re-built gstreamer-vaapi module (tested v1.14.2 & v1.14.3) taking care to ensure that I have the correct pre-requisites install for DRM:
DRM: libva-dev (>= 1.1.0), libdrm-dev, libudev-dev

I then ran my pipeline when SSH connected to the host and it now works.
"aravissrc ! capsfilter caps=video/x-raw,format=(string)UYVY,width=800,height=600,framerate=(fraction)30/1 ! videoconvert ! vaapih264enc ! capsfilter caps=video/x-h264,profile=high ! rtph264pay name=pay0 pt=96"

gst-inspect-1.0 vaapi also shows me 16 elements (7th gen CPU) when before I would get 0 elements when logged in via SSH.
The Windowing environment is still enabled on the host but no-one is logged in that way.
I've just disabled the Windowing environment (systemctl set-default multi-user.target) and rebooted and it's still working.
I'm not sure how it's working but I'm very happy that it is.

-----Original Message-----
From: gstreamer-devel <gstreamer-devel-bounces at lists.freedesktop.org> On Behalf Of Víctor Jáquez
Sent: Friday, 14 September 2018 7:00 PM
To: Discussion of the development of and with GStreamer <gstreamer-devel at lists.freedesktop.org>
Subject: Re: Headless VA-API hardware accelerated H.264 video encoding with vaapih264enc?


On Fri, 14 Sep 2018 at 06:00, Matthew Thyer wrote:
> The Libav Wiki "Hardware/vaapi" page
> (https://wiki.libav.org/Hardware/vaapi)
> states that I should be able to use VA-API hardware acceleration
> without being connected to an X server.
> Quote:
> "The libva driver needs to be attached to a DRM device to work. This
> can be connected either directly or via a running X server. When
> working standalone, it is generally best to use a DRM render node
> (/dev/dri/render*); only use a connection via X if you actually want
> to deal with surfaces inside X (with DRI2, for example)."
> It then gives an example on how to use the DRI rendering device
> directly with the "avconv" utility: avconv -hwaccel vaapi
> -hwaccel_device
> /dev/dri/renderD128 -i ...
> What's the equivalent for the vaapih264enc GStreamer element?  i.e.,
> How do I make it use the DRM device /dev/dri/renderD128 instead of the
> X server?  I can't see any properties of the element that allow me to control this.

vaapih264enc will try to find a usable libva connection by querying other elements in the pipeline (via gstcontext), and the application later. If there is not reply, the vaapi element will iterate a list of possible of connection in a trial-and-error manner.

When the DRM is chosen, it will also iterate over the render nodes available until it find one suitable for VAAPI.

So, if you want to use the DRM connection, you could either

1) run the pipeline without any window environment:

   $ DISPLAY= WAYLAND_DISPLAY= gst-launch-1.0 videotestsrc num-buffers=100 ! vaapih264enc ! fakesink --gst-debug=vaapidisplay:5

And you'll see the created display GstVaapiDisplayDRM

2) *this is no implemented yet for DRM, only for X11 and Wayland* the application can create it's own vaDisplay and can pass it to the pipeline along with the used dri device.

gstreamer-devel mailing list
gstreamer-devel at lists.freedesktop.org

More information about the gstreamer-devel mailing list