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

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Matthew Thyer

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.


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

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

Matthew Thyer

Partially answering my own question…

I see that when I built gstreamer-vaapi v1.14.2 module from source that the “DRM backend” is enabled by default “—enable-drm=yes” but from my configure log I see that checking for DRM failed: “checking for DRM... no”.

The configuration summary at the end of my configure output shows only “x11 glx egl wayland” in the “Video outputs” section.

 

So I’m missing some dependency for building the gstreamer-vaapi v1.14.2 module with DRM.

      DRM: libva-dev (>= 1.1.0), libdrm-dev, libudev-dev

 

I’ve now tested by having libdrm-dev & libudev-dev installed before my build and this has provided the DRM Video output.

I still don’t know how to select it at run time!

 

From: Matthew Thyer
Sent: Friday, 14 September 2018 3:30 PM
To: 'Discussion of the development of and with GStreamer' <[hidden email]>
Subject: Headless VA-API hardware accelerated H.264 video encoding with vaapih264enc?

 

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.


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

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

Victor Jaquez
In reply to this post by Matthew Thyer
Hi

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.

vmjl
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

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

Matthew Thyer
Víctor,

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 <[hidden email]> On Behalf Of Víctor Jáquez
Sent: Friday, 14 September 2018 7:00 PM
To: Discussion of the development of and with GStreamer <[hidden email]>
Subject: Re: Headless VA-API hardware accelerated H.264 video encoding with vaapih264enc?

Hi

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.

vmjl
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel