Need help with scripting (Python/Lua) or Auto restart replay buffer after save

azzyfive

New Member
Lua:
obs = obslua
local clock = os.clock
function sleep(n)-- seconds
local t0 = clock()
while clock() - t0 <= n do end
end
function script_description()
return "auto restart replay buffer"
end

function refresh_button()
print('hello')
print('world')
sleep(3)
return nil
end
function script_properties()
local props = obs.obs_properties_create()
local button = obs.obs_properties_add_button(props, "button", "Refresh", refresh_button)
return props
end
Python:
import obspython as obs
import time
import sys
test_hotkey = obs.OBS_INVALID_HOTKEY_ID
def refresh_pressed(props, prop):
print("hello")
time.sleep(4)
print("world")
# obs.obs_frontend_replay_buffer_start()

def script_properties():
props = obs.obs_properties_create()
obs.obs_properties_add_button(props, "button", "Refresh", refresh_pressed)
return props
def script_description():
return "stop replay buffer on save and restart it after some time."

Okay, so I am trying to make a script where upon pressing the SAVE REPLAY hotkey the script waits for a few seconds then stops the replay and starts it again after a few seconds. To achieve that I am first trying to make the sleep command work but for some reason, it is giving priority to the sleep command regardless of the order it is in ( in python and Lua). I am new to scripting so I'm just making use of docs and everything I can find. If the script to this already exists or if any one of you is kind enough to script it for me that would be really nice of you. Also, do explain to me why the sleep command is doing that. I figured it's only when I'm using it in obs, otherwise, the sleep command works as intended. The drawback to this is that obs.obs_frontend_replay_buffer_start() obs.obs_frontend_replay_buffer_stop() both commands are run at the same time by OBS so only one command really works ( if replay buffer is active then it stops and vice versa ) it doesn't really restart which it should do
 
Top