[LIBVA] Trying to choose render device for vainfo

Update:
It was an upstream issue of the patch’s inability to choose render device.

I have a question on how to change the render device for VAINFO though.

==

Old

To try to make OBS to have lower CPU usage, I looked into this git and built it to do what it does.
https://github.com/GloriousEggroll/arch-obs-studio-latest-ffmpeg-vaapi

Last month, I was able to get VA-API working to generate a streaming with OBS. I did not know if it is really utilizing the iGPU, but there was no error message and it generated a working stream.
However, when I tried it today again, I get the following error

[AVHWDeviceContext @ 0x55e4f574bd40] libva: va_getDriverName() failed with unknown libva error,driver_name=(null)
[AVHWDeviceContext @ 0x55e4f574bd40] Failed to initialise VAAPI connection: -1 (unknown libva error).
warning: [FFMPEG VAAPI encoder: ‘streaming_h264’] Failed to create VAAPI device context: 輸入/輸出錯誤

in console.

Here is the vainfo.

[devops@devops-pc ~]$ LIBVA_DRIVER_NAME=i965 vainfo
libva info: VA-API version 1.1.0
libva info: va_getDriverName() returns 0
libva info: User requested driver ‘i965’
libva info: Trying to open /usr/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_1
libva error: /usr/lib/dri/i965_drv_video.so init failed
libva info: va_openDriver() returns -1
vaInitialize failed with error code -1 (unknown libva error),exit

I found a lots of thread to dealing with the concurrent usage of both iGPU and NVIDIA, and I could not find related thread to this problem, since I am on a desktop trying to do this.

Inxi

System:    Host: devops-pc Kernel: 4.15.13-1-MANJARO x86_64 bits: 64 Desktop: KDE Plasma 5.12.3 
           Distro: Manjaro Linux 17.1.7 Hakoila 
Machine:   Type: Desktop System: ASUS product: All Series v: N/A serial: N/A 
           Mobo: ASUSTeK model: H81M-E v: Rev X.0x serial: N/A UEFI: American Megatrends v: 3601 
           date: 12/15/2017 
CPU:       Dual Core: Intel Celeron G1840 type: MCP speed: 800 MHz min/max: 800/2800 MHz 
Graphics:  Card-1: Intel Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller driver: i915 
           v: kernel 
           Card-2: NVIDIA GP108 [GeForce GT 1030] driver: nvidia v: 390.42 
           Display Server: x11 (X.Org 1.19.6) driver: intel,nvidia resolution: 1920x1080~60Hz 
           OpenGL: renderer: GeForce GT 1030/PCIe/SSE2 v: 4.6.0 NVIDIA 390.42 
Network:   Card-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller driver: r8169 
Drives:    HDD Total Size: 698.65 GiB used: 165.94 GiB (23.8%) 
Info:      Processes: 206 Uptime: 4:01 Memory: 7.67 GiB used: 2.41 GiB (31.4%) Shell: bash inxi: 2.9.08 

xorg.conf

I also modified my xorg.conf

[devops@devops-pc ~]$ cat /etc/X11/xorg.conf.d/90-mhwd.conf 
# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 384.98  (buildmeister@swio-display-x86-rhel47-02)  Thu Oct 26 15:56:05 PDT 2017

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
#    Inactive       "intel"
EndSection

Section "Files"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    HorizSync       28.0 - 33.0
    VertRefresh     43.0 - 72.0
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BusID          "PCI:1:0:0"
        Option "NoLogo" "1"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

Section "Extensions"
    Option         "Composite" "Enable"
EndSection

 
Section "InputClass"
        Identifier          "Keyboard Defaults"
        MatchIsKeyboard     "yes"
        Option              "XkbOptions" "terminate:ctrl_alt_bksp"
EndSection
 

Section "Device"
    Identifier "intel"
    Driver "intel"
    BusID "PCI:0:2:0"
            Option "AccelMethod" "sna"
EndSection

Section "Screen"
    Identifier     "intel"
    Device         "intel"
EndSection

1 Like

It would be very great if you could share your experience here.

Have you tried using OpenGL 3.1 instead of 2.0 in the KDE System Settings>Display & Monitor>Compositor?

currently using xrender for that and sadly, changing compositor makes no difference.

since your machine seems to have all the proper drivers, is only the question what libva you installed … so, make sure is the good one :wink:

lib32-libva 1.8.3-1
lib32-libva-intel-driver 1.8.3-1
lib32-libva-mesa-driver 18.0.0-0
lib32-libva-vdpau-driver 0.7.4-5
libva 2.1.0-1
libva-intel-driver 2.1.0-1
libva-mesa-driver 18.0.0-0
libva-utils 2.1.0-1
libva-vdpau-driver 0.7.4-3

Basically everything related I could find.:sweat_smile:
BTW, is it related if I have enabled nvidia kms?

So, if it was working before, but not now, what has changed?

The time it was working is right after I compiled the package above, and immediately broadcasted a stream using VAAPI.

As it was working, I didnt even tried vainfo. And it does not generate a stream now. I do not really remember what have been changed.

Have you tried re-compiling the package?

It is not possible currently, complaining about invalid git for obs-studio

Please post full error messages so other people can see exactly what’s going on.

As it is, I suspect you have a $SRCDEST set in /etc/makepkg.conf; if so, you need to remove the existing repo clone.

Is this a git repo?

cd /home/devops/arch-obs-studio-latest-ffmpeg-vaapi/obs-studio
git status
git describe
ls

Even when I manually remove the directory obs-studio, the same message appears.

[devops@devops-pc obs-studio]$ git status
fatal: This operation must be run in a work tree

git status in existing obs-studio:

Have obs-studio folder removed:

[devops@devops-pc arch-obs-studio-latest-ffmpeg-vaapi]$ makepkg
==> 製作軟體包中:obs-studio 21.0.3_54_g55e1865a-1 (Sat Apr  7 00:38:14 HKT 2018)
==> 正在檢查執行時期依賴關係...
==> 正在檢查建置時期依賴關係...
==> 擷取來源中...
  -> 再製 obs-studio git 庫中...
Cloning into bare repository '/home/devops/gits/arch-obs-studio-latest-ffmpeg-vaapi/obs-studio'...
remote: Counting objects: 53403, done.
remote: Compressing objects: 100% (182/182), done.
remote: Total 53403 (delta 114), reused 102 (delta 48), pack-reused 53169
Receiving objects: 100% (53403/53403), 31.82 MiB | 7.96 MiB/s, done.
Resolving deltas: 100% (35054/35054), done.
  -> 更新 ftl-sdk git 庫中...
Fetching origin
remote: Counting objects: 9, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 9 (delta 3), reused 8 (delta 3), pack-reused 0
Unpacking objects: 100% (9/9), done.
From https://github.com/Mixer/ftl-sdk
   5dedec9..c4c28de  refs/pull/66/head  -> refs/pull/66/head
 + e7f8bb5...b45ede5 refs/pull/66/merge -> refs/pull/66/merge  (forced update)
  -> 找到 ffmpeg-vaapi.patch
==> 正在以 source 驗證 md5sums 檔案...
    obs-studio ... 已略過
    ftl-sdk ... 已略過
    ffmpeg-vaapi.patch ... 已略過
==> 正在解開來源...
  -> 正在建立 obs-studio git 庫的工作副本...
fatal: '/home/devops/arch-obs-studio-latest-ffmpeg-vaapi/obs-studio' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
==> 錯誤: 更新 obs-studio git 庫的工作副本時失敗
    正在中止...

Upstream issue is here:

System:    Host: GlaDOS Kernel: 4.16.2-1-MANJARO x86_64 bits: 64 Console: tty 1
           Distro: Manjaro Linux 17.1.8 Hakoila
Machine:   Type: Desktop System: ASUS product: All Series v: N/A serial: N/A
           Mobo: ASUSTeK model: H81M-E v: Rev X.0x serial: 150239448903979 UEFI: American Megatrends v: 3601
           date: 12/15/2017
CPU:       Dual Core: Intel Celeron G1840 type: MCP speed: 800 MHz min/max: 800/2800 MHz
Graphics:  Card-1: Intel Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics driver: i915 v: kernel
           Card-2: NVIDIA GP108 [GeForce GT 1030] driver: nvidia v: 390.48
           Display Server: X.Org 1.19.6 driver: nvidia resolution: 1920x1080~60Hz
           OpenGL: renderer: GeForce GT 1030/PCIe/SSE2 v: 4.6.0 NVIDIA 390.48
Network:   Card-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet driver: r8168
Drives:    HDD Total Size: 698.65 GiB used: 184.92 GiB (26.5%)
Info:      Processes: 201 Uptime: 29m Memory: 7.67 GiB used: 1.83 GiB (23.9%) Shell: bash inxi: 3.0.00

still trying LIBVA_DRIVER_NAME=i965 vainfo

The result is the same.

[GlaDOS ~]# LIBVA_DRIVER_NAME=i965 vainfo
error: XDG_RUNTIME_DIR not set in the environment.
libva info: VA-API version 1.1.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'i965'
libva info: Trying to open /usr/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_1
libva error: /usr/lib/dri/i965_drv_video.so init failed
libva info: va_openDriver() returns -1
vaInitialize failed with error code -1 (unknown libva error),exit

I also tried on a fresh Win10 install, and it worked to recorded using QSV. I have yet to try testing on other linux distro.

In case any of you do not know what is “iGpu multi-monitor” mentioned here, here is the reference : https://itstillworks.com/enable-onboard-video-asus-11643.html

Xorg.0.log

When I try ffmpeg, it did made an output

Perhaps I should figure out how to direct vainfo to using renderD129?

[devops@GlaDOS Movies]$ LD_PRELOAD=/usr/lib/dri/i965_drv_video.so LIBVA_DRIVER_NAME=i965 ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD129 -i '2018-04-29 21-36-03.mkv' -vf 'format=nv12|vaapi,hwupload' -threads 8 -c:v h264_vaapi -preset slower -c:a libopus "f-new.mkv"   
ffmpeg version 3.4.2 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 7.3.0 (GCC)
  configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-avresample --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libass --enable-libbluray --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-shared --enable-version3 --enable-omx
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Input #0, matroska,webm, from '2018-04-29 21-36-03.mkv':
  Metadata:
    ENCODER         : Lavf57.83.100
  Duration: 00:00:17.10, start: 0.000000, bitrate: 1373 kb/s
    Stream #0:0: Video: h264 (Constrained Baseline), yuv420p(progressive), 1280x720, 1k fps, 30 tbr, 1k tbn, 60 tbc (default)
    Metadata:
      DURATION        : 00:00:17.100000000
    Stream #0:1: Audio: aac (LC), 44100 Hz, stereo, fltp (default)
    Metadata:
      title           : Track1
      DURATION        : 00:00:17.090000000
Codec AVOption preset (Configuration preset) specified for output file #0 (f-new.mkv) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.        
File 'f-new.mkv' already exists. Overwrite ? [y/N] y
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_vaapi))
  Stream #0:1 -> #0:1 (aac (native) -> opus (libopus))
Press [q] to stop, [?] for help
[libopus @ 0x558643eba880] No bit rate set. Defaulting to 96000 bps.
Output #0, matroska, to 'f-new.mkv':
  Metadata:
    encoder         : Lavf57.83.100
    Stream #0:0: Video: h264 (h264_vaapi) (High) (H264 / 0x34363248), vaapi_vld, 1280x720, q=0-31, 30 fps, 1k tbn, 30 tbc (default)
    Metadata:
      DURATION        : 00:00:17.100000000
      encoder         : Lavc57.107.100 h264_vaapi
    Stream #0:1: Audio: opus (libopus) ([255][255][255][255] / 0xFFFFFFFF), 48000 Hz, stereo, flt, 96 kb/s (default)
    Metadata:
      title           : Track1
      DURATION        : 00:00:17.090000000
      encoder         : Lavc57.107.100 libopus
Invalid return value 0 for stream protocol time=00:00:16.59 bitrate=1001.9kbits/s speed=6.62x    
    Last message repeated 1 times
frame=  513 fps=197 q=-0.0 Lsize=    2222kB time=00:00:17.11 bitrate=1063.4kbits/s speed=6.58x    
video:2209kB audio:3kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.439519%

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.

Forum kindly sponsored by