Skip to content

Instantly share code, notes, and snippets.

@Palakis
Last active March 20, 2018 22:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Palakis/2b7a0e872c66d209050f6e01b60f1c94 to your computer and use it in GitHub Desktop.
Save Palakis/2b7a0e872c66d209050f6e01b60f1c94 to your computer and use it in GitHub Desktop.
OBS Studio - Global Browser Source (Downstream Keyer)
ffi = require "ffi"
obs = obslua
globalSource = nil -- Null pointer
outputIndex = 63 -- Last index
function script_description()
return "Plays a media source as a global source.\nSelect a file, reload the script and enjoy."
end
function script_properties()
local props = obs.obs_properties_create()
obs.obs_properties_add_text(props, "url", "URL", obs.OBS_TEXT_DEFAULT)
obs.obs_properties_add_int(props, "width", "Width", 1, 4096, 1);
obs.obs_properties_add_int(props, "height", "Height", 1, 4096, 1);
obs.obs_properties_add_int(props, "fps", "FPS", 1, 60, 1);
obs.obs_properties_add_text(props, "css", "Additional CSS", obs.OBS_TEXT_MULTILINE)
return props
end
function script_defaults(settings)
obs.obs_data_set_default_string(settings, "url", "https://www.google.com")
obs.obs_data_set_default_int(settings, "width", 1280)
obs.obs_data_set_default_int(settings, "height", 720)
obs.obs_data_set_default_int(settings, "fps", 30)
obs.obs_data_set_default_string(settings, "css", "body { background-color: rgba(0, 0, 0, 0); margin: 0px auto; overflow: hidden; }")
end
function script_load(settings)
local sourceSettings = obs.obs_data_create()
obs.obs_data_set_string(sourceSettings, "url", obs.obs_data_get_string(settings, "url"))
obs.obs_data_set_int(sourceSettings, "width", obs.obs_data_get_int(settings, "width"))
obs.obs_data_set_int(sourceSettings, "height", obs.obs_data_get_int(settings, "height"))
obs.obs_data_set_int(sourceSettings, "fps", obs.obs_data_get_int(settings, "fps"))
obs.obs_data_set_string(sourceSettings, "css", obs.obs_data_get_string(settings, "css"))
globalSource = obs.obs_source_create_private("browser_source", "Global Browser Source", sourceSettings)
obs.obs_data_release(sourceSettings)
obs.obs_set_output_source(outputIndex, globalSource)
end
function script_unload()
obs.obs_set_output_source(outputIndex, nil)
obs.obs_source_release(globalSource)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment