LizardByte / Sunshine

Self-hosted game stream host for Moonlight.
http://app.lizardbyte.dev/Sunshine/
GNU General Public License v3.0
16k stars 770 forks source link

Intel VAAPI failed #2634

Open garywill opened 1 month ago

garywill commented 1 month ago

Is there an existing issue for this?

Is your issue described in the documentation?

Is your issue present in the latest beta/pre-release?

Describe the Bug

Sunshine failed to use VAAPI. I have integrated Intel GPU. I'm sure my GPU supports VAAPI. I can encode video using ffmpeg -hwaccel vaapi -i "input file" -vf 'format=nv12,hwupload' -vcodec h264_vaapi "output file"

Using sunshine.flatpak v2024.601.193044 from Github release. (I've tried v0.23.1 AppImage before. It also failed)

Expected Behavior

No response

Additional Context

Output of system vainfo

$ vainfo
libva info: VA-API version 1.16.0
libva info: Trying to open /usr/lib64/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_1_13
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.16 (libva 2.15.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Ivybridge Mobile - 2.4.1
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
$ flatpak list --all
Name                              Application ID                       Version  Branch      Origin          Installation
sunshine                          dev.lizardbyte.sunshine                       master      sunshine-origin system
Freedesktop Platform              org.freedesktop.Platform             22.08.24 22.08       sjtu            system
Mesa                              org.freedesktop.Platform.GL.default  24.0.4   22.08       sjtu            system
Mesa (Extra)                      org.freedesktop.Platform.GL.default  24.0.4   22.08-extra sjtu            system
freedesktop platform translations org.freedesktop.Platform.Locale               22.08       sjtu            system
Intel                             org.freedesktop.Platform.VAAPI.Intel          22.08       sjtu            system
openh264                          org.freedesktop.Platform.openh264    2.1.0    2.2.0       sjtu            system

One thing I'm not sure if related. Flatpak enviroment's ffmpeg doesn't show h264_vaapi encoder:

$ flatpak enter dev.lizardbyte.sunshine  bash
$ ffmpeg -encoders
ffmpeg version 5.0.3 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 12.2.0 (GCC)
...
V....D libopenh264          OpenH264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (codec h264)
V....D mjpeg_vaapi          MJPEG (VAAPI) (codec mjpeg)
V....D vp8_vaapi            VP8 (VAAPI) (codec vp8)

System's ffmpeg:

$ ffmpeg -encoders
ffmpeg version 6.1.1 Copyright (c) 2000-2023 the FFmpeg developers
built with gcc 7 (SUSE Linux)
...
V....D libx264              libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (codec h264)
V....D libx264rgb           libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 RGB (codec h264)
V....D libopenh264          OpenH264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (codec h264)
V..... h264_qsv             H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (Intel Quick Sync Video acceleration) (codec h264)
V..... h264_v4l2m2m         V4L2 mem2mem H.264 encoder wrapper (codec h264)
V....D h264_vaapi           H.264/AVC (VAAPI) (codec h264)
...
V....D libvpx               libvpx VP8 (codec vp8)
V..... vp8_v4l2m2m          V4L2 mem2mem VP8 encoder wrapper (codec vp8)
V....D vp8_vaapi            VP8 (VAAPI) (codec vp8)
V....D libvpx-vp9           libvpx VP9 (codec vp9)
V....D vp9_vaapi            VP9 (VAAPI) (codec vp9)

V....D mjpeg_vaapi          MJPEG (VAAPI) (codec mjpeg)
V....D mpeg2_vaapi          MPEG-2 (VAAPI) (codec mpeg2video)
V....D av1_vaapi            AV1 (VAAPI) (codec av1)

Host Operating System

Linux

Operating System Version

openSUSE 15.5

Architecture

64 bit

Sunshine commit or version

v2024.601.193044

Package

Linux - flatpak

GPU Type

Intel

GPU Model

Intel HD Graphics 4000

GPU Driver/Mesa Version

22.3.5

Capture Method (Linux Only)

default (I didn't change)

Config

min_log_level = 1
output_name = 2
origin_web_ui_allowed = pc

Apps

No response

Relevant log output

$ flatpak run dev.lizardbyte.sunshine
[output_name] -- [2]
[origin_web_ui_allowed] -- [pc]
[min_log_level] -- [1]
[2024:06:04:21:28:48]: Info: Sunshine version: v2024.601.193044
Cannot load libcuda.so.1
[2024:06:04:21:28:48]: Error: Couldn't load cuda: -1
[2024:06:04:21:28:48]: Error: Failed to gain CAP_SYS_ADMIN
[2024:06:04:21:28:48]: Info: /dev/dri/card0 -> i915
[2024:06:04:21:28:48]: Debug: Opening render node: /dev/dri/renderD128
[2024:06:04:21:28:48]: Error: Failed to gain CAP_SYS_ADMIN
[2024:06:04:21:28:48]: Error: Couldn't get handle for DRM Framebuffer [106]: Probably not permitted
[2024:06:04:21:28:48]: Error: You must run [sudo setcap cap_sys_admin+p $(readlink -f $(which sunshine))] for KMS display capture to work!
If you installed from AppImage or Flatpak, please refer to the official documentation:
https://docs.lizardbyte.dev/projects/sunshine/en/latest/about/setup.html#install
[2024:06:04:21:28:48]: Error: Environment variable WAYLAND_DISPLAY has not been defined
[2024:06:04:21:28:48]: Debug: Monitor description
[2024:06:04:21:28:48]: Debug: Resolution: 0x0
[2024:06:04:21:28:48]: Debug: Offset: 0x0
[2024:06:04:21:28:48]: Debug: Monitor description
[2024:06:04:21:28:48]: Debug: Resolution: 0x0
[2024:06:04:21:28:48]: Debug: Offset: 0x0
[2024:06:04:21:28:48]: Debug: Monitor description
[2024:06:04:21:28:48]: Debug: Resolution: 0x0
[2024:06:04:21:28:48]: Debug: Offset: 0x0
[2024:06:04:21:28:48]: Debug: Desktop resolution: 0x0
[2024:06:04:21:28:48]: Info: Detecting displays
Gtk-Message: 21:28:48.558: Failed to load module "canberra-gtk-module"
[2024:06:04:21:28:48]: Info: Detected display: LVDS-1 (id: 0)LVDS-1 connected: true
[2024:06:04:21:28:48]: Info: Detected display: VGA-1 (id: 1)VGA-1 connected: false
[2024:06:04:21:28:48]: Info: Detected display: HDMI-1 (id: 2)HDMI-1 connected: false
[2024:06:04:21:28:48]: Info: Detected display: DP-1 (id: 3)DP-1 connected: false
[2024:06:04:21:28:48]: Info: Detected display: HDMI-2 (id: 4)HDMI-2 connected: false
[2024:06:04:21:28:48]: Info: Detected display: DP-2 (id: 5)DP-2 connected: true
[2024:06:04:21:28:48]: Error: Could not create Sunshine Mouse (Relative): Permission denied
[2024:06:04:21:28:48]: Error: Could not create Sunshine Mouse (Absolute): Permission denied
[2024:06:04:21:28:48]: Error: Could not create Sunshine Keyboard: Permission denied
[2024:06:04:21:28:48]: Error: Falling back to XTest for virtual input! Are you a member of the 'input' group?
[2024:06:04:21:28:48]: Info: // Testing for available encoders, this may generate errors. You can safely ignore those errors. //
[2024:06:04:21:28:48]: Info: Trying encoder [nvenc]
[2024:06:04:21:28:48]: Info: Screencasting with X11
[2024:06:04:21:28:48]: Info: Configuring selected display (2) to stream
[2024:06:04:21:28:48]: Warning: Couldn't get requested display info, defaulting to recording entire virtual desktop
Cannot load libcuda.so.1
[2024:06:04:21:28:48]: Error: Couldn't load cuda: -1
Cannot load libcuda.so.1
[2024:06:04:21:28:48]: Error: Couldn't load cuda: -1
[2024:06:04:21:28:48]: Info: Encoder [nvenc] failed
[2024:06:04:21:28:48]: Info: Trying encoder [vaapi]
[2024:06:04:21:28:48]: Info: Screencasting with X11
[2024:06:04:21:28:48]: Info: Configuring selected display (2) to stream
[2024:06:04:21:28:49]: Warning: Couldn't get requested display info, defaulting to recording entire virtual desktop
[2024:06:04:21:28:49]: Info: System tray created
[2024:06:04:21:28:49]: Debug: System tray loop

MESA-LOADER: failed to open crocus: /usr/lib/x86_64-linux-gnu/GL/default/lib/dri/crocus_dri.so: undefined symbol: amdgpu_va_get_start_addr (search paths /usr/lib/x86_64-linux-gnu/GL/default/lib/dri, suffix _dri)
MESA-LOADER: failed to open kms_swrast: /usr/lib/x86_64-linux-gnu/GL/default/lib/dri/kms_swrast_dri.so: undefined symbol: amdgpu_va_get_start_addr (search paths /usr/lib/x86_64-linux-gnu/GL/default/lib/dri, suffix _dri)
MESA-LOADER: failed to open swrast: /usr/lib/x86_64-linux-gnu/GL/default/lib/dri/swrast_dri.so: undefined symbol: amdgpu_va_get_start_addr (search paths /usr/lib/x86_64-linux-gnu/GL/default/lib/dri, suffix _dri)
[2024:06:04:21:28:49]: Error: Couldn't create GBM device: [No such file or directory]
MESA-LOADER: failed to open crocus: /usr/lib/x86_64-linux-gnu/GL/default/lib/dri/crocus_dri.so: undefined symbol: amdgpu_va_get_start_addr (search paths /usr/lib/x86_64-linux-gnu/GL/default/lib/dri, suffix _dri)
MESA-LOADER: failed to open kms_swrast: /usr/lib/x86_64-linux-gnu/GL/default/lib/dri/kms_swrast_dri.so: undefined symbol: amdgpu_va_get_start_addr (search paths /usr/lib/x86_64-linux-gnu/GL/default/lib/dri, suffix _dri)
MESA-LOADER: failed to open swrast: /usr/lib/x86_64-linux-gnu/GL/default/lib/dri/swrast_dri.so: undefined symbol: amdgpu_va_get_start_addr (search paths /usr/lib/x86_64-linux-gnu/GL/default/lib/dri, suffix _dri)
[2024:06:04:21:28:49]: Error: Couldn't create GBM device: [No such file or directory]
[2024:06:04:21:28:49]: Debug: System tray loop

[2024:06:04:21:28:49]: Debug: System tray loop
MESA-LOADER: failed to open crocus: /usr/lib/x86_64-linux-gnu/GL/default/lib/dri/crocus_dri.so: undefined symbol: amdgpu_va_get_start_addr (search paths /usr/lib/x86_64-linux-gnu/GL/default/lib/dri, suffix _dri)
MESA-LOADER: failed to open kms_swrast: /usr/lib/x86_64-linux-gnu/GL/default/lib/dri/kms_swrast_dri.so: undefined symbol: amdgpu_va_get_start_addr (search paths /usr/lib/x86_64-linux-gnu/GL/default/lib/dri, suffix _dri)
MESA-LOADER: failed to open swrast: /usr/lib/x86_64-linux-gnu/GL/default/lib/dri/swrast_dri.so: undefined symbol: amdgpu_va_get_start_addr (search paths /usr/lib/x86_64-linux-gnu/GL/default/lib/dri, suffix _dri)
[2024:06:04:21:28:49]: Error: Couldn't create GBM device: [No such file or directory]
MESA-LOADER: failed to open crocus: /usr/lib/x86_64-linux-gnu/GL/default/lib/dri/crocus_dri.so: undefined symbol: amdgpu_va_get_start_addr (search paths /usr/lib/x86_64-linux-gnu/GL/default/lib/dri, suffix _dri)
MESA-LOADER: failed to open kms_swrast: /usr/lib/x86_64-linux-gnu/GL/default/lib/dri/kms_swrast_dri.so: undefined symbol: amdgpu_va_get_start_addr (search paths /usr/lib/x86_64-linux-gnu/GL/default/lib/dri, suffix _dri)
MESA-LOADER: failed to open swrast: /usr/lib/x86_64-linux-gnu/GL/default/lib/dri/swrast_dri.so: undefined symbol: amdgpu_va_get_start_addr (search paths /usr/lib/x86_64-linux-gnu/GL/default/lib/dri, suffix _dri)
[2024:06:04:21:28:49]: Error: Couldn't create GBM device: [No such file or directory]
[2024:06:04:21:28:49]: Info: Encoder [vaapi] failed
[2024:06:04:21:28:49]: Info: Trying encoder [software]
[2024:06:04:21:28:49]: Info: Screencasting with X11
[2024:06:04:21:28:49]: Info: Configuring selected display (2) to stream
[2024:06:04:21:28:49]: Warning: Couldn't get requested display info, defaulting to recording entire virtual desktop
[2024:06:04:21:28:49]: Info: SDR color coding [Rec. 601]
[2024:06:04:21:28:49]: Info: Color depth: 8-bit
[2024:06:04:21:28:49]: Info: Color range: [JPEG]
[2024:06:04:21:28:49]: Info: [libx264 @ 0x55f3a0ff4dc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[2024:06:04:21:28:49]: Info: [libx264 @ 0x55f3a0ff4dc0] profile High, level 4.2, 4:2:0, 8-bit
[2024:06:04:21:28:49]: Debug: Frame 1: IDR Keyframe (AV_FRAME_FLAG_KEY)
[2024:06:04:21:28:49]: Info: [libx264 @ 0x55f3a0ff4dc0] frame I:1     Avg QP:31.00  size:  1203
[2024:06:04:21:28:49]: Info: [libx264 @ 0x55f3a0ff4dc0] mb I  I16..4: 99.9%  0.0%  0.0%
[2024:06:04:21:28:49]: Info: [libx264 @ 0x55f3a0ff4dc0] 8x8 transform intra:0.0%
[2024:06:04:21:28:49]: Info: [libx264 @ 0x55f3a0ff4dc0] coded y,uvDC,uvAC intra: 0.0% 0.0% 0.0%
[2024:06:04:21:28:49]: Info: [libx264 @ 0x55f3a0ff4dc0] i16 v,h,dc,p: 97%  0%  3%  0%
[2024:06:04:21:28:49]: Info: [libx264 @ 0x55f3a0ff4dc0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  0%  0% 75% 12%  0%  0%  0%  0% 12%
[2024:06:04:21:28:49]: Info: [libx264 @ 0x55f3a0ff4dc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu:  0%  0% 100%  0%  0%  0%  0%  0%  0%
[2024:06:04:21:28:49]: Info: [libx264 @ 0x55f3a0ff4dc0] i8c dc,h,v,p: 100%  0%  0%  0%
[2024:06:04:21:28:49]: Info: [libx264 @ 0x55f3a0ff4dc0] kb/s:577.44
[2024:06:04:21:28:49]: Info: Screencasting with X11
[2024:06:04:21:28:49]: Info: Configuring selected display (2) to stream
[2024:06:04:21:28:49]: Warning: Couldn't get requested display info, defaulting to recording entire virtual desktop
[2024:06:04:21:28:49]: Info:
[2024:06:04:21:28:49]: Info: // Ignore any errors mentioned above, they are not relevant. //
[2024:06:04:21:28:49]: Info:
[2024:06:04:21:28:49]: Debug: ------  h264 ------
[2024:06:04:21:28:49]: Debug: PASSED: supported
[2024:06:04:21:28:49]: Debug: REF_FRAMES_RESTRICT: supported
[2024:06:04:21:28:49]: Debug: CBR: supported
[2024:06:04:21:28:49]: Debug: DYNAMIC_RANGE: unsupported
[2024:06:04:21:28:49]: Debug: VUI_PARAMETERS: supported
[2024:06:04:21:28:49]: Debug: -------------------
[2024:06:04:21:28:49]: Info: Found H.264 encoder: libx264 [software]
[2024:06:04:21:28:49]: Info: Adding avahi service Sunshine
[2024:06:04:21:28:49]: Info: Configuration UI available at [https://localhost:47990]
[2024:06:04:21:28:50]: Info: Avahi service Sunshine successfully established.
gschintgen commented 1 month ago

Unfortunately there are currently a few issues with the flatpak, notably when it comes to VA-API. This has also been reported in #2409. (The reason here may be different though.)

To further confuse matters there are actually two flatpaks: the official github release and the one from Flathub. When I last checked the one from Flathub had slightly more up-to-date build dependencies. You might give it a try.

In general it's always best to use a Sunshine package built specifically for your distribution. (I think for Suse there are also some community provided builds available, but there is no official build.)

As for the AppImage, could you please also post those logs?

gschintgen commented 18 hours ago

There were a few changes to the Flatpak. Do you mind to retest the latest pre-release as published here on Github?