about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSandro <sandro.jaeckel@gmail.com>2022-03-23 05:35:55 +0100
committerGitHub <noreply@github.com>2022-03-23 05:35:55 +0100
commit7c641c7a5d6cc9a65b50b45720bf174e3ece4081 (patch)
tree0b0c506410ef5001864b2376b6315fb071d21e7e
parent85ce10e75a3ad8eb0f1d24ab9c58c703999b475e (diff)
parent9eeffe65addea33801bac5fcf911c452cc67beed (diff)
downloadnixlib-7c641c7a5d6cc9a65b50b45720bf174e3ece4081.tar
nixlib-7c641c7a5d6cc9a65b50b45720bf174e3ece4081.tar.gz
nixlib-7c641c7a5d6cc9a65b50b45720bf174e3ece4081.tar.bz2
nixlib-7c641c7a5d6cc9a65b50b45720bf174e3ece4081.tar.lz
nixlib-7c641c7a5d6cc9a65b50b45720bf174e3ece4081.tar.xz
nixlib-7c641c7a5d6cc9a65b50b45720bf174e3ece4081.tar.zst
nixlib-7c641c7a5d6cc9a65b50b45720bf174e3ece4081.zip
Merge pull request #165351 from babbaj/gpu-screen-recorder
-rw-r--r--pkgs/applications/video/gpu-screen-recorder/default.nix50
-rw-r--r--pkgs/applications/video/gpu-screen-recorder/fix-nvfbc-check.patch38
-rw-r--r--pkgs/applications/video/gpu-screen-recorder/gpu-screen-recorder-gtk.nix46
-rw-r--r--pkgs/top-level/all-packages.nix4
4 files changed, 138 insertions, 0 deletions
diff --git a/pkgs/applications/video/gpu-screen-recorder/default.nix b/pkgs/applications/video/gpu-screen-recorder/default.nix
new file mode 100644
index 000000000000..be02bb5c690e
--- /dev/null
+++ b/pkgs/applications/video/gpu-screen-recorder/default.nix
@@ -0,0 +1,50 @@
+{ stdenv, lib, fetchgit, makeWrapper, pkg-config, cudatoolkit, glew, libX11
+, libXcomposite, glfw, libpulseaudio, ffmpeg }:
+
+stdenv.mkDerivation rec {
+  pname = "gpu-screen-recorder";
+  version = "1.0.0";
+
+  src = fetchgit {
+    url = "https://repo.dec05eba.com/gpu-screen-recorder";
+    rev = "36fd4516db06bcb192e49055319d1778bbed0322";
+    sha256 = "sha256-hYEHM4FOYcPmQ5Yxh520PKy8HiD+G0xv9hrn8SmA07w=";
+  };
+
+  nativeBuildInputs = [
+    pkg-config
+    makeWrapper
+  ];
+
+  buildInputs = [
+    glew
+    libX11
+    libXcomposite
+    glfw
+    libpulseaudio
+    ffmpeg
+  ];
+
+  postPatch = ''
+    substituteInPlace ./build.sh \
+      --replace '/opt/cuda/targets/x86_64-linux/include' '${cudatoolkit}/targets/x86_64-linux/include' \
+      --replace '/usr/lib64/libcuda.so' '${cudatoolkit}/targets/x86_64-linux/lib/stubs/libcuda.so'
+  '';
+
+  buildPhase = ''
+    ./build.sh
+  '';
+
+  installPhase = ''
+    install -Dt $out/bin/ gpu-screen-recorder
+    wrapProgram $out/bin/gpu-screen-recorder --prefix LD_LIBRARY_PATH : /run/opengl-driver/lib
+  '';
+
+  meta = with lib; {
+    description = "A screen recorder that has minimal impact on system performance by recording a window using the GPU only";
+    homepage = "https://git.dec05eba.com/gpu-screen-recorder/about/";
+    license = licenses.gpl3Only;
+    maintainers = with maintainers; [ babbaj ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/pkgs/applications/video/gpu-screen-recorder/fix-nvfbc-check.patch b/pkgs/applications/video/gpu-screen-recorder/fix-nvfbc-check.patch
new file mode 100644
index 000000000000..bd0d7111c80a
--- /dev/null
+++ b/pkgs/applications/video/gpu-screen-recorder/fix-nvfbc-check.patch
@@ -0,0 +1,38 @@
+diff --git a/build.sh b/build.sh
+index 05603db..8c38b31 100755
+--- a/build.sh
++++ b/build.sh
+@@ -2,5 +2,5 @@
+ 
+ dependencies="gtk+-3.0 x11 xrandr libpulse"
+ includes="$(pkg-config --cflags $dependencies)"
+-libs="$(pkg-config --libs $dependencies)"
++libs="$(pkg-config --libs $dependencies) -ldl"
+ g++ -o gpu-screen-recorder-gtk -O2 src/main.cpp -s $includes $libs
+diff --git a/src/main.cpp b/src/main.cpp
+index ae2078f..9dcdce1 100644
+--- a/src/main.cpp
++++ b/src/main.cpp
+@@ -15,6 +15,7 @@
+ #include <pwd.h>
+ #include <libgen.h>
+ #include <functional>
++#include <dlfcn.h>
+ 
+ typedef struct {
+     Display *display;
+@@ -830,7 +831,13 @@ static void audio_input_change_callback(GtkComboBox *widget, gpointer userdata)
+ }
+ 
+ static bool is_nv_fbc_installed() {
+-    return access("/usr/lib/libnvidia-fbc.so.1", F_OK) == 0 || access("/usr/local/lib/libnvidia-fbc.so.1", F_OK) == 0;
++    auto handle = dlopen("libnvidia-fbc.so.1", RTLD_LAZY);
++    if (handle) {
++        dlclose(handle);
++        return true;
++    } else {
++        return false;
++    }
+ }
+ 
+ static GtkWidget* create_common_settings_page(GtkStack *stack, GtkApplication *app) {
diff --git a/pkgs/applications/video/gpu-screen-recorder/gpu-screen-recorder-gtk.nix b/pkgs/applications/video/gpu-screen-recorder/gpu-screen-recorder-gtk.nix
new file mode 100644
index 000000000000..6bfb425f0af9
--- /dev/null
+++ b/pkgs/applications/video/gpu-screen-recorder/gpu-screen-recorder-gtk.nix
@@ -0,0 +1,46 @@
+{ stdenv, lib, fetchgit, pkg-config, makeWrapper, gtk3, libX11, libXrandr
+, libpulseaudio, gpu-screen-recorder }:
+
+stdenv.mkDerivation rec {
+  pname = "gpu-screen-recorder-gtk";
+  version = "0.1.0";
+
+  src = fetchgit {
+    url = "https://repo.dec05eba.com/gpu-screen-recorder-gtk";
+    rev = "4c317abd0531f8e155fbbbcd32850bbeebbf2ead";
+    sha256 = "sha256-5W6qmUMP31ndRDxMHuQ/XnZysPQgaie0vVlMTzfODU4=";
+  };
+
+  patches = [ ./fix-nvfbc-check.patch ];
+
+  nativeBuildInputs = [
+    pkg-config
+    makeWrapper
+  ];
+
+  buildInputs = [
+    gtk3
+    libX11
+    libXrandr
+    libpulseaudio
+  ];
+
+  buildPhase = ''
+    ./build.sh
+  '';
+
+  installPhase = ''
+    install -Dt $out/bin/ gpu-screen-recorder-gtk
+    install -Dt $out/share/applications/ gpu-screen-recorder-gtk.desktop
+
+    wrapProgram $out/bin/gpu-screen-recorder-gtk --prefix PATH : ${lib.makeBinPath [ gpu-screen-recorder ]}
+  '';
+
+  meta = with lib; {
+    description = "GTK frontend for gpu-screen-recorder.";
+    homepage = "https://git.dec05eba.com/gpu-screen-recorder-gtk/about/";
+    license = licenses.gpl3Only;
+    maintainers = with maintainers; [ babbaj ];
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index f7955497ad03..ad051141479d 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -26386,6 +26386,10 @@ with pkgs;
 
   gpsprune = callPackage ../applications/misc/gpsprune { };
 
+  gpu-screen-recorder = callPackage ../applications/video/gpu-screen-recorder { };
+
+  gpu-screen-recorder-gtk = callPackage ../applications/video/gpu-screen-recorder/gpu-screen-recorder-gtk.nix { };
+
   gpxlab = libsForQt5.callPackage ../applications/misc/gpxlab { };
 
   gpxsee = libsForQt5.callPackage ../applications/misc/gpxsee { };