Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find encoder #69

Closed
emmyoh opened this issue Feb 26, 2022 · 21 comments
Closed

Unable to find encoder #69

emmyoh opened this issue Feb 26, 2022 · 21 comments
Labels
os:Linux:Arch OS is Arch Linux

Comments

@emmyoh
Copy link

emmyoh commented Feb 26, 2022

Describe the Bug

Having switched from the original repository's version of Sunshine to this fork, Sunshine no longer runs at all, with the process aborting due to a fatal error mere moments after starting it.

Below is the output I get on every run:

[2022:02:25:19:21:44]: Error: Failed to gain CAP_SYS_ADMIN
[2022:02:25:19:21:44]: Error: Couldn't expose some/all drm planes for card: /dev/dri/card0
[2022:02:25:19:21:44]: Info: Detecting connected monitors

[2022:02:25:19:21:44]: Info: //////////////////////////////////////////////////////////////////
[2022:02:25:19:21:44]: Info: //                                                              //
[2022:02:25:19:21:44]: Info: //   Testing for available encoders, this may generate errors.  //
[2022:02:25:19:21:44]: Info: //   You can safely ignore those errors.                        //
[2022:02:25:19:21:44]: Info: //                                                              //
[2022:02:25:19:21:44]: Info: //////////////////////////////////////////////////////////////////
[2022:02:25:19:21:44]: Info: Trying encoder [nvenc]
[2022:02:25:19:21:44]: Info: Screencasting with X11
[2022:02:25:19:21:44]: Info: Color coding [Rec. 601]
[2022:02:25:19:21:44]: Info: Color range: [JPEG]
[2022:02:25:19:21:44]: Error: Could not open codec [h264_nvenc]: Function not implemented
[2022:02:25:19:21:44]: Info: Screencasting with X11
[2022:02:25:19:21:44]: Info: Color coding [Rec. 601]
[2022:02:25:19:21:44]: Info: Color range: [JPEG]
[swscaler @ 0x5635aa687e80] bad src image pointers
[2022:02:25:19:21:44]: Error: Couldn't convert image to required format and/or size
[2022:02:25:19:21:44]: Info: Screencasting with X11
[2022:02:25:19:21:44]: Info: Color coding [Rec. 601]
[2022:02:25:19:21:44]: Info: Color range: [JPEG]
[2022:02:25:19:21:44]: Error: Could not open codec [h264_nvenc]: Function not implemented
[2022:02:25:19:21:44]: Info: Screencasting with X11
[2022:02:25:19:21:44]: Info: Color coding [Rec. 601]
[2022:02:25:19:21:44]: Info: Color range: [JPEG]
[swscaler @ 0x5635aa223700] bad src image pointers
[2022:02:25:19:21:44]: Error: Couldn't convert image to required format and/or size
[2022:02:25:19:21:45]: Info: Encoder [nvenc] failed
[2022:02:25:19:21:45]: Info: Trying encoder [vaapi]
[2022:02:25:19:21:45]: Info: Screencasting with X11
[2022:02:25:19:21:45]: Info: Color coding [Rec. 601]
[2022:02:25:19:21:45]: Info: Color range: [JPEG]
[2022:02:25:19:21:45]: Info: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
[2022:02:25:19:21:45]: Error: Couldn't initialize va display: unknown libva error
[2022:02:25:19:21:45]: Info: Screencasting with X11
[2022:02:25:19:21:45]: Info: Color coding [Rec. 601]
[2022:02:25:19:21:45]: Info: Color range: [JPEG]
[2022:02:25:19:21:45]: Info: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
[2022:02:25:19:21:45]: Error: Couldn't initialize va display: unknown libva error
[2022:02:25:19:21:45]: Info: Screencasting with X11
[2022:02:25:19:21:45]: Info: Color coding [Rec. 601]
[2022:02:25:19:21:45]: Info: Color range: [JPEG]
[2022:02:25:19:21:45]: Info: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
[2022:02:25:19:21:45]: Error: Couldn't initialize va display: unknown libva error
[2022:02:25:19:21:45]: Info: Screencasting with X11
[2022:02:25:19:21:45]: Info: Color coding [Rec. 601]
[2022:02:25:19:21:45]: Info: Color range: [JPEG]
[2022:02:25:19:21:45]: Info: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null)
[2022:02:25:19:21:45]: Error: Couldn't initialize va display: unknown libva error
[2022:02:25:19:21:45]: Info: Encoder [vaapi] failed
[2022:02:25:19:21:45]: Info: Trying encoder [software]
[2022:02:25:19:21:45]: Info: Screencasting with X11
[2022:02:25:19:21:45]: Info: Color coding [Rec. 601]
[2022:02:25:19:21:45]: Info: Color range: [JPEG]
[swscaler @ 0x5635ab1e9040] bad src image pointers
[2022:02:25:19:21:45]: Error: Couldn't convert image to required format and/or size
[2022:02:25:19:21:45]: Info: Screencasting with X11
[2022:02:25:19:21:45]: Info: Color coding [Rec. 601]
[2022:02:25:19:21:45]: Info: Color range: [JPEG]
[swscaler @ 0x5635abde9040] bad src image pointers
[2022:02:25:19:21:45]: Error: Couldn't convert image to required format and/or size
[2022:02:25:19:21:45]: Info: Screencasting with X11
[2022:02:25:19:21:45]: Info: Color coding [Rec. 601]
[2022:02:25:19:21:45]: Info: Color range: [JPEG]
[swscaler @ 0x5635aa17a340] bad src image pointers
[2022:02:25:19:21:45]: Error: Couldn't convert image to required format and/or size
[2022:02:25:19:21:45]: Info: Screencasting with X11
[2022:02:25:19:21:45]: Info: Color coding [Rec. 601]
[2022:02:25:19:21:45]: Info: Color range: [JPEG]
[swscaler @ 0x5635aa17a340] bad src image pointers
[2022:02:25:19:21:45]: Error: Couldn't convert image to required format and/or size
[2022:02:25:19:21:45]: Info: Encoder [software] failed
[2022:02:25:19:21:45]: Info: 
[2022:02:25:19:21:45]: Info: //////////////////////////////////////////////////////////////
[2022:02:25:19:21:45]: Info: //                                                          //
[2022:02:25:19:21:45]: Info: // Ignore any errors mentioned above, they are not relevant //
[2022:02:25:19:21:45]: Info: //                                                          //
[2022:02:25:19:21:45]: Info: //////////////////////////////////////////////////////////////
[2022:02:25:19:21:45]: Info: 
[2022:02:25:19:21:45]: Fatal: Couldn't find any encoder

Expected Behavior

Sunshine should run and work properly as it did before this forked version was created.

Additional Context

Two other users on the Arch User Repository (AUR) have encountered this very same issue—@JPenuchot and @pogojotz.
Like me, @JPenuchot had switched from the pre-fork version to the version hosted on this GitHub repository. However, @pogojotz had not installed the unmaintained version of Sunshine; this eliminates the possibility that some leftover files from before I made the switch are causing problems.
The other two mentioned are also running Arch Linux with Nvidia GPUs on X11.

Sunshine Host Operating System and Version

Arch Linux

Architecture

x86-64

Sunshine Version

git

GPU Type

Nvidia

GPU Model

GeForce GTX 970

GPU Driver/Mesa Version

510.54

Capture Method (Linux Only)

X11 GNOME Session

@emmyoh
Copy link
Author

emmyoh commented Feb 26, 2022

Perhaps this is related to the FFmpeg 5.0 release? The Arch Linux package ffmpeg4.4 was used to build Sunshine on my system, so the recent 5.0 release is not the cause.
How may I help with debugging this?

@ReenigneArcher ReenigneArcher added the os:Linux:Arch OS is Arch Linux label Feb 26, 2022
@Theslees
Copy link

Theslees commented Feb 26, 2022

I'm also having this issue, same OS and terminal output, but using a different GPU. (AMD)

@cyl3x
Copy link

cyl3x commented Feb 26, 2022

same issue here, Arch and NVIDIA Card

@ReenigneArcher
Copy link
Member

@hadogenes any thoughts?

@JPenuchot
Copy link

JPenuchot commented Feb 26, 2022

Same issue, same config. I switched to this fork because of an AUR update and now I can't get Sunshine to run. However I tried building the package at its last version targeting the original repo and I still run into this problem, so it might not be a regression. I'm also seeing CMake not detecting any CUDA compiler despite CUDA_HOME and CUDA_PATH both being set to /opt/cuda, so I'm suspecting a build system issue to be the root cause.

PS: CUDA compiler not being detected happens on both the original repo and this fork. I guess it's worth fixing this repo as it's more reactive to PRs and already being tracked by the AUR package.

@JPenuchot
Copy link

Update: The CMake script actually finds the CUDA install present on my system, although not when being called through makepkg when building the AUR package. Not sure the lack of a CUDA compiler is what's causing the error, but maybe what's causing CMake to not find nvcc could also be causing it to not find an essential library.

@JPenuchot
Copy link

After a bit of debugging it turns out the issue happens here:
https://github.com/SunshineStream/Sunshine/blob/4a483078ad983b159d349e8056fccf61d918dc74/sunshine/video.cpp#L740

Both this fork and the original repo are impacted.

@JPenuchot
Copy link

Another note: I don't get this issue on my laptop with Intel integrated graphics. It's possible that it was caused by a libdrm or Nvidia update too.

@emmyoh
Copy link
Author

emmyoh commented Feb 26, 2022

OK … so it's not a regression introduced from the fork (so is not due to a code change), is not unique to Nvidia, but may possibly still be connected to something with Arch Linux? I'm quite lost as to what the cause could be. I had the pre-fork version of Sunshine installed an hour before opening this issue, and my system was 100% up-to-date at the time, so the only updates that could've possibly affected things is anything statically-linked to the compiled binary. The fact that it works on Intel is interesting.

@emmyoh emmyoh changed the title Potential regression Process dies almost immediately; unable to find encoder (Arch Linux — February 2022) Feb 26, 2022
@ReenigneArcher
Copy link
Member

The AUR was recently updated and there were changes in the build besides pointing to this repo. There were 3 commits a few days ago https://aur.archlinux.org/cgit/aur.git/log/?h=sunshine

@JPenuchot
Copy link

OK … so it's not a regression introduced from the fork (so is not due to a code change), is not unique to Nvidia, but may possibly still be connected to something with Arch Linux? I'm quite lost as to what the cause could be. I had the pre-fork version of Sunshine installed an hour before opening this issue, and my system was 100% up-to-date at the time, so the only updates that could've possibly affected things is anything statically-linked to the compiled binary.

The issue points to avcodec, and it is statically linked indeed. I'll have a look at their bug tracker to find out if there's been any sort of regression.

The fact that it works on Intel is interesting.

Not 100% sure but as far as I know my 6300U doesn't have any hardware encoder

@JPenuchot
Copy link

And there it is: https://trac.ffmpeg.org/ticket/9666

@JPenuchot
Copy link

Sorry I just found out I forgot to build Sunshine with ffmpeg 4.4, so I just polluted this issue with something that's already been solved here: #63

I've added the CMake flags to link against ffmpeg 4.4 and I'm back to the Couldn't expose some/all drm planes for card: /dev/dri/card0 error

@ReenigneArcher ReenigneArcher changed the title Process dies almost immediately; unable to find encoder (Arch Linux — February 2022) Unable to find encoder Feb 26, 2022
@cyl3x
Copy link

cyl3x commented Feb 27, 2022

I fixed my issue by adding -DLIBSWSCALE_INCLUDE_DIR=/usr/include/ffmpeg4.4 -DLIBSWSCALE_LIBRARIES=/usr/lib/ffmpeg4.4/libswscale.so as CMAKE Flags in the PKGBUILD from AUR

@pogojotz
Copy link

I can confirm that @cyl3x's solution works. Cheers for that 🍻

@JPenuchot
Copy link

Back to business indeed. Thanks a lot :)

@pogojotz
Copy link

pogojotz commented Mar 1, 2022

This has been resolved in the AUR. Can be closed.

@mdeguzis
Copy link

In my case, I needed to make sure I set the DISPLAY in the systemd unit file. I noticed things would run fine if I didn't launch the app image via systemd

[gamer@chimeraos tmp]$ cat ~/.config/systemd/user/sunshine.service 
[Unit]
Description=Sunshine self-hosted game stream host for Moonlight.
StartLimitIntervalSec=500
StartLimitBurst=5

[Service]
ExecStart=%h/software/sunshine.AppImage
Restart=on-failure
RestartSec=5s
Environment=DISPLAY=chimeraos:10.0
#Flatpak Only
#ExecStop=flatpak kill dev.lizardbyte.sunshine

[Install]
WantedBy=graphical-session.target

@VRKade11
Copy link

VRKade11 commented Mar 3, 2024

do you mind if you elaborate on the solution a little bit I have the code but I don't know where to put it

@ReenigneArcher
Copy link
Member

@VRKade11 you need to set the DISPLAY environment variable

@VRKade11
Copy link

VRKade11 commented Mar 3, 2024

Well I figured it out it was the output name and adapter name needed to be blank or I messed something up with the name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
os:Linux:Arch OS is Arch Linux
Projects
None yet
Development

No branches or pull requests

8 participants