and_cesbo icon

Astra Simple DVR

and_cesbo | PRO | 11/08/18 06:35:00 AM UTC | 0 ⭐ | 927 👁️ | Never ⏰ | []
Lua |

1.14 KB

|

None

|

0 👍

/

0 👎

-- Simple DVR for Astra-4 and Astra-5
-- Usage:
-- - Download Astra: http://cesbo.com/download/
-- - Save this script into: dvr.lua
-- - Launch: astra dvr.lua "INPUT"
 
local channel_instance = nil
local input_addr = ""
local current_hour = -1
 
function stop()
    if channel_instance then
        kill_channel(channel_instance)
        channel_instance = nil
    end
end
 
function start()
    local current_date = os.date("*t")
    if current_hour == current_date.hour then
        return nil
    end
    current_hour = current_date.hour
 
    if channel_instance then
        stop()
    end
 
    channel_instance = make_channel({
        name = "DVR",
        input = { input_addr },
        output = { "file://" .. os.date("%H-%d-%m-%Y") .. ".ts" },
    })
end
 
options = {
    ["*"] = function(idx)
        input_addr = argv[idx]
        return 0
    end,
}
 
function main()
    log.info("Starting Astra " .. astra.version)
    if not input_addr then
        log.error("Usage: astra dvr.lua INPUT")
        astra.exit()
    end
    start()
    timer({
        interval = 10,
        callback = start,
    })
end

Comments