I'm trying to create a server in node.js that receives RTMP packets and converts them in HLS packets, then it sends back the packets. I'm doing this to create a livestream service compatible with every dispositive from the moment that iOS doesn't support RTMP. This is my code, but i'm stuck in what i should put into the callback. Sorry for the mess but I'm not a JS programmer and this are my first steps into a JS project. Thanks in advance! My stream client will be OBS.
import { Server } from 'https';
var hls = require('hls-server')(8000);
var ffmpeg = require('fluent-ffmpeg')
// host, port and path to the RTMP stream
var host = 'localhost'
var port = '8000'
var path = '/live/test'
clients = [];
function callback(){
}
fmpeg('rtmp://'+host+':'+port+path, { timeout: 432000 }).addOptions([
'-c:v libx264',
'-c:a aac',
'-ac 1',
'-strict -2',
'-crf 18',
'-profile:v baseline',
'-maxrate 400k',
'-bufsize 1835k',
'-pix_fmt yuv420p',
'-hls_time 10',
'-hls_list_size 6',
'-hls_wrap 10',
'-start_number 1'
]).output('public/videos/output.m3u8').on('end', callback).run()