From 54b03eabbd8eb481da707ee31bd716ae9806b80f Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 31 Dec 2023 15:44:37 +0100 Subject: Fix for opensuse: set unix domain socket mod 777 Fixes screen capture on opensuse amd/intel or nvidia wayland --- README.md | 4 +--- kms/client/kms_client.c | 8 +++++++- src/main.cpp | 14 ++++++++++---- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4c93c00..1883558 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ![](https://dec05eba.com/images/gpu_screen_recorder_logo_small.png) # GPU Screen Recorder -This is a screen recorder that has minimal impact on system performance by recording a window using the GPU only, +This is a screen recorder that has minimal impact on system performance by recording your monitor using the GPU only, similar to shadowplay on windows. This is the fastest screen recording tool for Linux. This screen recorder can be used for recording your desktop offline, for live streaming and for nvidia shadowplay-like instant replay, @@ -37,8 +37,6 @@ NVIDIA driver has a "feature" (read: bug) where it will downclock memory transfe To enable overclocking for optimal performance use the `-oc` option when running GPU Screen Recorder. You also need to have "Coolbits" NVIDIA X setting set to "12" to enable overclocking. You can automatically add this option if you run `sudo nvidia-xconfig --cool-bits=12` and then reboot your computer.\ Note that this only works when Xorg server is running as root, and using this option will only give you a performance boost if the game you are recording is bottlenecked by your GPU.\ Note! use at your own risk! -## Note about optimal performance on AMD/Intel -Performance is the same when recording a single window or the monitor, however in some cases, such as when gpu usage is 100%, the video capture rate might be slower than the games fps when recording a single window instead of a monitor. Recording the monitor instead is recommended in such cases. # Installation If you are running an Arch Linux based distro, then you can find gpu screen recorder on aur under the name gpu-screen-recorder-git (`yay -S gpu-screen-recorder-git`).\ diff --git a/kms/client/kms_client.c b/kms/client/kms_client.c index bcd6870..0b28b48 100644 --- a/kms/client/kms_client.c +++ b/kms/client/kms_client.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #define GSR_SOCKET_PAIR_LOCAL 0 @@ -229,7 +230,12 @@ int gsr_kms_client_init(gsr_kms_client *self, const char *card_path) { local_addr.sun_family = AF_UNIX; strncpy_safe(local_addr.sun_path, self->initial_socket_path, sizeof(local_addr.sun_path)); - if(bind(self->initial_socket_fd, (struct sockaddr*)&local_addr, sizeof(local_addr.sun_family) + strlen(local_addr.sun_path)) == -1) { + + const mode_t prev_mask = umask(0000); + int bind_res = bind(self->initial_socket_fd, (struct sockaddr*)&local_addr, sizeof(local_addr.sun_family) + strlen(local_addr.sun_path)); + umask(prev_mask); + + if(bind_res == -1) { fprintf(stderr, "gsr error: gsr_kms_client_init: failed to bind socket, error: %s\n", strerror(errno)); goto err; } diff --git a/src/main.cpp b/src/main.cpp index d257bc2..9afb631 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1970,6 +1970,10 @@ int main(int argc, char **argv) { } else { const AVCodec *h265_codec = find_h265_encoder(gpu_inf.vendor, card_path); + if(h265_codec && fps > 60) { + fprintf(stderr, "Warning: recording at higher fps than 60 with h265 might result in recording at a very low fps. If this happens, switch to h264\n"); + } + // h265 generally allows recording at a higher resolution than h264 on nvidia cards. On a gtx 1080 4k is the max resolution for h264 but for h265 it's 8k. // Another important info is that when recording at a higher fps than.. 60? h265 has very bad performance. For example when recording at 144 fps the fps drops to 1 // while with h264 the fps doesn't drop. @@ -2050,10 +2054,12 @@ int main(int argc, char **argv) { } fprintf(stderr, "Error: your gpu does not support '%s' video codec. If you are sure that your gpu does support '%s' video encoding and you are using an AMD/Intel GPU,\n" - " then it's possible that your distro has disabled hardware accelerated video encoding for '%s' video codec.\n" - " This may be the case on corporate distros such as Manjaro.\n" - " You can test this by running 'vainfo | grep VAEntrypointEncSlice' to see if it matches any H264/HEVC/AV1 profile. vainfo is part of libva-utils.\n" - " On such distros, you need to manually install mesa from source to enable H264/HEVC/AV1 hardware acceleration, or use a more user friendly distro.\n", video_codec_name, video_codec_name, video_codec_name); + " then make sure you have installed the GPU specific vaapi packages.\n" + " It's also possible that your distro has disabled hardware accelerated video encoding for '%s' video codec.\n" + " This may be the case on corporate distros such as Manjaro, Fedora or OpenSUSE.\n" + " You can test this by running 'vainfo | grep VAEntrypointEncSlice' to see if it matches any H264/HEVC profile. Also make sure 'ffmpeg -h encoder=h264_vaapi' doesn't return any error.\n" + " vainfo is part of libva-utils.\n" + " On such distros, you need to manually install mesa from source to enable H264/HEVC hardware acceleration, or use a more user friendly distro. Alternatively record with AV1 if supported by your GPU.\n", video_codec_name, video_codec_name, video_codec_name); _exit(2); } -- cgit v1.2.3