Copy the script text and save it as a .lua file. Typically they are stored here... C:\Program Files\obs-studio\data\obs-plugins\frontend-tools\scripts. Add the new lua script in OBS and it should offer you a new "source" that you can add to a scene to refresh the browser when it is loaded in a preview window. I have this feature as a checkbox in the controller I wrote as well as a "delay" option so the camera will move after the transition but following a preset delay so the move does not show up in any crossfade transitions. Here is the source text again. I don't use PTZOptics cameras, nor do I use a browser to interface my Visca PTZ Cameras with OBS, so it might need testing. I just wrapped your code in a source shell.
++--------------------------------------------------------------
obs = obslua
bit = require("bit")
source_def = {}
source_def.id = "Refresh_Browser"
source_def.type = OBS_SOURCE_TYPE_INPUT;
source_def.output_flags = bit.bor(obs.OBS_SOURCE_CUSTOM_DRAW)
source_def.get_name = function()
return "Refresh Browser On Preview"
end
function script_description()
return "Adds a Refresh Browser On Show Source"
end
source_def.get_properties = function (data)
end
source_def.destroy = function(source)
end
source_def.create = function(settings, source)
end
source_def.activate = function(data)
end
source_def.show = function(data)
local scenesource = obs.obs_frontend_get_current_preview_scene()
if scenesource == nil then
return
end
local scene = obs.obs_scene_from_source(scenesource)
local scene_name = obs.obs_source_get_name(scenesource)
local scene_items = obs.obs_scene_enum_items(scene)
if scene_items ~= nil then
for _, scene_item in ipairs(scene_items) do
local source = obs.obs_sceneitem_get_source(scene_item)
local source_id = obs.obs_source_get_unversioned_id(source)
if source_id == "browser_source" then
local settings = obs.obs_source_get_settings(source)
local fps = obs.obs_data_get_int(settings, "fps")
if fps % 2 == 0 then
obs.obs_data_set_int(settings,"fps",fps + 1)
else
obs.obs_data_set_int(settings,"fps",fps - 1)
end
obs.obs_source_update(source, settings)
obs.obs_data_release(settings)
end
end
end
obs.sceneitem_list_release(scene_items)
obs.obs_source_release(scenesource)
obs.source_list_release(sources)
end
obs.obs_register_source(source_def);
++----------------------------------------------------------------------------------