Running gstreamer vaapi in docker

1.6k views Asked by At

I'm trying to run Gstreamer vaapi plugin in docker. I only need vaapi decoder with intel backend. In docker, looks like it could support vainfo:

vainfo
error: XDG_RUNTIME_DIR not set in the environment.
error: can't connect to X server!
libva info: VA-API version 1.7.0
libva info: User environment variable requested driver 'iHD'
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_7
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.7 (libva 2.6.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 20.1.1 ()
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSliceLP
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSliceLP
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD

but there's no any element shown on gst-inspect-1.0 vaapi (build gstreamer from gst-build 1.18) Here's the step I inspect vaapi run docker with:

docker run -it --rm --privileged \
       -v /dev:/dev \
       gstreamer_docker \
       bash
export GST_VAAPI_ALL_DRIVERS=1
export LIBVA_DRIVER_NAME=iHD
export LIBVA_DRIVERS_PATH=/usr/lib/x86_64-linux-gnu/dri
gst-inspect-1.0 vaapi

Having some clue that when I look into gstreamer-vaapi, all elements require display. Does anyone have experience running vaapi decoder in docker?

2

There are 2 answers

0
Ricky On

Just found that I miss libdrm-dev before building plugins. Then gstreamer vaapi plugin would find drm display.

0
Antonin Rousset On

In order to use gstreamer-vaapi within a docker I had to use the docker flag --device=/dev/dri/:/dev/dri/ and install libdrm-dev and libva-dev on Debian.

You may also need to install more drivers (e.g. i965-va-driver) according to your GPU.