Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Script for Astra 5.62 and newer
- -- Script implements API method to switch between inputs
- -- Installation: Save script input /etc/astra/mod/change-input.lua
- -- Usage:
- -- 1. Create new stream
- -- 2. In the stream settings set "Backup Type" to "Passive Backup"
- -- 3. Save stream and check stream ID, you may find in the stream settings or in the URL. For example : http://server.local:8000/#/stream/server.local:8000/a018 "a018" - this is stream ID
- -- 4. Call API method: curl -X POST -d "{\"cmd\":\"change-input\",\"id\":\"a018\"}" http://admin:password@server.local:8000/control/
- -- server.local - this is server address
- -- 8000 - port to the Astra web interface
- -- a018 - stream ID
- control_api["change-input"] = function(server, client, data)
- local channel_data = channel_list_ID[data.id]
- if not channel_data then
- control_api_response(server, client, { ["change-input"] = "er" })
- return nil
- end
- local input_id = channel_data.active_input_id
- local next_input_id = input_id + 1
- if next_input_id > #channel_data.input then
- next_input_id = 1
- end
- channel_kill_input(channel_data, input_id)
- log.debug("[" .. channel_data.config.name .. "] Destroy input #" .. input_id)
- channel_data.active_input_id = -1
- collectgarbage()
- channel_init_input(channel_data, next_input_id)
- control_api_response(server, client, { ["change-input"] = "ok" })
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement