diff mbox series

[bug#45707,v2] gnu: Add obs-v4l2sink.

Message ID 87turt4ogl.fsf@gmail.com
State New
Headers show
Series [bug#45707,v2] gnu: Add obs-v4l2sink. | expand

Checks

Context Check Description
cbaines/submitting builds success
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Evan Straw Jan. 6, 2021, 11:47 p.m. UTC

Comments

Nicolò Balzarotti Jan. 7, 2021, 12:11 a.m. UTC | #1
Thanks for the update.

Evan Straw <evan.straw99@gmail.com> writes:
> +              (method git-fetch)
> +              (uri (git-reference (url "https://github.com/CatxFish/obs-v4l2sink")
> +                                  (commit version)))


I'm not 100% sure (I usually don't do patch review) but I think the
indentation is wrong (line should break after git-reference).

> +    (inputs `(("qtbase" ,qtbase)
> +              ("obs" ,obs)))
I think it's the same after inputs..

> +    (description "An @dfn{Open Broadcaster Software} (OBS) Studio plugin that
> +provides output capabilities to a @dfn{Video4Linux2} (v4l2) device.  It can be
> +used with @code{v4l2loopback} to achieve cross-program video transfer between
I think that instead of definitions, those are acronyms, so it should be
@acronym{OBS, Open Broadcaster Software} and @acronym{Video 4 Linux 2,
vl42}.

I'd say that you should wait for somebody that knows better than me
before applying my suggestions.

It builds and lint is ok, but obs does not work on my laptop (video card
too old) so I cannot test that it run.

Nicolo
Evan Straw Jan. 7, 2021, 4:37 a.m. UTC | #2
On further investigation, I'm not even sure this package will work correctly because of the way OBS handles plugins. To install plugins, OBS requires that you add their .so files to a plugins directory under the OBS share directory, which under Guix should be immutable. As far as I'm aware, there doesn't seem to be a way to get OBS to use a different directory or use an environment variable containing search paths. Not sure if there is a way to even get plugins for OBS to work at all under Guix if this is the case.

Apologies for creating this patch without having really done this research first. If there's really no way to get this to work under Guix, then feel free to just close this ticket.

--Evan

Jan 6, 2021 3:47:55 PM Evan Straw <evan.straw99@gmail.com>:

>
Alexey Abramov Jan. 7, 2021, 8:19 a.m. UTC | #3
Hi Evan,

You can make it work. 

In order to provide plugins for obs via $XDG_CONFIG_HOME (~/.config) you need to provide the following structure:

"$XDG_CONFIG_HOME/obs-studio/plugins/<module-name>/bin/<arch>/"

As it implemented in obs-studio (~/obs-studio/UI/window-basic-main.cpp)

--8<---------------cut here---------------start------------->8---
  static void AddExtraModulePaths()
  {
          char base_module_dir[512];
  #if defined(_WIN32) || defined(__APPLE__)
          int ret = GetProgramDataPath(base_module_dir, sizeof(base_module_dir),
                                       "obs-studio/plugins/%module%");
  #else
          int ret = GetConfigPath(base_module_dir, sizeof(base_module_dir),
                                  "obs-studio/plugins/%module%");
  #endif

          if (ret <= 0)
                  return;

          string path = base_module_dir;
  #if defined(__APPLE__)
          obs_add_module_path((path + "/bin").c_str(), (path + "/data").c_str());

          BPtr<char> config_bin =
                  os_get_config_path_ptr("obs-studio/plugins/%module%/bin");
          BPtr<char> config_data =
                  os_get_config_path_ptr("obs-studio/plugins/%module%/data");
          obs_add_module_path(config_bin, config_data);

  #elif ARCH_BITS == 64
          obs_add_module_path((path + "/bin/64bit").c_str(),
                              (path + "/data").c_str());
  #else
          obs_add_module_path((path + "/bin/32bit").c_str(),
                              (path + "/data").c_str());
  #endif
  }
--8<---------------cut here---------------end--------------->8---


So what I am currently have is this:

--8<---------------cut here---------------start------------->8---
  λ find ~/.config/obs-studio/plugins 
  /home/levenson/.config/obs-studio/plugins
  /home/levenson/.config/obs-studio/plugins/v4l2sink
  /home/levenson/.config/obs-studio/plugins/v4l2sink/bin
  /home/levenson/.config/obs-studio/plugins/v4l2sink/bin/64bit
  /home/levenson/.config/obs-studio/plugins/v4l2sink/bin/64bit/v4l2sink.so
--8<---------------cut here---------------end--------------->8---

where the library is a symlink

v4l2sink.so -> /home/levenson/.guix-profile/lib/obs-plugins/v4l2sink.so
Ludovic Courtès Jan. 13, 2021, 2:35 p.m. UTC | #4
Hi,

Alexey Abramov <levenson@mmer.org> skribis:

> In order to provide plugins for obs via $XDG_CONFIG_HOME (~/.config) you need to provide the following structure:
>
> "$XDG_CONFIG_HOME/obs-studio/plugins/<module-name>/bin/<arch>/"
>
> As it implemented in obs-studio (~/obs-studio/UI/window-basic-main.cpp)
>
>   static void AddExtraModulePaths()
>   {
>           char base_module_dir[512];
>   #if defined(_WIN32) || defined(__APPLE__)
>           int ret = GetProgramDataPath(base_module_dir, sizeof(base_module_dir),
>                                        "obs-studio/plugins/%module%");
>   #else
>           int ret = GetConfigPath(base_module_dir, sizeof(base_module_dir),
>                                   "obs-studio/plugins/%module%");
>   #endif

What about patching this function so that it honors, say, an
‘OBS_PLUGIN_PATH’ environment variable?

We’d put plugins under $prefix/lib/obs-studio/plugins and define a
‘search-path-specification’ for it.

My 2¢,
Ludo’.
pelzflorian (Florian Pelz) Jan. 15, 2021, 5:10 p.m. UTC | #5
Hello Evan!

Since OBS version 26.1 without any plugins there is a new button
“Start Virtual Camera” in the bottom right.

Is this v4l2sink plugin really still useful?  If I tested corrrectly,
it is not.

Making OBS plugins usable by search path is good though.

Regards,
Florian
Evan Straw Jan. 15, 2021, 7:25 p.m. UTC | #6
Hi Florian,

"pelzflorian (Florian Pelz)" <pelzflorian@pelzflorian.de> writes:

> Since OBS version 26.1 without any plugins there is a new button
> “Start Virtual Camera” in the bottom right.

I was actually not aware of this, I guess I did not have the required
kernel module installed so it didn't show up for me. With that said, I
suppose that this package is indeed not very useful anymore since this
functionality is built into OBS. Apologies, this was some poor research
on my part. Still, maybe it's good to have started the discussion of how
to package OBS plugins for Guix in the future.

-- Evan
diff mbox series

Patch

From 7bcaffb15f1f6697310a4c4bacb8dea1eca2a4e8 Mon Sep 17 00:00:00 2001
From: Evan Straw <evan.straw99@gmail.com>
Date: Wed, 6 Jan 2021 15:33:25 -0800
Subject: [PATCH] gnu: Add obs-v4l2sink.

* gnu/packages/video.scm (obs-v4l2sink): New variable.
---
 gnu/packages/video.scm | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/gnu/packages/video.scm b/gnu/packages/video.scm
index 2b1b111e97..194699dd23 100644
--- a/gnu/packages/video.scm
+++ b/gnu/packages/video.scm
@@ -3133,6 +3133,45 @@  and JACK.")
     (home-page "https://obsproject.com")
     (license license:gpl2+)))
 
+(define-public obs-v4l2sink
+  (package
+    (name "obs-v4l2sink")
+    (version "0.1.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference (url "https://github.com/CatxFish/obs-v4l2sink")
+                                  (commit version)))
+              (file-name (string-append name "-" version))
+              (sha256
+               (base32
+                "0l4lavaywih5lzwgxcbnvdrxhpvkrmh56li06s3aryikngxwsk3z"))))
+    (build-system cmake-build-system)
+    (arguments `(#:tests? #f ;; obs-v4l2sink does not have tests
+                 #:phases
+                 (modify-phases %standard-phases
+                   ;; The CMakeLists.txt file for obs-v4l2sink attempts to use
+                   ;; its own method to search for libobs which uses a lot of
+                   ;; hardcoded paths and ultimately fails under Guix. OBS
+                   ;; already comes with its own CMake configuration, so
+                   ;; remove the line that uses the hardcoded method and just
+                   ;; let CMake locate OBS.
+                   (add-before 'configure 'fix-libobs
+                     (lambda* _
+                       (substitute* "CMakeLists.txt"
+                         (("^.*FindLibObs.*$") ""))
+                       #t)))))
+    (inputs `(("qtbase" ,qtbase)
+              ("obs" ,obs)))
+    (home-page "https://github.com/CatxFish/obs-v4l2sink")
+    (synopsis "OBS Studio output plugin for Video4Linux2 device")
+    (description "An @dfn{Open Broadcaster Software} (OBS) Studio plugin that
+provides output capabilities to a @dfn{Video4Linux2} (v4l2) device.  It can be
+used with @code{v4l2loopback} to achieve cross-program video transfer between
+OBS Studio and third party software supporting Video4Linux2, e.g. to present
+an OBS session in browser-based conferencing systems by selecting the OBS
+session as a webcam.")
+    (license license:gpl2+)))
+
 (define-public libvdpau
   (package
     (name "libvdpau")
-- 
2.25.1