obsproject / obsproject/obs-studio

obs-scripting + API doc : obs_source_get_color_space() and gs_get_format_from_space()

Open
#9,199 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
76.4k
Forks
10.2k
Avg merge
4d 23h
Merged PRs (30d)
12

Description

Operating System Info

Other

Other OS

Debian 12

OBS Studio Version

29.1.3

OBS Studio Version (Other)

No response

OBS Studio Log URL

N/A

OBS Studio Crash Log URL

No response

Expected Behavior

I am using lua scripting for shader filters. This BR is more a custom binding missing and doc missing hint than a "expected/current behavior" deviation.

I try to make a source filter similar to obs-filters/color-key-filter.c in lua.
In color_key_render_v2(), the existing C++ code uses 3 things :

  • const enum gs_color_space preferred_spaces[] (array)
  • obs_source_get_color_space() passing preferred_spaces array
  • const enum gs_color_format format = gs_get_format_from_space(source_space)

First, it seems that gs_get_format_from_space() is not in the API doc.
Second, it seems that a manual lua binding is necessary for obs_source_get_color_space() last argument : an array of enum values. (it may deduce from lua table the enum count automatically)

Current Behavior

I've tried from lua, in source_info.video_render() callback :

local target = obs.obs_filter_get_target(filter_impl_data.context)
local preferred_spaces = { obs.GS_CS_SRGB, obs.GS_CS_SRGB_16F, obs.GS_CS_709_EXTENDED }
local source_space = obs.obs_source_get_color_space(target, 3, preferred_spaces)

warning: [Lua: cam-png-compose.lua] Failed to call video_render [...] Error in obs_source_get_color_space (arg 3), expected 'enum gs_color_space const *' got 'table'

I think a glue code should allow passing a lua table on enums to lua obs_source_get_color_space() that not need the count as argument and accept a lua table as preferred_spaces.

Steps to Reproduce

N/A

Anything else we should know?

I may try to wrote a PR if it is pertinent.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with obs-filters/color-key-filter.c and the Lua source_info.video_render() example to understand the intended color-space lookup. Inspect the bindings for obs_source_get_color_space() and the API documentation around gs_get_format_from_space(); done means the Lua call accepts the preferred-space values and the missing function is documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, lua
Domain
api, documentation
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.