-- Recorder Restart (DcStrato)
obs = obslua
enabled = false
options = 1
function waitToStart()
if obs.obs_frontend_recording_active() then
obs.timer_remove(waitToStart)
obs.timer_add(timer_callback,1000)
end
end
function waitToStop()
if not obs.obs_frontend_recording_active() then
obs.timer_remove(waitToStop)
obs.obs_frontend_recording_start()
obs.timer_add(waitToStart, 100)
end
end
function timer_callback()
local time = os.date("*t")
local now = os.time()
local target = os.time{year=time.year, month=time.month, day=time.day, hour = hour, min=minute, sec=0}
if (now-target)%(86400/options) == 0 and enabled and obs.obs_frontend_recording_active() then
obs.timer_remove(timer_callback)
obs.obs_frontend_recording_stop()
obs.timer_add(waitToStop,200) --check restart every 200ms Increase if restart does NOT happen
end
end
function script_properties()
local pp = obs.obs_properties_create()
obs.obs_properties_add_bool(pp, "enable", "Enable Restart")
obs.obs_properties_add_int(pp, "hour", "Hour to Start Recording (24hr)",0,60,1)
obs.obs_properties_add_int(pp, "minute", "Minute to Start Recording",0,60,1)
local opp = obs.obs_properties_add_list(pp,"options","Repeat Options",obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_INT)
obs.obs_property_list_add_int(opp, "Every 24hrs", 1)
obs.obs_property_list_add_int(opp, "Every 12hrs", 2)
obs.obs_property_list_add_int(opp, "Every 8hrs", 3)
obs.obs_property_list_add_int(opp, "Every 6hrs", 4)
obs.obs_property_list_add_int(opp, "Every 4hrs", 6)
obs.obs_property_list_add_int(opp, "Every 2hrs", 12)
obs.obs_property_list_add_int(opp, "Every hour", 24)
obs.obs_property_list_add_int(opp, "Every 30 min", 48)
obs.obs_property_list_add_int(opp, "Every 15 min", 96)
obs.obs_property_list_add_int(opp, "Every 5 min", 160)
obs.obs_property_list_add_int(opp, "Every minute", 1440)
obs.obs_property_list_add_int(opp, "15 sec", 5760)
return pp
end
function script_description()
return "Restart recording at specific hour/min. (DCStrato)"
end
function script_update(settings)
enabled = obs.obs_data_get_bool(settings,"enable")
hour = obs.obs_data_get_int(settings,"hour")
minute = obs.obs_data_get_int(settings,"minute")
options = obs.obs_data_get_int(settings,"options")
end
function script_defaults(settings)
obs.obs_data_set_default_bool(settings, "enable", false)
obs.obs_data_set_default_int(settings, "hour", 0)
obs.obs_data_set_default_int(settings, "min", 0)
obs.obs_data_set_default_int(settings, "options",1)
end
function script_load(settings)
obs.timer_add(timer_callback, 1000)
end