OBS issues (nix on fedora)

Hi all

So I’m only a few days into nix but I’m very keen to try to understand what’s going on here a little better…

I am on a vanilla fedora 36 installation right now, nvidia GPU and all that stuff natively…

So I just installed the 22.05 release of obs-studio via nix however when I run the package I get an odd error:

Failed to initialize video. Your GPU may not be supported, or your graphics drivers may need to be updated.

This doesn’t make sense as I can run the obs flatpak and rpm versions just fine right now…

am I missing some nvidia deps maybe?

(The reason I’m here is so that I can just run OBS and the “backgroundremoval” plugin, plus I really like what I’ve learned about nix thus far)

To install I have ran: $ nix-env -iA nixpkgs.obs-studio

To launch OBS I ran: $ nix-shell -p obs-studio $ obs

Logs and screenshot follow

❯ nix-channel --list
unstable https://nixos.org/channels/nixpkgs-unstable

~ 
❯ nix-env -q "*"

~ 
❯ nix-env -iA nixpkgs.obs-studio
installing 'obs-studio-27.2.4'
building '/nix/store/50r0lypb9a0gzgd0jv98q9p4d74hy7dx-user-environment.drv'...

~ 
❯ nix-env -iA nixpkgs.obs-studio-plugins.obs-backgroundremoval
installing 'obs-backgroundremoval-0.4.0'

~ 
❯ nix-env -q "*"
obs-backgroundremoval-0.4.0
obs-studio-27.2.4

~ 
❯ nix-shell -p obs-studio
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

[nix-shell:~]$ pwd
/home/starkers

[nix-shell:~]$ git remote -v
fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

[nix-shell:~]$ obs
obs             obs-ffmpeg-mux  

[nix-shell:~]$ which obs
/nix/store/6cn8zxys4lqb7r8zycapqq2x0sbfxsyd-obs-studio-27.2.4/bin/obs

[nix-shell:~]$ obs   

(process:253611): Gtk-WARNING **: 14:21:09.021: Locale not supported by C library.
	Using the fallback 'C' locale.
Gtk-Message: 14:21:09.041: Failed to load module "canberra-gtk-module"
Gtk-Message: 14:21:09.041: Failed to load module "pk-gtk-module"
Gtk-Message: 14:21:09.041: Failed to load module "canberra-gtk-module"
Gtk-Message: 14:21:09.041: Failed to load module "pk-gtk-module"
Attempted path: share/obs/obs-studio/locale/en-US.ini
Attempted path: /nix/store/6cn8zxys4lqb7r8zycapqq2x0sbfxsyd-obs-studio-27.2.4/share/obs/obs-studio/locale/en-US.ini
Attempted path: share/obs/obs-studio/themes/Dark.qss
Attempted path: /nix/store/6cn8zxys4lqb7r8zycapqq2x0sbfxsyd-obs-studio-27.2.4/share/obs/obs-studio/themes/Dark.qss
info: CPU Name: AMD Ryzen 5 3600 6-Core Processor
info: CPU Speed: 4200.039MHz
info: Physical Cores: 6, Logical Cores: 12
info: Physical Memory: 64246MB Total, 33863MB Free
info: Kernel Version: Linux 5.19.14-200.fc36.x86_64
info: Distribution: "Fedora Linux" 36
info: Session Type: x11
info: Window System: X11.0, Vendor: The X.Org Foundation, Version: 1.20.14
info: Qt Version: 5.15.6 (runtime), 5.15.6 (compiled)
info: Portable mode: false
Attempted path: share/obs/obs-studio/themes/Dark/no_sources.svg
Attempted path: /nix/store/6cn8zxys4lqb7r8zycapqq2x0sbfxsyd-obs-studio-27.2.4/share/obs/obs-studio/themes/Dark/no_sources.svg
QMetaObject::connectSlotsByName: No matching signal for on_tbar_position_valueChanged(int)
QMetaObject::connectSlotsByName: No matching signal for on_actionShowTransitionProperties_triggered()
QMetaObject::connectSlotsByName: No matching signal for on_actionHideTransitionProperties_triggered()
info: OBS 27.2.4 (linux)
info: ---------------------------------
info: ---------------------------------
info: audio settings reset:
	samples per sec: 48000
	speakers:        2
info: ---------------------------------
info: Initializing OpenGL...
error: ARB_GLX_create_context not supported!
error: Failed to create context!
error: device_create (GL) failed
error: Failed to initialize video.  Your GPU may not be supported, or your graphics drivers may need to be updated.
qt.glx: qglx_findConfig: Failed to finding matching FBConfig for QSurfaceFormat(version 2.0, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize -1, redBufferSize 1, greenBufferSize 1, blueBufferSize 1, alphaBufferSize -1, stencilBufferSize -1, samples -1, swapBehavior QSurfaceFormat::SingleBuffer, swapInterval 1, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::NoProfile)
No XVisualInfo for format QSurfaceFormat(version 2.0, options QFlags<QSurfaceFormat::FormatOption>(), depthBufferSize -1, redBufferSize 1, greenBufferSize 1, blueBufferSize 1, alphaBufferSize -1, stencilBufferSize -1, samples -1, swapBehavior QSurfaceFormat::SingleBuffer, swapInterval 1, colorSpace QSurfaceFormat::DefaultColorSpace, profile  QSurfaceFormat::NoProfile)
Falling back to using screens root_visual.
^Cinfo: ==== Shutting down ==================================================
info: All scene data cleared
info: ------------------------------------------------
info: Freeing OBS context data
info: == Profiler Results =============================
info: run_program_init: 399824 ms
info:  ┣OBSApp::AppInit: 1.454 ms
info:  ┃ ┗OBSApp::InitLocale: 0.558 ms
info:  ┗OBSApp::OBSInit: 196.267 ms
info:    ┣obs_startup: 1.07 ms
info:    ┗OBSBasic::OBSInit: 13.348 ms
info:      ┣OBSBasic::InitBasicConfig: 0.055 ms
info:      ┣OBSBasic::ResetAudio: 0.084 ms
info:      ┗OBSBasic::ResetVideo: 13.18 ms
info: obs_hotkey_thread(25 ms): min=0.039 ms, median=0.069 ms, max=27.346 ms, 99th percentile=0.171 ms, 99.9937% below 25 ms
info: audio_thread(Audio): min=0 ms, median=0.005 ms, max=0.03 ms, 99th percentile=0.015 ms
info: =================================================
info: == Profiler Time Between Calls ==================
info: obs_hotkey_thread(25 ms): min=25.061 ms, median=25.129 ms, max=52.404 ms, 99.7484% within ±2% of 25 ms (0% lower, 0.25162% higher)
info: =================================================
info: Number of memory leaks: 0

[nix-shell:~]$ ^C

1 Like

Not an expert, but you might need to use NixGL here.

1 Like

Ohh nice yes… thanks! I wasn’t aware that this was a well known issue.

I’ve installed it and can run OBS now

The problem now is that OBS doesn’t seem to load the plugin I’m doing all of this for (obs-backgroundremoval)

The files look OK:

/nix/store/pyz8zn744pk7rbmy3dvg1v60ydinwd5q-obs-backgroundremoval-0.4.0/lib/obs-plugins/obs-backgroundremoval.so

~ 
❯ find /nix/ -type l -name obs-backgroundremoval.so
/nix/store/xkyd1c00i4kp27zq9c1zrmff8w062s8w-user-environment/lib/obs-plugins/obs-backgroundremoval.so
/nix/store/4ybmcahnfxgschhgv1gs2y0m11pc3pm7-user-environment/lib/obs-plugins/obs-backgroundremoval.so
/nix/store/0hrkgfy91a6ri4438f5ql3j50657d3j5-user-environment/lib/obs-plugins/obs-backgroundremoval.so

~ 
❯ find ~/.nix-profile/lib/obs-plugins/
/home/starkers/.nix-profile/lib/obs-plugins/
/home/starkers/.nix-profile/lib/obs-plugins/chrome_100_percent.pak
/home/starkers/.nix-profile/lib/obs-plugins/chrome_200_percent.pak
/home/starkers/.nix-profile/lib/obs-plugins/decklink-captions.so
/home/starkers/.nix-profile/lib/obs-plugins/decklink-ouput-ui.so
/home/starkers/.nix-profile/lib/obs-plugins/frontend-tools.so
/home/starkers/.nix-profile/lib/obs-plugins/icudtl.dat
/home/starkers/.nix-profile/lib/obs-plugins/image-source.so
/home/starkers/.nix-profile/lib/obs-plugins/libcef.so
/home/starkers/.nix-profile/lib/obs-plugins/linux-alsa.so
/home/starkers/.nix-profile/lib/obs-plugins/linux-capture.so
/home/starkers/.nix-profile/lib/obs-plugins/linux-decklink.so
/home/starkers/.nix-profile/lib/obs-plugins/linux-jack.so
/home/starkers/.nix-profile/lib/obs-plugins/linux-pulseaudio.so
/home/starkers/.nix-profile/lib/obs-plugins/linux-v4l2.so
/home/starkers/.nix-profile/lib/obs-plugins/locales
/home/starkers/.nix-profile/lib/obs-plugins/obs-browser-page
/home/starkers/.nix-profile/lib/obs-plugins/obs-browser.so
/home/starkers/.nix-profile/lib/obs-plugins/obs-ffmpeg.so
/home/starkers/.nix-profile/lib/obs-plugins/obs-filters.so
/home/starkers/.nix-profile/lib/obs-plugins/obs-libfdk.so
/home/starkers/.nix-profile/lib/obs-plugins/obs-outputs.so
/home/starkers/.nix-profile/lib/obs-plugins/obs-transitions.so
/home/starkers/.nix-profile/lib/obs-plugins/obs-vst.so
/home/starkers/.nix-profile/lib/obs-plugins/obs-x264.so
/home/starkers/.nix-profile/lib/obs-plugins/resources.pak
/home/starkers/.nix-profile/lib/obs-plugins/rtmp-services.so
/home/starkers/.nix-profile/lib/obs-plugins/snapshot_blob.bin
/home/starkers/.nix-profile/lib/obs-plugins/text-freetype2.so
/home/starkers/.nix-profile/lib/obs-plugins/v8_context_snapshot.bin
/home/starkers/.nix-profile/lib/obs-plugins/vlc-video.so
/home/starkers/.nix-profile/lib/obs-plugins/obs-backgroundremoval.so

however when running obs it seems that it just doesn’t detect them

info: [vlc-video]: VLC 3.0.17.3 Vetinari found, VLC video source enabled
info: ---------------------------------
info:   Loaded Modules:
info:     vlc-video.so
info:     text-freetype2.so
info:     rtmp-services.so
info:     obs-x264.so
info:     obs-vst.so
info:     obs-transitions.so
info:     obs-outputs.so
info:     obs-libfdk.so
info:     obs-filters.so
info:     obs-ffmpeg.so
info:     obs-browser.so
info:     linux-v4l2.so
info:     linux-pulseaudio.so
info:     linux-jack.so
info:     linux-decklink.so
info:     linux-capture.so
info:     linux-alsa.so
info:     image-source.so
info:     frontend-tools.so
info:     decklink-ouput-ui.so
info:     decklink-captions.so
info: ---------------------------------
info: ==== Startup complete ===============================================

Curiously elsewhere in the startup logs it looks like it loads some images/assets from /nix/store/6cn8zxys4lqb7r8zycapqq2x0sbfxsyd-obs-studio-27.2.4/ which appears to be the main-place that obs was installed…

There’s so much nix magic going on here I’m not sure if maybe I’ve done something wrong

you probably have the same problem as Obs-linuxbrowser not showing in OBS.

Ohh yes…

I “did a dirty” and copied the library file into that path like a barbarian and it now loads

image

I find it odd think that I might be first person to notice that this plugin “doesn’t work” out the box… am I just doing something horribly wrong maybe?

You need to use wrapOBS; i.e.

    wrapOBS {
      plugins = with obs-studio-plugins; [
        obs-vkcapture
        obs-gstreamer
      ];
    }
3 Likes

Just in case, to make it clearer, this is best used in place of the obs-studio package, in a list of packages. The function returns a wrapped version of the package, but might need to be enclosed in (), like so:

  environment.systemPackages = with pkgs; [
    this_pkg
    that_pkg
    some_other_pkg

    (wrapOBS {
      plugins = with obs-studio-plugins; [
        obs-backgroundremoval
      ];
    })

    v4l-utils
  ];

The Wiki example is also lacking this extra context to make it clear how to use this, alas.

1 Like

Yes

Thanks for the help… I’ve managed to learn some really basic home-manager so that I just have a config to edit… I use fish so had to triage more than a few annoyances along the way… but it seems I got this wrapOBS to work… but its far from working correctly still…

Looks like it wraps in the .so file, but the library then attempts to load other files (The “Segmentation Models” that it uses via onnx

I’ll keep experimenting but I think I’m officially stumped now unless I can find the source code for wrapOBS and I guess learn how to read more nix… I don’t know even how to append to arrays yet

re: nix + home-manager (WIP) · starkers/dotfiles@605a007 · GitHub

Aha… found it (really hard looking for wrapOBS in the actual code

@Atemu looks like you fixed this already on obs-studio: include plugins in wrapper again · NixOS/nixpkgs@c5e6fb1 · GitHub

Presumably the 22.05 version of nixpks.wrapOBS didn’t include this so I’ve tried via unstable

(without much luck)

...
let
  # nix-channel --add https://nixos.org/channels/nixpkgs-unstable          unstable
  unstable = import <unstable> { };
in
{
  ...
  home.packages = [
    ...
    (unstable.wrapOBS {
      plugins = with unstable.obs-studio-plugins; [
        obs-backgroundremoval
      ];
    })
   ...
  ]

To my eyes… this should work…

yet still I see:

error: [obs-backgroundremoval] Unable to get model filename mediapipe.onnx from plugin.

So now I’m just really stumped… I could buy an actual green screen but I won’t on principle… will try to understand the source-code/OBS a bit more now

Thanks for all the help so far! its been really useful

FWIW, I added the bit I quoted above, on nixos-unstable, and it just worked.

I currently use a green screen, and OBS shows about 4% cpu use. With this plugin instead, it’s up around 60-90% (depending on some options and sliders), and does a worse job. So don’t dismiss the idea completely :slight_smile:

Where is it trying to load mediapipe.onnx from? strace -f it and grep for that filename.