0

What is the method to get the current recording duration?

I have the following script, but couldn't find the way to get current record time:

obs = obslua

function log_to_file(message)
    local file = io.open("obs_script_log.txt", "a")
    if file then
        file:write(os.date("[%Y-%m-%d %H:%M:%S] ") .. message .. "\n")
        file:close()
    end
end

function hotkey_handler(pressed)
    if pressed then
        if obs.obs_frontend_recording_active() then
            log_to_file("Recording time: " .. --[[ what goes here? ]])
        else
            log_to_file("Recording is not active")
        end
    end
end

function script_load(settings)
    obs.obs_hotkey_register_frontend(
            "obs_script.hotkey",
            "Time Taker",
            hotkey_handler
    )
    log_to_file("OBS script loaded")
end

function script_unload()
    obs.obs_hotkey_unregister("obs_script.hotkey")
    log_to_file("OBS script unloaded")
end
Tar
  • 8,529
  • 9
  • 56
  • 127

1 Answers1

0

This resource may help you finishing your code: https://obsproject.com/forum/resources/livetime.1213/

Stefan
  • 33
  • 8