Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
OBS Studio - Global media source
obs = obslua
mediaSource = nil -- Null pointer
outputIndex = 63 -- Last index
-- A function named script_description returns the description shown to
-- the user
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_path(props, "path", "Local media path", obs.OBS_PATH_FILE, "*", 0)
return props
end
-- a function named script_load will be called on startup
function script_load(settings)
local sourceSettings = obs.obs_data_create()
obs.obs_data_set_bool(sourceSettings, "is_local_file", true)
obs.obs_data_set_string(sourceSettings, "local_file", obs.obs_data_get_string(settings, "path"))
obs.obs_data_set_bool(sourceSettings, "looping", true)
mediaSource = obs.obs_source_create_private("ffmpeg_source", "Global Media Source", sourceSettings)
obs.obs_data_release(sourceSettings)
obs.obs_set_output_source(outputIndex, mediaSource)
end
function script_unload()
obs.obs_set_output_source(outputIndex, nil)
obs.obs_source_release(mediaSource)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment