source_path = "/home/iptv/xxx" output_addr = "192.168.0.11" output_port = 8806 playlist = {} current_item = 0 for d in utils.readdir(source_path) do table.insert(playlist, d) end channel_data = {} channel_data.input = nil channel_data.transmit = transmit() function on_http_read(self, client, request) if not request then return nil end local client_data = self:data(client) self:send(client, channel_data.transmit:stream()) end channel_data.output = http_server({ addr = output_addr, port = output_port, route = { { "/xxx", http_upstream({ callback = on_http_read, }) }, }, }) function play_item() current_item = current_item + 1 if current_item > #playlist then log.info("End of playlist") astra.exit() end log.debug("Play: " .. playlist[current_item]) if channel_data.input then kill_input(channel_data.input) channel_data.input = nil end local source_file = playlist[current_item] local channel_conf = { name = source_file, format = "file", filename = source_path .. "/" .. source_file, on_error = function() play_item() end, map = { { "pmt", "100" }, { "video", "101" }, { "audio", "102" }, }, set_pnr = 100, } channel_data.input = init_input(channel_conf) channel_data.transmit:set_upstream(channel_data.input.tail:stream()) end play_item()