Skip to content

Instantly share code, notes, and snippets.

@Windows81
Last active January 4, 2026 22:47
Show Gist options
  • Select an option

  • Save Windows81/76c13c3ec634d4c28ea27323c7da8eab to your computer and use it in GitHub Desktop.

Select an option

Save Windows81/76c13c3ec634d4c28ea27323c7da8eab to your computer and use it in GitHub Desktop.
Lua script for Advanced Scene Switcher (on OBS) to make the video scale fully to "Display Capture"
local obs = obslua
local WIDTH_OFFSET_BEFORE = 0
local WIDTH_OFFSET_AFTER = 0
local HEIGHT_OFFSET_BEFORE = 120
local HEIGHT_OFFSET_AFTER = 0
function run()
local source = obs.obs_frontend_get_current_scene()
local scene = obs.obs_scene_from_source(source)
local sceneitem = obs.obs_scene_find_source(scene,"Display Capture")
obs.obs_source_release(source)
local source = obs.obs_sceneitem_get_source(sceneitem)
local width = obs.obs_source_get_width(source)
local height = obs.obs_source_get_height(source)
config = obs.obs_frontend_get_profile_config()
local total_width = width + WIDTH_OFFSET_BEFORE + HEIGHT_OFFSET_AFTER
local total_height = height + HEIGHT_OFFSET_BEFORE + HEIGHT_OFFSET_AFTER
obs.config_set_uint(config, "Video", "BaseCX", total_width)
obs.config_set_uint(config, "Video", "BaseCY", total_height)
obs.config_set_uint(config, "Video", "OutputCX", total_width)
obs.config_set_uint(config, "Video", "OutputCY", total_height)
obs.obs_frontend_reset_video()
obs.config_save(config)
local transform_info = obs.obs_transform_info()
obs.vec2_set(transform_info.scale, 1, 1)
obs.vec2_set(transform_info.pos, WIDTH_OFFSET_BEFORE, HEIGHT_OFFSET_BEFORE)
transform_info.alignment = 5 -- OBS_ALIGN_LEFT | OBS_ALIGN_TOP
obs.obs_sceneitem_set_info2(sceneitem, transform_info)
--obs.script_log(obs.LOG_WARNING, tostring(obs.config_get_uint(config, "Video", "BaseCY")))
return true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment