and_cesbo

Astra. Rotate inputs

May 12th, 2016
627
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.65 KB | None | 0 0
  1. -- Change input every 10 minutes
  2.  
  3. s = make_channel({
  4.     name = "CAM",
  5.     input = {
  6.         "rtsp://address-1",
  7.         "rtsp://address-2",
  8.     },
  9.     output = {
  10.         "udp://127.0.0.1:10000",
  11.     },
  12.     backup_type = "passive",
  13. })
  14.  
  15. timer({
  16.     interval = 10 * 60,
  17.     callback = function()
  18.         local input_id = s.active_input_id
  19.         local next_input_id = input_id + 1
  20.         if next_input_id > #s.input then next_input_id = 1 end
  21.         channel_kill_input(s, input_id)
  22.         log.info("[" .. s.config.name .. "] Destroy input #" .. input_id)
  23.         collectgarbage()
  24.         channel_init_input(s, next_input_id)
  25.     end,
  26. })
Advertisement
Add Comment
Please, Sign In to add comment