Advanced output timer with segment control

Birb

New Member
Hi there,

I have a feature that would be extremely beneficial for managing storage spaces, especially when uploading video files on the cloud.

I was hoping if someone or the OBS team could make an advancement of the output timer that has a segment control. Basically you can have each segment last for a day and it automatically stops (just like the regular output timer does). Key difference being is that it automatically switches itself back on.

Thanks if anyone can add this in.
 

Aussie Andrew

New Member
I would love to see this as well, I was thinking we would just need a simple checkbox in the Output Timer window to automatically restart a new recording after the last recording times-out.

That way the length of each segment could be set with the "Stop recording after:" value.

Thanks in advance!
 

Aussie Andrew

New Member
I have no idea how to write scripts etc. but would it be possible to have a plugin that would stop a recording at a certain time of day and automatically start a new recording?

I really (REALLY) need something like this! I'm basically recording a stream 24/7 and at the moment I have to remember to stop/start it by hand at least once every day.

If anyone could even suggest how this might be done I'd be very grateful.

Andrew
 

AntoineDD

New Member
Do you know about AutoHotkey? It's basically a programming language to create macros and automate things. You can create a script that searches for an image on your screen and clicks on that part of the screen.

I haven't done exactly what you need, but autohotkey would be my best guess.
 

Aussie Andrew

New Member
Arrgghhh! OBS is driving me crazy!

I've setup windows scheduler to run a batch file. I've written the batch file to run any one of half-a-dozen different scripts I've tried so far ranging from VB script to AutoHotkey and nothing works.

I've set the hotkeys in OBS to stop and start recording and I've confirmed that they work from the physical keyboard (and I've tried many different combinations of hotkeys), but nothing I do will make OBS respond to a 'virtual' hotkey press. I have confirmed these virtual hotkeys do work with other programs though.

I've researched online and there are many other questions about this same behavior with OBS and I've tried every suggestion offered (running OBS as administrator, running in foreground, running in background, changing the "Hotkey Focus Behavior" in Settings, adding a 'key-down' delay into the script, spamming it with multiple key presses, etc.) and no matter what I do I just can't get OBS to do anything upon a virtual hotkey activation.

I've wasted my entire Sunday trying to get this to work... I give up!

My only hope now is if the developers can add an auto-restart feature to the Output Timer window?
 

Aussie Andrew

New Member
My only hope now is if the developers can add an auto-restart feature to the Output Timer window?

Apologies if I sound impatient, is there any way to know if the developers are reading this and possibly considering adding this feature?

If not, is there someone I can contact to ask for it to be added?
 

Aussie Andrew

New Member
Going on ten months later and I'm still asking basically the same question, how can I talk to an actual developer about this?

There's been several program updates since I last posted and every time one arrives I scan the list of features being added while crossing my fingers and holding my breath, but to no avail.

I really (REALLY) need this feature! I quite often record 24/7 but I have to remember to stop/start the recordings manually so the file sizes remain even somewhat manageable.

Yes, I know I can automatically stop recording after a certain amount of time, I just need the program to (optionally) automatically restart recording again once that happens.

It's the only flaw in an otherwise perfect (for me) program!

Please, please, pretty please, with sugar on top!
 

DCStrato

Member
Try saving this as a .lua file script and loading it. It will restart the recording a specified number of seconds after it stops unless disabled.

obs = obslua gs = nil disable = false delay = 1 function script_properties() local props = obs.obs_properties_create() obs.obs_properties_add_bool(props, "disable", "Disable Restart") obs.obs_properties_add_int(props,"delay", "Restart Delay in Seconds:",1,60,1) return props end function script_description() return "Restart recording if it stops. (DCStrato)" end function restartRecording() obs.timer_remove(restartRecording) obs.obs_frontend_recording_start() end function on_event(event) if not disable and event == obs.OBS_FRONTEND_EVENT_RECORDING_STOPPED then obs.timer_add(restartRecording, delay*1000) end end function script_update(settings) disable = obs.obs_data_get_bool(settings,"disable") delay = obs.obs_data_get_int(settings,"delay") end function script_defaults(settings) obs.obs_data_set_default_bool(settings, "disable", true) obs.obs_data_set_default_int(settings, "delay", "1") end function script_load(settings) gs = settings disable = obs.obs_data_get_bool(settings,"disable") delay = obs.obs_data_get_int(settings,"delay") obs.obs_frontend_add_event_callback(on_event) end
 

DCStrato

Member
Aussie,

I tried this script with the OBS Output Timer (Enable recording timer every time was checked) and set the time to 10 seconds. With the restart script enabled using a 1 sec restart delay, it created six 10 second videos in one minute. Was this the result you were expecting?

DC
 

DCStrato

Member
Here is a version with three hotkeys to enable, disable, or toggle the restart script.

obs = obslua gs = nil disable = false delay = 1 hotkey_enable_id = obs.OBS_INVALID_HOTKEY_ID hotkey_disable_id = obs.OBS_INVALID_HOTKEY_ID hotkey_toggle_id = obs.OBS_INVALID_HOTKEY_ID function script_properties() local pp = obs.obs_properties_create() obs.obs_properties_add_bool(pp, "disable", "Disable Restart") obs.obs_properties_add_int(pp,"delay", "Restart Delay in Seconds:",1,60,1) return pp end function script_description() return "Restart recording if it stops. (DCStrato)" end function restartRecording() obs.timer_remove(restartRecording) obs.obs_frontend_recording_start() end function on_event(event) if not disable and event == obs.OBS_FRONTEND_EVENT_RECORDING_STOPPED then obs.timer_add(restartRecording, delay*1000) end end function script_update(settings) disable = obs.obs_data_get_bool(settings,"disable") delay = obs.obs_data_get_int(settings,"delay") end function script_defaults(settings) obs.obs_data_set_default_bool(settings, "disable", true) obs.obs_data_set_default_int(settings, "delay", "1") end function enableRestart(pressed) if not pressed then return end disable = false obs.obs_data_set_bool(gs, "disable", false) end function disableRestart(pressed) if not pressed then return end disable = true obs.obs_data_set_bool(gs, "disable", true) end function toggleRestart(pressed) if not pressed then return end disable = not disable obs.obs_data_set_bool(gs, "disable", disable) end function script_load(settings) gs = settings disable = obs.obs_data_get_bool(settings,"disable") delay = obs.obs_data_get_int(settings,"delay") obs.obs_frontend_add_event_callback(on_event) hotkey_enable_id = obs.obs_hotkey_register_frontend("enable_record_restart", "Enable Record Restart",enableRestart) local hotkey_save_array = obs.obs_data_get_array(settings, "enable_record_restart") obs.obs_hotkey_load(hotkey_enable_id, hotkey_save_array) obs.obs_data_array_release(hotkey_save_array) hotkey_disable_id = obs.obs_hotkey_register_frontend("disable_record_restart", "Disable Record Restart", disableRestart) hotkey_save_array = obs.obs_data_get_array(settings, "disable_record_restart") obs.obs_hotkey_load(hotkey_disable_id, hotkey_save_array) obs.obs_data_array_release(hotkey_save_array) hotkey_toggle_id = obs.obs_hotkey_register_frontend("toggle_record_restart", "Toggle Record Restart", toggleRestart) hotkey_save_array = obs.obs_data_get_array(settings, "toggle_record_restart") obs.obs_hotkey_load(hotkey_toggle_id, hotkey_save_array) obs.obs_data_array_release(hotkey_save_array) end function script_save(settings) local hotkey_save_array = obs.obs_hotkey_save(hotkey_enable_id) obs.obs_data_set_array(settings, "enable_record_restart", hotkey_save_array) obs.obs_data_array_release(hotkey_save_array) hotkey_save_array = obs.obs_hotkey_save(hotkey_disable_id) obs.obs_data_set_array(settings, "disable_record_restart", hotkey_save_array) obs.obs_data_array_release(hotkey_save_array) hotkey_save_array = obs.obs_hotkey_save(hotkey_toggle_id) obs.obs_data_set_array(settings, "toggle_record_restart", hotkey_save_array) obs.obs_data_array_release(hotkey_save_array) end
 

DCStrato

Member
Reading your use case again I think this version that stops then starts recording once during a specified hour/min is a better fit.

DC
Lua:
--  Recorder Restart  (DcStrato)

obs           = obslua
hour            = 0
minute            = 0
restarted       = false
UTCTime       = 0
enabled       = false

function restartRecording()
    obs.timer_remove(restartRecording)
    obs.obs_frontend_recording_start()
end

function timer_callback()
    local time = os.date("*t")
    if enabled and time.hour == hour and time.min == minute and time.sec < 2 and not restarted then
        restarted = true
        obs.obs_frontend_recording_stop()
        obs.timer_add(restartRecording, 1000)  -- restart recording in 1 sec(required delay)
    end
    if  time.sec > 2 and restarted then
        restarted = false -- reset for next 24 hour restart
    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 Restart Recording (24hr)",0,60,1)
    obs.obs_properties_add_int(pp, "minute", "Minute to Restart Recording",0,60,1)
    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")   
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)
end

function script_load(settings)
    obs.timer_add(timer_callback, 1000)   
end
 

Attachments

  • RecordRestarter.zip
    819 bytes · Views: 13

Aussie Andrew

New Member
Thanks DC!

I'll have a go at implementing that tomorrow (I've had too much long weekend 'cheer' to try now). I was looking at 6 hour recording lengths, so restarting 4 times a day.

I'll let you know how it goes.

Thanks again,
Andrew
 

DCStrato

Member
Okay.. I thought you only wanted once a day. Here is an option that adds for restarting have the initially specified hour/min, once very 24,12,8,6,4,2,1,30min, 15min, 5min, or 1 minute.

DC
 

Attachments

  • RecordRestarter.zip
    1 KB · Views: 14

Aussie Andrew

New Member
I think there's something hinky with that last one (I'm calling it Version 4), I set the "Repeat Options" to "Every Minute" and it starts recording at the correct time, then stops after 1 minute (as it should), but it waits for 1 minute to restart another recording (not for 1 second as specified earlier).

Anyhow, I actually went back to Version 1, it seems to work best for me. I just have to remember to disable the plugin to stop recording but that's okay.

Two questions:

1) Is it possible to disable a script (V1 in this case) if the "Stop Recording" button on the main GUI is pressed? (So that the "Stop Recording" button does actually stop all recordings.)

2) Can the restart delay be less than 1 whole second? Would half a second be enough, for example?

Thanks again!
Andrew
 

DCStrato

Member
I could not get it to work with less than 1 second between when it was told to stop recording and when it was told to restart.

DC
 

DCStrato

Member
What is wonky is the timing for file operations in OBS. Stopping requires closing the files and waiting on the OS to finish before opening a new file for recording. That time is what is causing your 1 minute restart. It fails to restart and does not try again for 1 minute. Here is a version that uses cascading timers to check every 200ms for the recording to no longer be active and then every 100ms for it to become active before waiting on the next restart interval. Unfortunately it seems that even trying to restart immediately after OBS reports the recording stopped also does not work. That 200ms seems to still be required. This restarts in about 600ms on my computer.

DC

Lua:
--  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
 
Top