obs-studio-wrapper: allow plugins' arguments

This commit is contained in:
PedroHLC ☭ 2022-08-03 13:19:32 -03:00
parent a035b1b5ac
commit cc26a157ca
No known key found for this signature in database
GPG key ID: DF4C6898CBDC6DF5
2 changed files with 33 additions and 6 deletions

View file

@ -22,6 +22,25 @@ stdenv.mkDerivation rec {
nativeBuildInputs = [ pkg-config meson ninja ];
buildInputs = with gst_all_1; [ gstreamer gst-plugins-base obs-studio ];
# - We need "getLib" instead of default derivation, otherwise it brings gstreamer-bin;
# - without gst-plugins-base it won't even show proper errors in logs;
# - Without gst-plugins-bad it won't find element "h264parse";
# - gst-vaapi adds "VA-API" to "Encoder type";
# - gst-plugins-ugly adds "x264" to "Encoder type";
# Tip: "could not link appsrc to videoconvert1" can mean a lot of things, enable GST_DEBUG=2 for help.
passthru.obsWrapperArguments =
let
gstreamerHook = package: "--prefix GST_PLUGIN_SYSTEM_PATH_1_0 : ${lib.getLib package}/lib/gstreamer-1.0";
in
with gst_all_1; builtins.map gstreamerHook [
gstreamer
gst-plugins-base
gst-plugins-bad
gst-plugins-ugly
gst-vaapi
];
meta = with lib; {
description = "An OBS Studio source, encoder and video filter plugin to use GStreamer elements/pipelines in OBS Studio";
homepage = "https://github.com/fzwoch/obs-gstreamer";

View file

@ -1,4 +1,4 @@
{ obs-studio, symlinkJoin, makeWrapper }:
{ lib, obs-studio, symlinkJoin, makeWrapper }:
{ plugins ? [] }:
@ -8,11 +8,19 @@ symlinkJoin {
nativeBuildInputs = [ makeWrapper ];
paths = [ obs-studio ] ++ plugins;
postBuild = ''
wrapProgram $out/bin/obs \
--set OBS_PLUGINS_PATH "$out/lib/obs-plugins" \
--set OBS_PLUGINS_DATA_PATH "$out/share/obs/obs-plugins"
'';
postBuild = with lib;
let
# Some plugins needs extra environment, see obs-gstreamer for an example.
pluginArguments =
lists.concatMap (plugin: plugin.obsWrapperArguments or []) plugins;
wrapCommand = [
"wrapProgram"
"$out/bin/obs"
''--set OBS_PLUGINS_PATH "$out/lib/obs-plugins"''
''--set OBS_PLUGINS_DATA_PATH "$out/share/obs/obs-plugins"''
] ++ pluginArguments;
in concatStringsSep " " wrapCommand;
inherit (obs-studio) meta;
passthru = obs-studio.passthru // {