thestr4ng3r / chiaki

Moved to https://git.sr.ht/~thestr4ng3r/chiaki - Free and Open Source PS4 Remote Play Client
https://git.sr.ht/~thestr4ng3r/chiaki
2.2k stars 368 forks source link

error while using vaapi #221

Open IamHaddad opened 4 years ago

IamHaddad commented 4 years ago

Hi when i try to use va-api option on arch linux i get this Error message : Failed to initialize Stream Session: avcodec_get_hw_config failed

thestr4ng3r commented 4 years ago

@neptu39701 Do you use the AppImage? If yes, then this is a duplicate of #214. On Arch you should be able to install from AUR.

@grave35 vaapi is not available on macOS at all.

IamHaddad commented 4 years ago

Hi again @thestr4ng3r i installed it from AUR and now i have this error: " Failed to initialize Stream Session: Failed to create hwdevice context " in a window and: " Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway. [I] Discovery Service detected new host with id F8461C0A59C3 [I] Logging to file /home/yuri/.local/share/Chiaki/Chiaki/log/chiaki_session_۲۰۲۰-۰۵-۰۳_۱۰-۱۵-۵۲-۹۴۰۹۴۰.log [I] Chiaki Version 1.2.0 [I] Using hardware decode vaapi [AVHWDeviceContext @ 0x5634fd5ae880] Failed to initialise VAAPI connection: -1 (unknown libva error). " in terminal same problem with appImage

cybern0id commented 4 years ago

I have this issue on Devuan too. I built Chiaki from git master source. My va-api drivers are installed correctly as confirmed by running vainfo. FYI, when running vlc with VA-API I get the same error quickly followed by similar output claiming the driver has been detected and indeed the video plays well.

Chiaki output:

`[I] Chiaki Version 1.2.0`
`[I] Using hardware decode vaapi`
`[AVHWDeviceContext @ 0x564816b20c40] libva: va_getDriverName() failed with unknown libva error,driver_name=(null)`
`[AVHWDeviceContext @ 0x564816b20c40] Failed to initialise VAAPI connection: -1 (unknown libva error).`

vlc output:

`VLC media player 3.0.10 Vetinari (revision 3.0.10-0-g7f145afa84)`
`[00005636596e5540] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.`
`Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.`
`[00005636596e6eb0] main playlist: playlist is empty`
`libva info: VA-API version 1.4.0`
`libva info: va_getDriverName() returns -1`
`libva error: va_getDriverName() failed with unknown libva error,driver_name=(null)`
`[00007f1c100033c0] glconv_vaapi_x11 gl error: vaInitialize: unknown libva error`
`libva info: VA-API version 1.4.0`
`libva info: va_getDriverName() returns 0`
`libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so`
`libva info: Found init function __vaDriverInit_1_4`
`libva info: va_openDriver() returns 0`
`[00007f1c300d3e70] avcodec decoder: Using Intel i965 driver for Intel(R) Ivybridge Mobile - 2.3.0 for hardware decoding`

Edit: I should add that I'm using gdm3+gnome-shell+wayland with Xwayland when required. Running Chiaki with QT_QPA_PLATFORM=wayland results in an invisible stream window after connecting to the PS4 with no video output (only audio is heard). Running Chiaki without environment variable works fine as long as VA-API hw acceleration is not enabled.

meltingrobot commented 4 years ago

Hi, @thestr4ng3r , I have created a manifest for a flatpak that works with vaapi(at least with AMD cards). Would you be interested in it? If so, let me know how/where to send it. I didn't want to put it on flathub since this is your project.

thestr4ng3r commented 4 years ago

You could make a pull request and put it in the scripts/ directory.

meltingrobot commented 4 years ago

Done.

meltingrobot commented 4 years ago

Testing instructions(assuming a working flatpak installation): flatpak-builder --repo=repo --force-clean build-dir com.github.thestr4ng3r.Chiaki.json flatpak --user remote-add --no-gpg-verify chiaki-repo repo flatpak --user install chiaki-repo org.flatpak.Chiaki

lsiudut commented 4 years ago

Does it work if you set the environmental variable:

LIBVA_DRIVER_NAME=iHD

There was a change in Xorg and it was selecting a wrong backend by default. It was suppose to be fixed in future releases. Arch was affected as it runs on the bleeding edge, obviously.

One way or another it works perfectly fine for me (on Arch).

Amanuense-del-diavolo commented 4 years ago

@cybern0id you're missing the environmental variable that define the which driver should VAAPI use, by the lock of it I'll suggest you to set the variable to LIBVA_DRIVER_NAME=iHD if the driver is missing it's in the packet "intel-media-driver" I suggest you to look here for more informations https://wiki.archlinux.org/index.php/Hardware_video_acceleration#Verifying_VA-API

If you'r trying to use the hardware accelleration on NVIDIA gpu's I'll suggest you to wait for the release of the VDPAU api's, see here for more informations https://github.com/thestr4ng3r/chiaki/pull/205 , if you'r desperate you can use install the driver libva-vdpau-driver and set the variable LIBVA_DRIVER_NAME= to vdpau

cybern0id commented 4 years ago

@Amanuense-del-diavolo I had already tried that and it doesn't work. I'm not using Arch I am using Devuan which is a derivative of Debian. I have all the VAAPI DRI drivers installed:

$ls -lah /usr/lib/x86_64-linux-gnu/dri/ total 166M drwxr-xr-x 2 root root 4.0K May 23 04:58 . drwxr-xr-x 167 root root 132K Jun 5 16:18 .. -rw-r--r-- 5 root root 9.6M Jan 15 19:28 i915_dri.so -rw-r--r-- 5 root root 9.6M Jan 15 19:28 i965_dri.so -rw-r--r-- 1 root root 1.8M Feb 2 2019 i965_drv_video.so -rw-r--r-- 1 root root 4.0M Apr 7 2019 iHD_drv_video.so -rw-r--r-- 8 root root 12M Jan 15 19:28 kms_swrast_dri.so -rw-r--r-- 8 root root 12M Jan 15 19:28 nouveau_dri.so -rw-r--r-- 3 root root 6.0M Jan 15 19:28 nouveau_drv_video.so -rw-r--r-- 5 root root 9.6M Jan 15 19:28 nouveau_vieux_dri.so -rw-r--r-- 5 root root 9.6M Jan 15 19:28 r200_dri.so -rw-r--r-- 8 root root 12M Jan 15 19:28 r300_dri.so -rw-r--r-- 8 root root 12M Jan 15 19:28 r600_dri.so -rw-r--r-- 3 root root 6.0M Jan 15 19:28 r600_drv_video.so -rw-r--r-- 5 root root 9.6M Jan 15 19:28 radeon_dri.so -rw-r--r-- 8 root root 12M Jan 15 19:28 radeonsi_dri.so -rw-r--r-- 3 root root 6.0M Jan 15 19:28 radeonsi_drv_video.so -rw-r--r-- 8 root root 12M Jan 15 19:28 swrast_dri.so -rw-r--r-- 8 root root 12M Jan 15 19:28 virtio_gpu_dri.so -rw-r--r-- 8 root root 12M Jan 15 19:28 vmwgfx_dri.so

vainfo reports I should use the i965 and not the iHD driver in any case:

$vainfo libva info: VA-API version 1.4.0 libva info: va_getDriverName() returns 0 libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so libva info: Found init function __vaDriverInit_1_4 libva info: va_openDriver() returns 0 vainfo: VA-API version: 1.4 (libva 2.4.0) vainfo: Driver version: Intel i965 driver for Intel(R) Ivybridge Mobile - 2.3.0 vainfo: Supported profile and entrypoints VAProfileMPEG2Simple : VAEntrypointVLD VAProfileMPEG2Simple : VAEntrypointEncSlice VAProfileMPEG2Main : VAEntrypointVLD VAProfileMPEG2Main : VAEntrypointEncSlice VAProfileH264ConstrainedBaseline: VAEntrypointVLD VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice VAProfileH264Main : VAEntrypointVLD VAProfileH264Main : VAEntrypointEncSlice VAProfileH264High : VAEntrypointVLD VAProfileH264High : VAEntrypointEncSlice VAProfileH264StereoHigh : VAEntrypointVLD VAProfileVC1Simple : VAEntrypointVLD VAProfileVC1Main : VAEntrypointVLD VAProfileVC1Advanced : VAEntrypointVLD VAProfileNone : VAEntrypointVideoProc VAProfileJPEGBaseline : VAEntrypointVLD

I have tried with LIBVA_DRIVER_NAME=iHD, LIBVA_DRIVER_NAME=i965 and LIBVA_DRIVER_NAME=i915 and still chiaki does not work when enabling vaapi hardware decode:

$LIBVA_DRIVER_NAME=i965 ./gui/chiaki Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway. [I] Discovery Service detected new host with id ############ [I] Logging to file /home/user/.local/share/Chiaki/Chiaki/log/chiaki_session_2020-06-05_16-29-49-757757.log [I] Chiaki Version 1.2.1 [I] Using hardware decode vaapi [AVHWDeviceContext @ 0x556cd3231a40] libva: /usr/lib/x86_64-linux-gnu/dri/i965_drv_video.so init failed [AVHWDeviceContext @ 0x556cd3231a40] Failed to initialise VAAPI connection: -1 (unknown libva error).

All of the above is from latest chiaki code git pulled and compiled from source today.

What intrigues me is the output from VLC when enabling vaapi acceleration. It shows the same error as chiaki at first and then immediately recovers and successfully initialises the correct vaapi driver.

meltingrobot commented 4 years ago

FYI, if you want to get Chiaki into flathub, here is the instructions for that: https://github.com/flathub/flathub/wiki/App-Submission

Since I am not the app developer, I don't think I am allowed to do that. With the latest commit I made, it should pass all the requirements to be added.

bterrier commented 4 years ago

As VDPAU is not yet supported and I have an nvidia GPU, I am trying to use VDPAU driver for VA-API.

When I connect to the PS4 I have an error dialog:

Failed to initialize Stream Session: Failed to create hwdevice contect

The console output is:

[I] Discovery Service detected new host with id F8461C83AE49
[I] Discovery Service: Host with id F8461C83AE49 is no longer available
[I] Discovery Service detected new host with id F8461C83AE49
[I] Logging to file ...
[I] Chiaki Version 1.2.0
[I] Using hardware decode vaapi
[AVHWDeviceContext @ 0x559e89d9aa40] libva: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
[AVHWDeviceContext @ 0x559e89d9aa40] Failed to initialise VAAPI connection: -1 (unknown libva error).

If I try to set LIBVA_DRIVER_NAME=vdpau then I have a SIGSEGV

$ LIBVA_DRIVER_NAME=vdpau chiaki
[I] Discovery Service detected new host with id F8461C83AE49
[I] Logging to file ...
[I] Chiaki Version 1.2.0
[I] Using hardware decode vaapi
“LIBVA_DRIVER_NAME=vdpau chiaki” terminated by signal SIGSEGV (Address boundary error)

The stack trace is:

#0  0x00007ffff1efa110 in XDisplayString () at /usr/lib/libX11.so.6
#1  0x00007fffe40fc8a7 in __vaDriverInit_1_4 () at /usr/lib/dri/vdpau_drv_video.so
#2  0x00007ffff203d028 in  () at /usr/lib/libva.so.2
#3  0x00007ffff20413af in vaInitialize () at /usr/lib/libva.so.2
#4  0x00007ffff631517e in  () at /usr/lib/libavutil.so.56
#5  0x00007ffff630d8bf in av_hwdevice_ctx_create () at /usr/lib/libavutil.so.56
#6  0x00005555555dcc85 in VideoDecoder::VideoDecoder(HardwareDecodeEngine, chiaki_log_t*) (this=0x555555e48880, hw_decode_engine=HW_DECODE_VAAPI, log=0x555555e47fb8) at chiaki/gui/src/videodecoder.cpp:63

I am not sure it is an issue in Chiaki as I can also make VLC SIGSEGV by forcing VA-API. For reference I have created a post on ArchLinux forum about this issue.

Is there any plan to have a native VDPAU support in Chiaki?

afiaka87 commented 4 years ago

Out of curiosity, is this something that can be enabled on Windows? I'm receiving the same error.

thestr4ng3r commented 4 years ago

No, vaapi only exists on Linux and *BSD.

coredump commented 4 years ago

I know this is a little old but:

I am running the latest master (https://github.com/thestr4ng3r/chiaki/commit/d4b4681a0f6a527620ace84ba24ffa1df08ce258) built on Manjaro and it's working with HW decoding using VAAPI

[I] Using hardware decode vaapi
[I] Starting session request
[I] OpenGL initialized with version "3.2.0 NVIDIA 440.100"

I am on a notebook with a hybrid setup, intel/nvidia cards, and from my dealings with Parsec I can say that if the nvidia card isn't the one your X is using as main, vaapi/vdpau won't work. I tried many ways using different offload options and and AFAIK there's no way to make that happen at least on most of the mobile cards. I am using optimus-manager to make sure my X is running on nvidia drivers and with that I get vainfo and vdpauinfo to look normal

❯ vdpauinfo |head -n3
display: :0   screen: 0
API version: 1
Information string: NVIDIA VDPAU Driver Shared Library  440.100  Fri May 29 08:12:22 UTC 2020
❯ vainfo |head -n2
vainfo: VA-API version: 1.8 (libva 2.8.0)
vainfo: Driver version: Splitted-Desktop Systems VDPAU backend for VA-API - 0.7.4

OTOH I can be reading this completely wrong and Chiaki is rendering everything via OpenGL, so, /shrug Not much of a solution, but I hope the info helps someone

imtbl commented 4 years ago

Under Arch, I can't seem to get vaapi working using an NVIDIA card (1080 Ti) either (with libva-vdpau-driver installed). The following error message appears: image

Log output (with verbose logging) of Chiaki is just the following: I was able to get some more output by launching Chiaki from the shell:

[I] Logging to file /home/imtbl/.local/share/Chiaki/Chiaki/log/chiaki_session_2020-11-16_02-26-04-614614.log
[I] Chiaki Version 1.3.0
[I] Using hardware decode vaapi
[AVHWDeviceContext @ 0x55e3de00a640] libva: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
[AVHWDeviceContext @ 0x55e3de00a640] Failed to initialise VAAPI connection: -1 (unknown libva error).

I tried via LIBVA_DRIVER_NAME=vdpau chiaki too, but it causes a segfault:

[I] Logging to file /home/imtbl/.local/share/Chiaki/Chiaki/log/chiaki_session_2020-11-16_01-38-26-619619.log
[I] Chiaki Version 1.3.0
[I] Using hardware decode vaapi
[1]    8399 segmentation fault (core dumped)  LIBVA_DRIVER_NAME=vdpau chiaki

The vainfo and vdpauinfo outputs look good to me at least:

vainfo: VA-API version: 1.9 (libva 2.9.1)
vainfo: Driver version: Splitted-Desktop Systems VDPAU backend for VA-API - 0.7.4
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileMPEG4Simple            : VAEntrypointVLD
      VAProfileMPEG4AdvancedSimple    : VAEntrypointVLD
      <unknown profile>               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
display: :0   screen: 0
API version: 1
Information string: NVIDIA VDPAU Driver Shared Library  455.38  Thu Oct 22 05:57:08 UTC 2020
[...]

Playing a video via mpv and forcing vaapi works too:

➜  mpv --vo=vaapi big_buck_bunny.mp4                                                                                   
 (+) Video --vid=1 (*) (h264 640x360 23.962fps)
 (+) Audio --aid=1 --alang=eng (*) (aac 2ch 22050Hz)
[vo/vaapi] VA-API is most likely emulated via VDPAU.
[vo/vaapi] It's better to use VDPAU directly with: --vo=vdpau
[vo/vaapi] Warning: this compatibility VO is low quality and may have issues with OSD, scaling, screenshots and more.
[vo/vaapi] vo=gpu is the preferred choice in any case and includes VA-API support via hwdec=vaapi or vaapi-copy.
Using hardware decoding (nvdec-copy).
AO: [pulse] 22050Hz stereo 2ch float
VO: [vaapi] 640x360 nv12
AV: 00:00:13 / 00:01:00 (23%) A-V:  0.000

Any idea what could be the culprit here? I am on the latest kernel (5.9.8) and NVIDIA driver (455.38). I'm aware that the driver isn't fully compatible with the 5.9.x kernel, though considering how mpv seems to work (unless I'm misreading the output and I didn't successfully force it to use vaapi after all), it looks like vdpau/vaapi should work even if CUDA and some other features don't with this driver under kernel 5.9.x.

Edit: I also found this thread which seems to describe the same issue: https://bbs.archlinux.org/viewtopic.php?id=256690

bterrier commented 3 years ago

@imtbl There are issues with using VA-API with VDPAU and nvidia GPU, at least on Arch Linux: https://bugs.archlinux.org/task/67054

The solution is to force chiaki to use VDPAU directly.

When I first had this issue, it seems that chiaki does support VDPAU out of the box, the fact that it is not available is just that the option is not offered in the combobox in the settings page.

I've tried editing the config file directly, or even recompiling to add the option in the combo box, and both work. I've been using vdpau for some time now without any issues.