Advertisement
and_cesbo

Astra Simple DVR

Nov 8th, 2018
445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.14 KB | None | 0 0
  1. -- Simple DVR for Astra-4 and Astra-5
  2. -- Usage:
  3. -- - Download Astra: http://cesbo.com/download/
  4. -- - Save this script into: dvr.lua
  5. -- - Launch: astra dvr.lua "INPUT"
  6.  
  7. local channel_instance = nil
  8. local input_addr = ""
  9. local current_hour = -1
  10.  
  11. function stop()
  12.     if channel_instance then
  13.         kill_channel(channel_instance)
  14.         channel_instance = nil
  15.     end
  16. end
  17.  
  18. function start()
  19.     local current_date = os.date("*t")
  20.     if current_hour == current_date.hour then
  21.         return nil
  22.     end
  23.     current_hour = current_date.hour
  24.  
  25.     if channel_instance then
  26.         stop()
  27.     end
  28.  
  29.     channel_instance = make_channel({
  30.         name = "DVR",
  31.         input = { input_addr },
  32.         output = { "file://" .. os.date("%H-%d-%m-%Y") .. ".ts" },
  33.     })
  34. end
  35.  
  36. options = {
  37.     ["*"] = function(idx)
  38.         input_addr = argv[idx]
  39.         return 0
  40.     end,
  41. }
  42.  
  43. function main()
  44.     log.info("Starting Astra " .. astra.version)
  45.     if not input_addr then
  46.         log.error("Usage: astra dvr.lua INPUT")
  47.         astra.exit()
  48.     end
  49.     start()
  50.     timer({
  51.         interval = 10,
  52.         callback = start,
  53.     })
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement