[FFmpeg-user] init_hw_device qsv for hwaccel on Skylake iGPU + Nvidia GF GPU

Terje Hanssen terjejhanssen at gmail.com
Mon Sep 2 22:35:27 EEST 2024


Den 02.09.2024 15:58, skrev Wang, Fei W:
> On Mon, 2024-09-02 at 15:29 +0200, Terje J. Hanssen wrote:
>>
>>
>> On 9/2/24 07:01, Wang, Fei W wrote:
>>
>>> On Sun, 2024-09-01 at 10:53 +0200, Terje J. Hanssen wrote:
>>>
>>>> I have not succeeded yet to configure ffmpeg QSV access to an enabled
>>>> iGPU onboard  an Intel Core i7-6700K (Skylake). This is a legacy,
>>>> rebuilt workstation with additional, discrete Nvidia GeForce GTX 960
>>>> GPU
>>>> on a MSI-Z170-A Pro mobo.
>>>> Any suggestions how to solve this?
>>> You can use vainfo to find the Intel gpu device correctly:
>>> "vainfo --display drm --device /dev/dri/renderD12X"
>>> Then specify device in ffmpeg cmdline with "-qsv_device
>>> /dev/dri/renderD12X"
>>> BTW, for legacy platforms, suggest to use libvpl with Media SDK for the
>>> runtime implementation:
>>> https://github.com/intel/libvpl
>>> https://github.com/Intel-Media-SDK/MediaSDK
>>> Thanks
>>> Fei
>> @Fei, thanks for your suggestion that hopefully will probe me in the 
>> right direction.
>> Right now, I will be absent from my Skylake workstation a week or 
>> two, before I can test more directly on it. But I did preserve some 
>> more output I will add and refer to below.
>>
>> In the meantime I also can do a bit indirectly tests on my available 
>> Kaby Lake XPS-13 with UHD 620 iGPU and a similar system installation:
>>
>>     vainfo --display drm --device /dev/dri/renderD12X
>>     Trying display: drm
>>     Failed to open the given device!
>>
>> As this don't find any device on Kaby Lake, I expect I rather have to 
>> put in a number "8" instead of "X" as found on Kaby Lake(?)
>
> Yes, X stands for 8 or 9. To find the Intel device node if vainfo 
> shows the correct message.
>
>>
>>     ls /dev/dri
>>     by-path  card1  renderD128
>>
>> When I try
>>
>>> vainfo --display drm --device /dev/dri/renderD12*
>> or
>>
>>> vainfo --display drm --device /dev/dri/renderD128
>> This simingly output just the same as "vainfo" alone on KabyLake.
>>
>> And I have the latter preserved also from Skylake as follows:
>>
>>> vainfo
>>> Trying display: wayland
>>> libva info: VA-API version 1.22.0
>>> libva info: Trying to open /usr/lib64/dri/iHD_drv_video.so
>>> libva info: Found init function __vaDriverInit_1_21
>>> libva info: va_openDriver() returns 0
>>> vainfo: VA-API version: 1.22 (libva 2.22.0)
>>> vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 
>>> 24.1.5 ()
>>> vainfo: Supported profile and entrypoints
>>>       VAProfileNone :    VAEntrypointVideoProc
>>>       VAProfileNone :    VAEntrypointStats
>>>       VAProfileMPEG2Simple :    VAEntrypointVLD
>>>       VAProfileMPEG2Simple :    VAEntrypointEncSlice
>>>       VAProfileMPEG2Main :    VAEntrypointVLD
>>>       VAProfileMPEG2Main :    VAEntrypointEncSlice
>>>       VAProfileH264Main :    VAEntrypointVLD
>>>       VAProfileH264Main :    VAEntrypointEncSlice
>>>       VAProfileH264Main :    VAEntrypointFEI
>>>       VAProfileH264Main :    VAEntrypointEncSliceLP
>>>       VAProfileH264High :    VAEntrypointVLD
>>>       VAProfileH264High :    VAEntrypointEncSlice
>>>       VAProfileH264High :    VAEntrypointFEI
>>>       VAProfileH264High :    VAEntrypointEncSliceLP
>>>       VAProfileVC1Simple :    VAEntrypointVLD
>>>       VAProfileVC1Main :    VAEntrypointVLD
>>>       VAProfileVC1Advanced :    VAEntrypointVLD
>>>       VAProfileJPEGBaseline :    VAEntrypointVLD
>>>       VAProfileJPEGBaseline :    VAEntrypointEncPicture
>>> VAProfileH264ConstrainedBaseline:    VAEntrypointVLD
>>> VAProfileH264ConstrainedBaseline:    VAEntrypointEncSlice
>>> VAProfileH264ConstrainedBaseline:    VAEntrypointFEI
>>> VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
>>>       VAProfileVP8Version0_3 :    VAEntrypointVLD
>>>       VAProfileVP8Version0_3 :    VAEntrypointEncSlice
>>>       VAProfileHEVCMain :    VAEntrypointVLD
>>>       VAProfileHEVCMain :    VAEntrypointEncSlice
>>>       VAProfileHEVCMain :    VAEntrypointFEI
>> ---------------
>>
>>
>> If  /dev/dri/card2 and /dev/dri/renderD129 refer to the Skylake HD 
>> 530 iGPU
>> (and /dev/dri/card1 and /dev/dri/renderD128 refer to  the Nvidia GPU),
>> I cannot understand why the initial, second ffmpeg command in section 
>> 2) below did report  errors?
>>
>> Possibly syntax error or something else?
>

> The command looks good. There are 2 run-time implementation Media SDK 
> and vpl-gpu-rt for libvpl(
> more details can be found on github of libvpl: 
> https://github.com/intel/libvpl).
> While only Media SDK supported on Skylake. So you may check if you 
> installed Meida SDK on your Skylake
> but not vpl-gpu-rt.
>
> Thanks
> Fei
>
>>

I only install and have installed related, pre-build distribution 
packages for openSUSE Tumbleweed Slowroll. Here they are sorted in two 
lists, to get both the summary descriptions and version numbers, in case 
something clarify if Media SDK RT is among them(?)

zypper se -i nvidia vulkan mesa nouveau intel
Laster pakkebrønndata...
Leser installerte pakker...

S  | Name                           | Summary | Type
---+--------------------------------+-------------------------------------------------------------------------+------
i+ | intel-gpu-tools                | Collection of tools for 
development and testing of the Intel DRM driver | pakke
i+ | intel-media-driver             | Intel Media Driver for 
VAAPI                                            | pakke
i  | kernel-firmware-intel          | Kernel firmware files for 
Intel-platform device drivers                 | pakke
i  | kernel-firmware-nvidia         | Kernel firmware files for Nvidia 
Tegra and graphics drivers             | pakke
i  | libdrm_intel1                  | Userspace interface for Kernel DRM 
services for Intel chips             | pakke
i  | libdrm_nouveau2                | Userspace interface for Kernel DRM 
services for NVIDIA chips            | pakke
i  | libgstvulkan-1_0-0             | GStreamer Streaming-Media 
Framework Plug-Ins                            | pakke
i  | libnvidia-egl-wayland1         | The EGLStream-based Wayland 
external platform                           | pakke
i+ | libvdpau_nouveau               | VDPAU state tracker for 
Nouveau                                         | pakke
i  | libvulkan1                     | The Vulkan 3D graphics and compute 
API                                  | pakke
i+ | libvulkan_intel                | Mesa vulkan driver for Intel 
GPU                                        | pakke
i  | Mesa                           | System for rendering 3-D 
graphics                                       | pakke
i  | Mesa-demo-x                    | GLX-based 
demos                                                         | pakke
i  | Mesa-dri                       | DRI plug-ins for 3D 
acceleration                                        | pakke
i  | Mesa-gallium                   | Mesa Gallium GPU 
drivers                                                | pakke
i  | Mesa-libEGL1                   | EGL API 
implementation                                                  | pakke
i  | Mesa-libGL1                    | The GL/GLX runtime of the Mesa 3D 
graphics library                      | pakke
i  | Mesa-libglapi0                 | Free implementation of the GL 
API                                       | pakke
i  | Mesa-libva                     | Mesa VA-API 
implementation                                              | pakke
i  | Mesa-vulkan-device-select      | Vulkan layer to select Vulkan 
devices provided by Mesa                  | pakke
i  | nvidia-compute-G06             | NVIDIA driver for computing with 
GPGPU                                  | pakke
i  | nvidia-compute-G06-32bit       | 32bit NVIDIA driver for computing 
with GPGPU                            | pakke
i+ | nvidia-driver-G06-kmp-default  | NVIDIA graphics driver kernel 
module for GeForce 700 series and newer   | pakke
i  | nvidia-gl-G06                  | NVIDIA OpenGL libraries for OpenGL 
acceleration                         | pakke
i  | nvidia-gl-G06-32bit            | 32bit NVIDIA OpenGL libraries for 
OpenGL acceleration                   | pakke
i  | nvidia-video-G06               | NVIDIA graphics driver for GeForce 
700 series and newer                 | pakke
i  | nvidia-video-G06-32bit         | 32bit NVIDIA graphics driver for 
GeForce 700 series and newer           | pakke
i+ | openSUSE-repos-Slowroll-NVIDIA | openSUSE NVIDIA repository 
definitions                                  | pakke
i+ | ucode-intel                    | Microcode Updates for Intel 
x86/x86-64 CPUs                             | pakke
i+ | vulkan-tools                   | Diagnostic utilities for 
Vulkan                                         | pakke


zypper se -is nvidia vulkan mesa nouveau intel
Laster pakkebrønndata...
Leser installerte pakker...

S  | Name                           | Type  | Version               | 
Arch   | Repository
---+--------------------------------+-------+-----------------------+--------+------------------------
i+ | intel-gpu-tools                | pakke | 1.28-3.4              | 
x86_64 | repo-oss
i+ | intel-media-driver             | pakke | 24.1.5-1.1            | 
x86_64 | repo-oss
i  | kernel-firmware-intel          | pakke | 20240809-1.1          | 
noarch | update-slowroll
i  | kernel-firmware-nvidia         | pakke | 20240809-1.1          | 
noarch | update-slowroll
i  | libdrm_intel1                  | pakke | 2.4.122-1.1           | 
x86_64 | repo-oss
i  | libdrm_nouveau2                | pakke | 2.4.122-1.1           | 
x86_64 | repo-oss
i  | libgstvulkan-1_0-0             | pakke | 1.24.6-1.1            | 
x86_64 | repo-oss
i  | libnvidia-egl-wayland1         | pakke | 1.1.15-1.1            | 
x86_64 | update-slowroll
i+ | libvdpau_nouveau               | pakke | 24.1.5-1699.393.pm.1  | 
x86_64 | Packman
i+ | libvdpau_nouveau               | pakke | 24.1.5-1699.393.pm.1  | 
x86_64 | Packman
i  | libvulkan1                     | pakke | 1.3.290-1.1           | 
x86_64 | repo-oss
i+ | libvulkan_intel                | pakke | 24.1.5-1699.393.pm.1  | 
x86_64 | Packman
i+ | libvulkan_intel                | pakke | 24.1.5-1699.393.pm.1  | 
x86_64 | Packman
i  | Mesa                           | pakke | 24.1.5-1699.393.pm.1  | 
x86_64 | Packman
i  | Mesa                           | pakke | 24.1.5-1699.393.pm.1  | 
x86_64 | Packman
i  | Mesa-demo-x                    | pakke | 9.0.0-3.3             | 
x86_64 | repo-oss
i  | Mesa-dri                       | pakke | 24.1.5-1699.393.pm.1  | 
x86_64 | Packman
i  | Mesa-dri                       | pakke | 24.1.5-1699.393.pm.1  | 
x86_64 | Packman
i  | Mesa-gallium                   | pakke | 24.1.5-1699.393.pm.1  | 
x86_64 | Packman
i  | Mesa-gallium                   | pakke | 24.1.5-1699.393.pm.1  | 
x86_64 | Packman
i  | Mesa-libEGL1                   | pakke | 24.1.5-1699.393.pm.1  | 
x86_64 | Packman
i  | Mesa-libEGL1                   | pakke | 24.1.5-1699.393.pm.1  | 
x86_64 | Packman
i  | Mesa-libGL1                    | pakke | 24.1.5-1699.393.pm.1  | 
x86_64 | Packman
i  | Mesa-libGL1                    | pakke | 24.1.5-1699.393.pm.1  | 
x86_64 | Packman
i  | Mesa-libglapi0                 | pakke | 24.1.5-1699.393.pm.1  | 
x86_64 | Packman
i  | Mesa-libglapi0                 | pakke | 24.1.5-1699.393.pm.1  | 
x86_64 | Packman
i  | Mesa-libva                     | pakke | 24.1.5-1699.393.pm.1  | 
x86_64 | Packman
i  | Mesa-libva                     | pakke | 24.1.5-1699.393.pm.1  | 
x86_64 | Packman
i  | Mesa-vulkan-device-select      | pakke | 24.1.5-1699.393.pm.1  | 
x86_64 | Packman
i  | Mesa-vulkan-device-select      | pakke | 24.1.5-1699.393.pm.1  | 
x86_64 | Packman
i  | nvidia-compute-G06             | pakke | 550.100-25.1          | 
x86_64 | repo-non-free
i  | nvidia-compute-G06             | pakke | 550.100-25.1          | 
x86_64 | nVidia Graphics Drivers
i  | nvidia-compute-G06-32bit       | pakke | 550.100-25.1          | 
x86_64 | repo-non-free
i  | nvidia-compute-G06-32bit       | pakke | 550.100-25.1          | 
x86_64 | nVidia Graphics Drivers
i+ | nvidia-driver-G06-kmp-default  | pakke | 550.100_k6.9.7_1-25.1 | 
x86_64 | repo-non-free
i+ | nvidia-driver-G06-kmp-default  | pakke | 550.100_k6.9.7_1-25.1 | 
x86_64 | nVidia Graphics Drivers
i  | nvidia-gl-G06                  | pakke | 550.100-25.1          | 
x86_64 | repo-non-free
i  | nvidia-gl-G06                  | pakke | 550.100-25.1          | 
x86_64 | nVidia Graphics Drivers
i  | nvidia-gl-G06-32bit            | pakke | 550.100-25.1          | 
x86_64 | repo-non-free
i  | nvidia-gl-G06-32bit            | pakke | 550.100-25.1          | 
x86_64 | nVidia Graphics Drivers
i  | nvidia-video-G06               | pakke | 550.100-25.1          | 
x86_64 | repo-non-free
i  | nvidia-video-G06               | pakke | 550.100-25.1          | 
x86_64 | nVidia Graphics Drivers
i  | nvidia-video-G06-32bit         | pakke | 550.100-25.1          | 
x86_64 | repo-non-free
i  | nvidia-video-G06-32bit         | pakke | 550.100-25.1          | 
x86_64 | nVidia Graphics Drivers
i+ | openSUSE-repos-Slowroll-NVIDIA | pakke | 20240712.dd8c2eb-1.1  | 
x86_64 | repo-oss
i+ | ucode-intel                    | pakke | 20240813-1.1          | 
x86_64 | update-slowroll
i+ | vulkan-tools                   | pakke | 1.3.290-1.1           | 
x86_64 | repo-oss

--------------


Beyond sdk/vainfo, I also preserved and add the following ffmpeg test 
with Vulkan and Vulkan-info output, in case they throw more light on the 
issue:

    Skylake (i7-6700K/Nvidia)
    ffmpeg -hide_banner -init_hw_device "vulkan=vk:0" -hwaccel vulkan
    -hwaccel_output_format vulkan -i h264_8bit_yuv420p.mp4 -f null -

         Stream #0:0 -> #0:0 (h264 (native) -> wrapped_avframe (native))
         Press [q] to stop, [?] for help
         [h264 @ 0x55921d474200] Device does not support the
    VK_KHR_video_decode_queue extension!
         [h264 @ 0x55921d474200] Failed setup for format vulkan: hwaccel
    initialisation returned error.
    frame= 1780 fps=430 q=-0.0 Lsize=N/A time=00:01:11.20 bitrate=N/A
    speed=17.2x


    vulkaninfo | egrep 'GPU|driver'
         VK_LUNARG_direct_driver_loading : extension revision 1
             GPU id = 0 (Intel(R) HD Graphics 530 (SKL GT2))
             GPU id = 1 (NVIDIA GeForce GTX 960)
             GPU id = 0 (Intel(R) HD Graphics 530 (SKL GT2))
             GPU id = 1 (NVIDIA GeForce GTX 960)
    GPU id : 0 (Intel(R) HD Graphics 530 (SKL GT2)):
    GPU id : 1 (NVIDIA GeForce GTX 960):
    GPU id : 0 (Intel(R) HD Graphics 530 (SKL GT2)):
    GPU id : 1 (NVIDIA GeForce GTX 960):
    GPU0:
         driverVersion     = 24.1.5 (100667397)
         deviceType        = PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU
         driverUUID                        =
    cc628f46-3d02-8624-0c8a-e98e0420c4f6
    driverID                                             =
    DRIVER_ID_INTEL_OPEN_SOURCE_MESA
    driverName                                           = Intel
    open-source Mesa driver
    driverInfo                                           = Mesa 24.1.5
    VK_KHR_driver_properties                      : extension revision 1
    GPU1:
         driverVersion     = 550.100.0.0 (2308505600)
         deviceType        = PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
         driverUUID                        =
    63390c76-60ef-5529-a6ac-99167eb42a9c
    driverID                                             =
    DRIVER_ID_NVIDIA_PROPRIETARY
    driverName                                           = NVIDIA
    driverInfo                                           = 550.100
    VK_KHR_driver_properties                      : extension revision 1





>>
>>>
>>>> My tested ffmpeg code lines and system information below.
>>>> 1) Tested first this simple ffmpeg decode bencmark code line from
>>>> https://trac.ffmpeg.org/wiki/Hardware/QuickSync#Decode-only
>>>> This works fine on single GPU Caby Lake/UHD 620 and on Alder Lake/Arc
>>>> A750, but on Skylake with dual iGPU HD 530 and a Nvidia GeForce GTX
>>>> 960
>>>> card, these errors are reported:
>>>>      ffmpeg -hide_banner -hwaccel qsv -hwaccel_output_format qsv -i
>>>>      h264_8bit_yuv420p.mp4 -f null -
>>>>      ....
>>>>      [AVHWDeviceContext @ 0x55bed1a7c500] Error creating a MFX
>>>> session: -9.
>>>>      Device creation failed: -1313558101.
>>>>      [vist#0:0/h264 @ 0x55bed1a656c0] [dec:h264_qsv @ 0x55bed1a64300]
>>>> No
>>>>      device available for decoder: device type qsv needed for codec
>>>> h264_qsv.
>>>>      [vist#0:0/h264 @ 0x55bed1a656c0] [dec:h264_qsv @ 0x55bed1a64300]
>>>>      Hardware device setup failed for decoder: Unknown error occurred
>>>>      [vost#0:0/wrapped_avframe @ 0x55bed1a63740] Error initializing a
>>>>      simple filtergraph
>>>>      Error opening output file -.
>>>>      Error opening output files: Unknown error occurred
>>>>      bench: maxrss=59076KiB
>>>> 2) Additional tests where I experimented to apply suggestions from
>>>> https://trac.ffmpeg.org/wiki/Hardware/QuickSync#Transcode
>>>>        -qsv_device is an qsv customized option can be used to specify
>>>> a
>>>>      hardware device and avoid the default device initialization
>>>> failure
>>>>      when multiple devices usable (eg: an Intel integrated GPU and an
>>>>      AMD/Nvidia discrete graphics card).
>>>>      ffmpeg -hide_banner -hwaccel qsv -qsv_device /dev/dri/renderD128
>>>> -i
>>>>      h264_8bit_yuv420p.mp4 -f null -
>>>>      DRM_IOCTL_VERSION, unsupported drm device by media driver: nvid
>>>>      DRM_IOCTL_VERSION, unsupported drm device by media driver: nvid
>>>>      [AVHWDeviceContext @ 0x56330da80dc0] libva:
>>>>      /usr/lib64/dri/iHD_drv_video.so init failed
>>>>      [AVHWDeviceContext @ 0x56330da80dc0] Failed to initialise VAAPI
>>>>      connection: 18 (invalid parameter).
>>>>      Device creation failed: -5.
>>>>      Failed to set value '/dev/dri/renderD128' for option
>>>> 'qsv_device':
>>>>      Input/output error
>>>>      Error parsing global options: Input/output error
>>>>      ffmpeg -hide_banner -hwaccel qsv -qsv_device /dev/dri/renderD129
>>>> -i
>>>>      h264_8bit_yuv420p.mp4 -f null -
>>>>      [AVHWDeviceContext @ 0x55deafcbcec0] Error creating a MFX
>>>> session: -9.
>>>>      Device creation failed: -1313558101.
>>>>      Failed to set value '/dev/dri/renderD129' for option
>>>> 'qsv_device':
>>>>      Unknown error occurred
>>>>      Error parsing global options: Unknown error occurred
>>>>      ffmpeg -hide_banner -init_hw_device qsv=hw -filter_hw_device hw
>>>>      -hwaccel_output_format qsv -hwaccel qsv -qsv_device
>>>>      /dev/dri/renderD128 -i h264_8bit_yuv420p.mp4 -f null -
>>>>      [AVHWDeviceContext @ 0x563f568e7e00] Error creating a MFX
>>>> session: -9.
>>>>      Device creation failed: -1313558101.
>>>>      Failed to set value 'qsv=hw' for option 'init_hw_device': Unknown
>>>>      error occurred
>>>>      Error parsing global options: Unknown error occurred
>


More information about the ffmpeg-user mailing list