intel / libvpl

Intel® Video Processing Library (Intel® VPL) API, dispatcher, and examples
https://intel.github.io/libvpl/
MIT License
262 stars 80 forks source link

ffmpeg libva: Failed to get device id from the driver. Please consider to upgrade the driver to support VA-API 1.15.0 #112

Closed WangFengtu1996 closed 6 months ago

WangFengtu1996 commented 8 months ago

Env

./autogen.sh ./configure make -j sudo make install

* intel-vaapi-driver

version master 2023年 10月 24日 星期二 18:54:08 CST

./autogen.sh ./configure make -j sudo make install

* gmmlib

version master 2023年 10月 24日 星期二 18:54:08 CST

cmake -B build . sudo cmake --build build --target install --parallel 16

* media-driver

version master 2023年 10月 24日 星期二 18:54:08 CST

cmake -B build . sudo cmake --build build --target install --parallel 16


* oneVPL-intel-gpu

version master 2023年 10月 24日 星期二 18:54:08 CST

cmake -B build . sudo cmake --build build --target install --parallel 16

* oneVPL

version master 2023年 10月 24日 星期二 18:54:08 CST

sudo script/bootstrap script/build sudo script/install


* ffmpeg

version 6.0

./configure --enable-libv4l2 --enable-libx264 --enable-libvpl --enable-gpl --disable-x86asm --enable-shared make -j sudo make install

# verify
* vainfo

(base) wang@wang-Inspiron-3020-S:~$ vainfo Trying display: wayland libva info: VA-API version 1.21.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_14 libva info: va_openDriver() returns 0 vainfo: VA-API version: 1.21 (libva 2.18.0) vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 22.3.1 () vainfo: Supported profile and entrypoints VAProfileNone : VAEntrypointVideoProc VAProfileNone : VAEntrypointStats VAProfileMPEG2Simple : VAEntrypointVLD VAProfileMPEG2Main : VAEntrypointVLD VAProfileH264Main : VAEntrypointVLD VAProfileH264Main : VAEntrypointEncSliceLP VAProfileH264High : VAEntrypointVLD VAProfileH264High : VAEntrypointEncSliceLP VAProfileJPEGBaseline : VAEntrypointVLD VAProfileJPEGBaseline : VAEntrypointEncPicture VAProfileH264ConstrainedBaseline: VAEntrypointVLD VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP VAProfileHEVCMain : VAEntrypointVLD VAProfileHEVCMain : VAEntrypointEncSliceLP VAProfileHEVCMain10 : VAEntrypointVLD VAProfileHEVCMain10 : VAEntrypointEncSliceLP VAProfileVP9Profile0 : VAEntrypointVLD VAProfileVP9Profile0 : VAEntrypointEncSliceLP VAProfileVP9Profile1 : VAEntrypointVLD VAProfileVP9Profile1 : VAEntrypointEncSliceLP VAProfileVP9Profile2 : VAEntrypointVLD VAProfileVP9Profile2 : VAEntrypointEncSliceLP VAProfileVP9Profile3 : VAEntrypointVLD VAProfileVP9Profile3 : VAEntrypointEncSliceLP VAProfileHEVCMain12 : VAEntrypointVLD VAProfileHEVCMain422_10 : VAEntrypointVLD VAProfileHEVCMain422_12 : VAEntrypointVLD VAProfileHEVCMain444 : VAEntrypointVLD VAProfileHEVCMain444 : VAEntrypointEncSliceLP VAProfileHEVCMain444_10 : VAEntrypointVLD VAProfileHEVCMain444_10 : VAEntrypointEncSliceLP VAProfileHEVCMain444_12 : VAEntrypointVLD VAProfileHEVCSccMain : VAEntrypointVLD VAProfileHEVCSccMain : VAEntrypointEncSliceLP VAProfileHEVCSccMain10 : VAEntrypointVLD VAProfileHEVCSccMain10 : VAEntrypointEncSliceLP VAProfileHEVCSccMain444 : VAEntrypointVLD VAProfileHEVCSccMain444 : VAEntrypointEncSliceLP VAProfileAV1Profile0 : VAEntrypointVLD VAProfileHEVCSccMain444_10 : VAEntrypointVLD VAProfileHEVCSccMain444_10 : VAEntrypointEncSliceLP

* ffmpeg

ffmpeg -hwaccel qsv -c:v h264_qsv -i 10daojishi.mp4 -c:v h264_qsv -global_quality 25 -maxrate 2M test_qvbr.mp4 -v verbose

ffmpeg version 6.0 Copyright (c) 2000-2023 the FFmpeg developers built with gcc 11 (Ubuntu 11.4.0-1ubuntu1~22.04) configuration: --enable-libv4l2 --enable-libx264 --enable-libvpl --enable-gpl --disable-x86asm --enable-shared libavutil 58. 2.100 / 58. 2.100 libavcodec 60. 3.100 / 60. 3.100 libavformat 60. 3.100 / 60. 3.100 libavdevice 60. 1.100 / 60. 1.100 libavfilter 9. 3.100 / 9. 3.100 libswscale 7. 1.100 / 7. 1.100 libswresample 4. 10.100 / 4. 10.100 libpostproc 57. 1.100 / 57. 1.100 [h264 @ 0x5594275e28c0] Reinit context to 1920x1088, pix_fmt: yuv420p WARNING: defaulting hwaccel_output_format to qsv for compatibility with old commandlines. This behaviour is DEPRECATED and will be removed in the future. Please explicitly set "-hwaccel_output_format qsv". Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '10daojishi.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf56.4.101 Duration: 00:10:08.36, start: 0.000000, bitrate: 189 kb/s Stream #0:00x1: Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p(progressive, left), 1920x1080 (1920x1088), 181 kb/s, 25 fps, 25 tbr, 12800 tbn (default) Metadata: handler_name : VideoHandler vendor_id : [0][0][0][0] Stream #0:10x2: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 2 kb/s (default) Metadata: handler_name : SoundHandler vendor_id : [0][0][0][0] [AVHWDeviceContext @ 0x5594276579c0] Trying to use DRM render node for device 0. [AVHWDeviceContext @ 0x5594276579c0] libva: VA-API version 1.21.0 [AVHWDeviceContext @ 0x5594276579c0] libva: User requested driver 'iHD' [AVHWDeviceContext @ 0x5594276579c0] libva: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so [AVHWDeviceContext @ 0x5594276579c0] libva: Found init function __vaDriverInit_1_14 [AVHWDeviceContext @ 0x5594276579c0] libva: va_openDriver() returns 0 [AVHWDeviceContext @ 0x5594276579c0] Initialised VAAPI connection: version 1.21 [AVHWDeviceContext @ 0x5594276579c0] VAAPI driver: Intel iHD driver for Intel(R) Gen Graphics - 22.3.1 (). [AVHWDeviceContext @ 0x5594276579c0] Driver not found in known nonstandard list, using standard behaviour. [AVHWDeviceContext @ 0x55942760c240] Use Intel(R) oneVPL to create MFX session, API version is 2.9, the required implementation version is 1.3 [AVHWDeviceContext @ 0x55942760c240] libva: Failed to get device id from the driver. Please consider to upgrade the driver to support VA-API 1.15.0 Device creation failed: -1313558101. No device available for decoder: device type qsv needed for codec h264_qsv. Stream mapping: Stream #0:0 -> #0:0 (h264 (h264_qsv) -> h264 (h264_qsv)) Stream #0:1 -> #0:1 (aac (native) -> aac (native)) Device setup failed for decoder on input stream #0:0 : Unknown error occurred [AVIOContext @ 0x559427657280] Statistics: 0 bytes written, 0 seeks, 0 writeouts [AVIOContext @ 0x5594275e9f00] Statistics: 527770 bytes read, 2 seeks


    *  follow [link](https://trac.ffmpeg.org/wiki/Hardware/QuickSync)

# I want to use qsv encode/decode video?
# Can anyone give me some guide?
# Do I need to provide more information?
akwrobel commented 8 months ago

@WangFengtu1996 This error is coming from the FFMpeg layer, not VPL, it is being passed though and output by VPL. This can be seen in code here: https://github.com/FFmpeg/FFmpeg/blob/master/libavutil/hwcontext_qsv.c#L819 We will follow up with the QSV team and update here once have next steps for follow up.

xhaihao commented 8 months ago

@WangFengtu1996

[AVHWDeviceContext @ 0x5594276579c0] libva: VA-API version 1.21.0

Your VAAPI version is 1.21,

[AVHWDeviceContext @ 0x5594276579c0] libva: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
[AVHWDeviceContext @ 0x5594276579c0] libva: Found init function __vaDriverInit_1_14

The init function is __vaDriverInit_1_14, so your media driver was built against against VA-API 1.14. Could you build your driver against VA-API 1.21 ?

akwrobel commented 6 months ago

@WangFengtu1996 Closing as there has been no additional response from the submitter.

SKAntoniou commented 1 month ago

Sorry I know this is closed but I am having the same issue with qsv in ffmpeg, il try keep it short.

ffmpeg -hwaccel qsv -qsv_device ${DEVICE:-/dev/dri/renderD128}

comes up with the same error:

libva: This version of libva doesn't support retrieving the device information from the driver. Please consider to upgrade libva to support VA-API 1.15.0
Device creation failed: -1313558101.

the workaround is using vaapi like this:

ffmpeg -init_hw_device vaapi=va:/dev/dri/renderD128

I couldn't find data on whether this loses performance, but I couldn't test it as I couldn't get it to work. Most of the Intel documentation, though, references the QSV method for media delivery optimisation.

vainfo output shortened:

Trying display: wayland
Trying display: x11
error: can't connect to X server!
Trying display: drm
libva info: VA-API version 1.20.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_20
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.20 (libva 2.20.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 23.4.3 ()
vainfo: Supported profile and entrypoints
      VAProfileNone                   : VAEntrypointVideoProc
      VAProfileNone                   : VAEntrypointStats
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD

Running this on ubuntu server 22.04 HWE, 6.5 kernel. Edit: tried this on ffmpeg 6.1 & 7.0 config:

configuration: --prefix=/usr --extra-version='1build2~22.04' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --disable-librav1e --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --disable-sndio --enable-libjxl --enable-pocketsphinx --enable-librsvg --enable-libvpl --disable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libsvtav1 --enable-libx264 --enable-libplacebo --disable-librav1e --enable-shared
tletnes commented 1 month ago

This error is being raised before VPL is called. The issue is likly due to a conflict in the LibVA versions used for building various components. The team that created the FFMpeg layer is probably your best bet to start figuring this out.

xhaihao commented 1 month ago

@SKAntoniou could you provide the output of the command below ? $ lspci -nn | grep -E "VGA|Display"

SKAntoniou commented 1 month ago

@tletnes Thank you for that information. I'll look at their page.

@xhaihao Thank you in advance for the help; I posted the results below. $ lspci -nn | grep -E "VGA|Display"

00:02.0 VGA compatible controller [0300]: Red Hat, Inc. QXL paravirtual graphic card [1b36:0100] (rev 05)
00:07.0 VGA compatible controller [0300]: Intel Corporation Device [8086:56a6] (rev 05)

This is run in a virtual machine for testing. On the 24.04 LTS server (again in VM), the lspci command would output more detailed information, but I think I could not get the "intel-i915-dkms" package to install correctly on it, as I am assuming the 24.04 is too new and not yet supported by intel.

I will add a few more checks below. ls /dev/dri

by-path  card0  card1  renderD128

card0 on 22.04 is the virtual GPU, card1 & renderD128 will be the Intel card. On 24.04, card0 & card1 switched when all setups were the same for VM.

lspci -nnk | grep VGA -A 3 | grep -E "VGA|driver"

00:02.0 VGA compatible controller [0300]: Red Hat, Inc. QXL paravirtual graphic card [1b36:0100] (rev 05)
    Kernel driver in use: qxl
00:07.0 VGA compatible controller [0300]: Intel Corporation Device [8086:56a6] (rev 05)
    Kernel driver in use: i915

clinfo | grep "Device Name"

  Device Name                                     Intel(R) Arc(TM) A310 Graphics
    Device Name                                   Intel(R) Arc(TM) A310 Graphics
    Device Name                                   Intel(R) Arc(TM) A310 Graphics
    Device Name                                   Intel(R) Arc(TM) A310 Graphics
xhaihao commented 1 month ago

@SKAntoniou Seems your have different versions of libva, and your FFmpeg was built against an older version of libva (VA API version < 1.15.0), could you rebuild your FFmpeg against your libva 2.20 (VA API version 1.20) ?

SKAntoniou commented 1 month ago

@xhaihao Hi, I am unfamiliar with building ffmpeg myself. I tried looking at various documentation and guides but had no luck configuring with enabling libvpl. Do you happen to have any rough data on whether the qsv command/method improves transcode times or if there is a resource to rebuild ffmpeg with a specific libva version? If not, no worries, I will stick with the vaapi method. Thank you for the help.

xhaihao commented 1 month ago

@SKAntoniou FFmpeg with enabling vpl is available in Ubuntu 24.04, you may install the corresponding libraries/applications then try FFmpeg with QSV in Ubuntu 24.04 (The kernel in Ubuntu 24.04 supports your A310, I don't think intel-i915-dkms is needed )

$ sudo apt install ffmpeg libva2 vainfo libvpl2 libmfx-gen1.2 libmfx1 libigdgmm12 intel-media-va-driver
SKAntoniou commented 1 month ago

@xhaihao Thanks, that did fix my vaapi issues but ended up hitting different errors. I don't use jellyfin but these guys had the same errors as me. They are talking about bugs in the kernel but tested forcing 6.7.9 & 6.9.1 on 24.04 with no luck. There were also other errors if I tried different bitrate settings that I couldn't find any lead on.

Gonna give up as spent too much time on this already. Thanks for the help though, may revisit in a few months time.

xhaihao commented 1 month ago

@SKAntoniou Sorry for any trouble caused to you. AFAIK the kernel bug talked about in https://github.com/jellyfin/jellyfin/issues/11626 doesn't impact kernel version 6.8.0 (which is used in Ubuntu 24.04). Please feel free to file any bitrate related issues in https://github.com/intel/cartwheel-ffmpeg when you have time.