How to install Gstreamer VAAPI plugins on Ubuntu?

10 min. read |

Video Acceleration API (VAAPI) is yet another way to use hardware acceleration to improve video processing performance (1.5-2 times faster than on CPU). The following guide helps to install Gstreamer VAAPI plugins on Ubuntu and provides solutions to most common issues.

Requirements

  • Ubuntu
  • Gstreamer
  • Intel Graphics Card
  • VAAPI

Scripts

Learn how to?

  • install gstreamer-vaapi package and enable VAAPI hardware-accelerated video processing
  • install-update Intel Graphics Drivers

Use gstreamer plugins:

Preface

VAAPI Gstreamer plugins is an alternative to NVIDIA’s ones (recall: “How to install NVIDIA Gstreamer Plugins on Ubuntu“) in order to enable hardware acceleration for video processing. For example, gst-video-analytics framework (check out: “Deep Learning Video Analytics Frameworks“) contains gstreamer plugins for video-analytics with OpenVino. To use framework the target platform must have Intel CPU and Intel Graphics Card. So, if you are restricted to Intel Hardware, then Video Acceleration API is a great choice. In the following guide we are going to provide steps in order to install drivers, requirements and gstreamer package for VA-API support .

Note: In gst-video-analytics framework Intel Media SDK works slower (see: Common Issues Section)

Guide

Environment Setup

  • Ubuntu 18.04.4 LTS
  • Gstreamer 1.14.5
  • Intel Graphics Card 591b

Inspect

To check if VA-API plugins are already installed, use the following command:

Requirements

Check the official gstreamer requirements page for VA-API support.

Check Hardware

Use lshw utility to fetch important hardware information about Intel Graphics Card.

Make sure that VGA compatible device with Intel Drivers present.

Note: install lshw with

Also you can use lspci utility to check same device and drivers.

Note: install lspci with

In addition, you can list available devices in the following location:

Install Drivers

By default Intel Graphics driver is already installed on Ubuntu as xserver-xorg-video-intel. But, to update driver execute next commands:

Now, install VA-API drivers.

In order to list available video drivers type next:

With vainfo (diagnostic tool for VA-API) check that everything is loaded correctly without any warning or mistakes.

Note: install vainfo utility with

Note: Check that under line <supported profile entry points> there is a list of supported Video Accelerated operations.

Pay attention to requested driver ‘i965‘ and driver location /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so. To change this just edit the environmental variables

Or reset:

Install gstreamer-vaapi

The safest way is to install Gstreamer’s VA-API plugin as official Ubuntu package:

Otherwise, you can build it by yourself using the following commands.

Intel Graphics Card monitoring tool

To check Intel Graphics card load use the next command:

Note: Here is a brief explanation of intel-gpu-top output.

In addition, there is a prepared docker container that allows you to build everything as discussed previously.

VAAPI-accelerated pipelines

Hardware specifications

  • GPU GeForce GTX 1050
  • CPU Intel(R) Core(TM) i7-7700HQ @ 2.80GHz

Plugins performance

For performance evaluation we are going to use Jumanji: The Next Level Final Trailer (2019) (check out “Nvidia Gstreamer Plugins. Section: Nvidia-accelerated pipelines”). Video’s resolution and frames count:

Decoding (H264)

First, decode video with avdec_h264 (CPU-based plugin):

Note: Intel Graphics Card remains in idle state (~0%) while CPU is almost loaded with work (70%).

Now, decode video with vaapih264dec:

Note: With VA-API decoding enabled, Intel Graphics GPU is busy, while CPU is less loaded than with avdec_h264.

Encoding (H264)

Color conversion (I420-RGBA)

Most Computer Vision/Deep Learning applications require RGB-colorspace and VA-API allows to do color conversion as well (unlike NVIDIA gstreamer plugins)

Summary

Let’s put all the numbers to table and summarize everything.

TransformCPU, %GPU, %Elapsed Time, msFPSPerf.
avdec_h264~739.159~4311.63x
vaapih264dec~40~985.598~705x
x264enc~5033.894~2951.42x
vaapih264enc~206923.788~420x
videoconvert1 core ~809.027~1100x
vaapipostproc1 core ~80489.27~1100x

Note: Video Encoding/Decoding with VA-API can give up to 2 times performance improvement.With image color-space conversion (I420 -> RGBA) there is almost no difference in performance.

Example Pipelines

Write to file

Display Video

how to install nvidia's gstreamer plugins (nvenc, nvdec) on ubuntu

Common issues

Intel Media SDK support

Note: According to Gstreamer-VAAPI 1.16 and libva and Gstreamer VA-API Troubleshooting, – Intel Media SDK is going to be supported since Gstreamer 1.18 and not officially supported yet.

DRM_IOCTL_I915_GEM_APERTURE Failed

With the following exports by Intel Media SDK

You can receive the next warning:

Note: Had received this type of message only using Intel Media SDK.

With the following warning most plugins work with less performance . For example, let’s do simple decoding:

Decoding with VA-API is almost 10 times slower than common CPU-based plugin avdec_h264

In order to fix warning just import original drivers.

Additional. Some plugins (ex: vaapisink) causes Caught SIGSEGV with Intel Media SDK

For further reading checkout Gstreamer VA-API Troubleshooting

Conclusion

With Gstreamer VAAPI plugins you can enable hardware-accelerated video processing and perform encoding/decoding almost 2 times faster. Also with current approach you can parallel video processing to Intel Graphics Card and save CPU for other tasks. VA-API as part of Gstreamer is very useful for building applications based on gst-video-analytics framework

Hope everything worked as expected. In case of any issues, questions, suggestions contact me 😉

References

Add a Comment

Your email address will not be published. Required fields are marked *