glava
glava copied to clipboard
OBS native plugin support
I'm looking at getting GLava to function as an OBS plugin to avoid both window management hassles and performance with the current method(s) used to record GLava's output. Since GLava is naturally able to do offscreen rendering to a texture since adding basic support for tests, it should be fairly straightforward to efficiently add it as a source in OBS as it (by default) also uses GLX contexts.
This requires some mucking with OBS internals but surprisingly someone has some similar things with EGL for DMA copies using GL textures, although I'm going to settle for the much simpler (and just as fast) GLX share lists that allow me to share textures between processes.
Ironically I cannot find any native audio visualizer plugins for OBS (even on Windows!), the status quo simply seems to be "record an external application", which leads to some very inefficient screen captures on Linux.
This is going to be part of a larger rework for a 2.0
milestone. See commit f562bc6 for how this has been implemented:
- GLava is no longer a standalone executable, rather it is now a shared library exposing a simple api in
glava/glava.h
. - At the moment
libglava
itself handles argument parsing but this may change such that the client (glava-cli/cli.c
) does so instead and the API simply requires a settings structure. - The API provides asynchronous functions to interact with GLava's renderer, including reloading and resize requests
- The API also provides a
glava_assign_external_ctx
function that can be used to associate GLava's OpenGL context to another via share lists, which consequently causes GLava to switch to offscreen rendering to a GL texture, exposed byoff_tex
in the renderer structure onceglava_wait
returns to indicate this texture is valid.
This in itself is a feature for anyone wishing to embed glava into other X11 applications. Note this will not be stable until 2.0
, which will come with a glava-gtk
tool to configure GLava profiles.
The plugin itself is currently still a stub since I'm still digging around in OBS sources.
Plugin seems to be functional now, with a few critical bugs:
- The source output in rare cases does not initialize, likely due to a race condition.
- Option properties are currently ignored but still trigger full resets of GLava's renderer when changed
- Renderer resets occasionally cause segmentation faults.
- High framerates (>1000FPS) cause the source output to be invisible. This is likely due to how the driver locks texture objects.
I was pleasantly surprised with the performance and output though (no tearing and no performance cost due to offscreen rendering). I will also need to test this on Nvidia and Intel graphics since sharelists have some implementation defined behavior here.
Unfortunately the plugin itself has some very hacky code since it relies on internal OBS structures that are not exposed by its plugin API. This is required since I am essentially assigning a GL texture from GLava to the abstracted gs_texture_t
type in OBS.
Also see obsproject/obs-studio#2052.
Hello I have problem with the GLava OBS plugin. When i try to add the GLava Direct Source to my scene it crashes the OBS. OBS log:
00:23:09.076: Initializing GLava OBS Plugin... 00:23:09.076: Updating GLava state 00:23:09.076: Waiting for GLava GL texture...
system: OS: Manjaro Linux x86_64 Kernel: 5.4.31-1-MANJARO DE: KDE plasma WM: KWin CPU: Ryzen 2700x GPU: AMD RX 580 mem: 16gb
btw what language is GLava written? Never seen that.
Same issue. Will this ever be fixed?
Log:
info: Initializing GLava OBS Plugin...
debug: input str '', set '(null)'
info: Updating GLava state
info: Waiting for GLava GL texture...
Segmentation fault (core dumped)
neofetch details:
~~~~~~~@~~~~
------------------------
OS: Ubuntu 20.04.3 LTS x86_64
Host: ~~~
Kernel: 5.4.0-90-generic
Uptime: ~~~
Packages: ~~~
Shell: bash 5.0.17
Resolution: 1920x1080, 1600x900
DE: Cinnamon
WM: Mutter (Muffin)
WM Theme: Menta (GreenLaguna)
Theme: GreenLaguna [GTK2/3]
Icons: Pixel-Theme [GTK2/3]
Terminal: gnome-terminal
CPU: AMD Ryzen 3 3200G (4) @ 3.600GH
GPU: AMD ATI 07:00.0 Picasso
Memory: 4468MiB / 5909MiB
I'm getting the same error Linux Mint 20.3. Both OBS and Glava are built from git sources:
info: Initializing GLava OBS Plugin... debug: input str '', set '(null)' info: Updating GLava state info: Waiting for GLava GL texture... Segmentation fault (core dumped)