diff options
| author | Oleg Pykhalov <go.wigust@gmail.com> | 2024-12-07 15:34:59 +0300 |
|---|---|---|
| committer | Oleg Pykhalov <go.wigust@gmail.com> | 2024-12-07 16:40:25 +0300 |
| commit | ec542755f860e050f2355c0b305cafc386496abf (patch) | |
| tree | 6f1acd89f2ca4d5362eb7d7666323d7c44302e1b | |
| parent | packages: Add emacs-lsp-java with fixed icons. (diff) | |
| download | guix-wigust-ec542755f860e050f2355c0b305cafc386496abf.tar.gz | |
packages: Add obs-ndi.
| -rw-r--r-- | .guix-channel | 14 | ||||
| -rw-r--r-- | guix/hardcode-ndi-path.patch | 14 | ||||
| -rw-r--r-- | guix/obs-ndi-add-additional-latency-mode.patch | 78 | ||||
| -rw-r--r-- | guix/wigust/packages/video.scm | 230 |
4 files changed, 331 insertions, 5 deletions
diff --git a/.guix-channel b/.guix-channel index 8cec433..cebed32 100644 --- a/.guix-channel +++ b/.guix-channel @@ -1,3 +1,15 @@ (channel (version 0) - (directory "guix")) + (directory "guix") + (dependencies + (channel + (name nonguix) + (url "https://gitlab.com/nonguix/nonguix") + (branch "master") + (commit + "720df79727769e4230706e891841ec6f0b8b3890") + (introduction + (channel-introduction + (version 0) + (commit "897c1a470da759236cc11798f4e0a5f7d4d59fbc") + (signer "2A39 3FFF 68F4 EF7A 3D29 12AF 6F51 20A0 22FB B2D5")))))) diff --git a/guix/hardcode-ndi-path.patch b/guix/hardcode-ndi-path.patch new file mode 100644 index 0000000..00daa40 --- /dev/null +++ b/guix/hardcode-ndi-path.patch @@ -0,0 +1,14 @@ +--- a/src/obs-ndi.cpp 1970-01-01 03:00:01.000000000 +0300 ++++ b/src/obs-ndi.cpp 2024-08-04 03:58:33.271766959 +0300 +@@ -229,10 +229,7 @@ + if (!path.isEmpty()) { + locations << path; + } +-#if defined(__linux__) || defined(__APPLE__) +- locations << "/usr/lib"; +- locations << "/usr/local/lib"; +-#endif ++ locations << "@NDI@/lib"; + for (QString location : locations) { + path = QDir::cleanPath( + QDir(location).absoluteFilePath(NDILIB_LIBRARY_NAME)); diff --git a/guix/obs-ndi-add-additional-latency-mode.patch b/guix/obs-ndi-add-additional-latency-mode.patch new file mode 100644 index 0000000..db2ef7a --- /dev/null +++ b/guix/obs-ndi-add-additional-latency-mode.patch @@ -0,0 +1,78 @@ +From 205098f366878956ae2ef79a7e6121b08c1f1cc1 Mon Sep 17 00:00:00 2001 +From: Oleg Pykhalov <go.wigust@gmail.com> +Date: Sun, 29 Sep 2024 22:51:11 +0300 +Subject: [PATCH] src: obs-ndi-source: Add additional latency mode with obs + buffering still + +--- + src/obs-ndi-source.cpp | 26 ++++++++++++++++---------- + 1 file changed, 16 insertions(+), 10 deletions(-) + +diff --git a/src/obs-ndi-source.cpp b/src/obs-ndi-source.cpp +index 631198f..db5699d 100644 +--- a/src/obs-ndi-source.cpp ++++ b/src/obs-ndi-source.cpp +@@ -57,6 +57,7 @@ with this program. If not, see <https://www.gnu.org/licenses/> + + #define PROP_LATENCY_NORMAL 0 + #define PROP_LATENCY_LOW 1 ++#define PROP_LATENCY_LOWEST 2 + + extern NDIlib_find_instance_t ndi_finder; + +@@ -278,6 +279,10 @@ obs_properties_t *ndi_source_getproperties(void *data) + latency_modes, + obs_module_text("NDIPlugin.SourceProps.Latency.Low"), + PROP_LATENCY_LOW); ++ obs_property_list_add_int( ++ latency_modes, ++ obs_module_text("NDIPlugin.SourceProps.Latency.Lowest"), ++ PROP_LATENCY_LOWEST); + + obs_properties_add_bool(props, PROP_AUDIO, + obs_module_text("NDIPlugin.SourceProps.Audio")); +@@ -356,15 +361,11 @@ void *ndi_source_poll_audio_video(void *data) + + switch (s->sync_mode) { + case PROP_SYNC_NDI_TIMESTAMP: +- obs_audio_frame.timestamp = +- (uint64_t)(audio_frame.timestamp * +- 100); ++ obs_audio_frame.timestamp = (uint64_t)(audio_frame.timestamp * 100); + break; + + case PROP_SYNC_NDI_SOURCE_TIMECODE: +- obs_audio_frame.timestamp = +- (uint64_t)(audio_frame.timecode * +- 100); ++ obs_audio_frame.timestamp = (uint64_t)(audio_frame.timecode * 100); + break; + } + +@@ -496,7 +497,10 @@ void ndi_source_update(void *data, obs_data_t *settings) + recv_desc.source_to_connect_to.p_ndi_name = + obs_data_get_string(settings, PROP_SOURCE); + recv_desc.allow_video_fields = true; +- recv_desc.color_format = NDIlib_recv_color_format_UYVY_BGRA; ++ if (obs_data_get_int(settings, PROP_LATENCY) == PROP_LATENCY_NORMAL) ++ recv_desc.color_format = NDIlib_recv_color_format_UYVY_BGRA; ++ else ++ recv_desc.color_format = NDIlib_recv_color_format_fastest; + + switch (obs_data_get_int(settings, PROP_BANDWIDTH)) { + case PROP_BW_HIGHEST: +@@ -526,9 +530,8 @@ void ndi_source_update(void *data, obs_data_t *settings) + s->yuv_colorspace = prop_to_colorspace( + (int)obs_data_get_int(settings, PROP_YUV_COLORSPACE)); + +- const bool is_unbuffered = +- (obs_data_get_int(settings, PROP_LATENCY) == PROP_LATENCY_LOW); +- obs_source_set_async_unbuffered(s->source, is_unbuffered); ++ // disable OBS buffering only for "Lowest" latency mode ++ obs_source_set_async_unbuffered(s->source, true); + + s->audio_enabled = obs_data_get_bool(settings, PROP_AUDIO); + +-- +2.41.0 + diff --git a/guix/wigust/packages/video.scm b/guix/wigust/packages/video.scm index e3839e9..b153b90 100644 --- a/guix/wigust/packages/video.scm +++ b/guix/wigust/packages/video.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2020 Oleg Pykhalov <go.wigust@gmail.com> +;;; Copyright © 2020, 2024 Oleg Pykhalov <go.wigust@gmail.com> ;;; ;;; This file is part of GNU Guix. ;;; @@ -17,11 +17,34 @@ ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. (define-module (wigust packages video) - #:use-module (guix packages) - #:use-module (guix build-system trivial) + #:use-module (gnu packages) + #:use-module (gnu packages algebra) + #:use-module (gnu packages avahi) + #:use-module (gnu packages base) + #:use-module (gnu packages bash) + #:use-module (gnu packages compression) + #:use-module (gnu packages elf) + #:use-module (gnu packages gawk) + #:use-module (gnu packages gcc) + #:use-module (gnu packages pkg-config) #:use-module (gnu packages python) + #:use-module (gnu packages qt) + #:use-module (gnu packages video) + #:use-module (guix build-system cmake) + #:use-module (guix build-system copy) + #:use-module (guix build-system trivial) + #:use-module (guix download) + #:use-module (guix gexp) #:use-module (guix git-download) - #:use-module ((guix licenses) #:prefix license:)) + #:use-module (guix hg-download) + #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix packages) + #:use-module (guix svn-download) + #:use-module (guix utils) + #:use-module (ice-9 match) + #:use-module (nongnu packages chromium) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26)) (define-public y2rss (let ((commit "d5bc8173028d1594d6c7575e3f7c309553403074") @@ -58,3 +81,202 @@ (description "This script takes a URL argument to a YouTube channel/playlist and returns a link to the corresponding RSS feed.") (license #f)))) + +(define-public ndi + (package + (name "ndi") + (version "5.6.1") ;NDI SDK for Linux/Version.txt + ;; https://downloads.ndi.tv/SDK/NDI_SDK_Linux/Install_NDI_SDK_v5_Linux.tar.gz + (source (local-file "/home/oleg/Install_NDI_SDK_v5_Linux.tar.gz")) + (build-system trivial-build-system) + (inputs (list bash-minimal tar findutils coreutils gawk gzip tar glibc patchelf `(,gcc "lib") avahi)) + (native-inputs `(("source" ,source))) + (arguments + (list + #:modules '((guix build utils)) + #:builder + #~(begin + (use-modules (guix build utils)) + (setenv "PATH" + (string-append + #$(this-package-input "gzip") "/bin" + ":" #$(this-package-input "tar") "/bin" + ":" #$(this-package-input "avahi") "/bin" + ":" #$(this-package-input "bash-minimal") "/bin" + ":" #$(this-package-input "gawk") "/bin" + ":" #$(this-package-input "findutils") "/bin" + ":" #$(this-package-input "tar") "/bin" + ":" #$(this-package-input "coreutils") "/bin" + ":" #$(this-package-input "patchelf") "/bin")) + (invoke "tar" "-xf" #$(this-package-native-input "source")) + (system "echo y | bash -x ./Install_NDI_SDK_v5_Linux.sh") + ;; Install binaries. + (mkdir-p (string-append #$output "/bin")) + (for-each (lambda (file) + (invoke "patchelf" + "--set-interpreter" + (string-append #$(this-package-input "glibc") + "/lib/ld-linux-x86-64.so.2") + (string-append "NDI SDK for Linux/bin/x86_64-linux-gnu/" file)) + (copy-file (string-append "NDI SDK for Linux/bin/x86_64-linux-gnu/" file) + (string-append #$output "/bin/" file))) + '("ndi-benchmark" + "ndi-free-audio" + "ndi-directory-service")) + (invoke "patchelf" + "--set-interpreter" + (string-append #$(this-package-input "glibc") + "/lib/ld-linux-x86-64.so.2") + "--set-rpath" (string-append #$(this-package-input "avahi") "/lib") + (string-append "NDI SDK for Linux/bin/x86_64-linux-gnu/ndi-record")) + (copy-file "NDI SDK for Linux/bin/x86_64-linux-gnu/ndi-record" + (string-append #$output "/bin/ndi-record")) + ;; Install libraries. + (mkdir-p (string-append #$output "/lib")) + (for-each (lambda (file) + (invoke "patchelf" + "--set-rpath" (string-append #$(this-package-input "avahi") "/lib") + (string-append "NDI SDK for Linux/lib/x86_64-linux-gnu/" file)) + (copy-file (string-append "NDI SDK for Linux/lib/x86_64-linux-gnu/" file) + (string-append #$output "/lib/" file))) + '("libndi.so.5.6.1")) + (with-directory-excursion (string-append #$output "/lib") + (for-each (lambda (file) + (symlink "libndi.so.5.6.1" file)) + '("libndi.so.5" + "libndi.so"))) + ;; Install misc. + (for-each (lambda (directory) + (mkdir-p (string-append #$output "/" directory)) + (copy-recursively (string-append "NDI SDK for Linux/" directory) + (string-append #$output "/" directory))) + '("include" "examples")) + (mkdir-p (string-append #$output "/doc")) + (for-each (lambda (directory) + (copy-recursively directory + (string-append #$output "/doc"))) + '("licenses" "logos"))))) + (home-page "") + (synopsis "") + (description "") + (license #f))) + +(define-public obs-ndi + (package + (name "obs-ndi") + (version "4.11.1") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/Palakis/obs-ndi") + (commit version))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "1wsb1k0jilcn6gqgpq5kq8hjiwnb6mi2w32fsqgb88iicwj1qa3y")) + (patches (append (search-patches "hardcode-ndi-path.patch") + (search-patches "obs-ndi-add-additional-latency-mode.patch"))))) + (build-system cmake-build-system) + (inputs + (list ndi obs qtbase-5)) + (arguments + (list + #:tests? #f ;no tests + #:phases + #~(modify-phases %standard-phases + (add-before 'configure 'ndi + (lambda* (#:key inputs #:allow-other-keys) + (let ((ndi #$(this-package-input "ndi"))) + (substitute* "src/obs-ndi.cpp" + (("@NDI@") ndi)) + (delete-file-recursively "lib/ndi") + (symlink (string-append ndi "/include") + "lib/ndi")))) + (add-after 'install 'obs-plugins + (lambda* (#:key outputs #:allow-other-keys) + (mkdir-p (string-append #$output "/lib/obs-plugins")) + (symlink + (string-append #$output + "/obs-plugins/64bit/obs-ndi.so") + (string-append #$output + "/lib/obs-plugins/obs-ndi.so"))))))) + (home-page "") + (synopsis "") + (description "") + (license #f))) + +(define-public ndi-4 + (package + (name "ndi-4") + (version "4") ;NDI SDK for Linux/Version.txt + ;; https://downloads.ndi.tv/SDK/NDI_SDK_Linux/Install_NDI_SDK_v5_Linux.tar.gz + (source (local-file "/home/oleg/src/git.puscii.nl/puppetexp/puppet-sms/files/InstallNDISDK_v4_Linux.sh")) + (build-system trivial-build-system) + (inputs (list bash-minimal tar findutils coreutils gawk gzip tar glibc patchelf `(,gcc "lib") avahi)) + (native-inputs `(("source" ,source))) + (arguments + (list + #:modules '((guix build utils)) + #:builder + #~(begin + (use-modules (guix build utils)) + (setenv "PATH" + (string-append + #$(this-package-input "gzip") "/bin" + ":" #$(this-package-input "tar") "/bin" + ":" #$(this-package-input "avahi") "/bin" + ":" #$(this-package-input "bash-minimal") "/bin" + ":" #$(this-package-input "gawk") "/bin" + ":" #$(this-package-input "findutils") "/bin" + ":" #$(this-package-input "tar") "/bin" + ":" #$(this-package-input "coreutils") "/bin" + ":" #$(this-package-input "patchelf") "/bin")) + (system (string-append "echo y | bash -x " #$(this-package-native-input "source"))) + ;; Install binaries. + (mkdir-p (string-append #$output "/bin")) + (for-each (lambda (file) + (invoke "patchelf" + "--set-interpreter" + (string-append #$(this-package-input "glibc") + "/lib/ld-linux-x86-64.so.2") + (string-append "NDI SDK for Linux/bin/x86_64-linux-gnu/" file)) + (copy-file (string-append "NDI SDK for Linux/bin/x86_64-linux-gnu/" file) + (string-append #$output "/bin/" file))) + '("ndi-directory-service")) + (invoke "patchelf" + "--set-interpreter" + (string-append #$(this-package-input "glibc") + "/lib/ld-linux-x86-64.so.2") + "--set-rpath" (string-append #$(this-package-input "avahi") "/lib") + (string-append "NDI SDK for Linux/bin/x86_64-linux-gnu/ndi-record")) + (copy-file "NDI SDK for Linux/bin/x86_64-linux-gnu/ndi-record" + (string-append #$output "/bin/ndi-record")) + ;; Install libraries. + (mkdir-p (string-append #$output "/lib")) + (for-each (lambda (file) + (invoke "patchelf" + "--set-rpath" (string-append #$(this-package-input "avahi") "/lib") + (string-append "NDI SDK for Linux/lib/x86_64-linux-gnu/" file)) + (copy-file (string-append "NDI SDK for Linux/lib/x86_64-linux-gnu/" file) + (string-append #$output "/lib/" file))) + '("libndi.so.4.0.1")) + (with-directory-excursion (string-append #$output "/lib") + (for-each (lambda (file) + (symlink "libndi.so.4.0.1" file)) + '("libndi.so.4" + "libndi.so"))) + ;; Install misc. + (for-each (lambda (directory) + (mkdir-p (string-append #$output "/" directory)) + (copy-recursively (string-append "NDI SDK for Linux/" directory) + (string-append #$output "/" directory))) + '("include" "examples")) + (mkdir-p (string-append #$output "/doc")) + (for-each (lambda (directory) + (copy-recursively directory + (string-append #$output "/doc"))) + '("licenses" "logos"))))) + (home-page "") + (synopsis "") + (description "") + (license #f))) |
