I i using ffmpeg and nodejs and i im trying to stream hls stream...but i im unable to do that...does anyone have code to do that? i have successfully stream only one stream using this code:
streamRoutes.get('/stream', function(req, res) {
// Write header
res.writeHead(200, { 'Content-Type': 'video/H264'
}); /*var command = ffmpeg.setFfmpegPath(process.env.PWD + "/node_modules/ffmpeg-static/bin/linux/x64/ffmpeg");*/ // Start ffmpeg
var command = child_process.spawn(process.env.PWD + "/node_modules/ffmpeg-static/bin/linux/x64/ffmpeg", [ "-y", /* OVERWRITE - output file */ "-hide_banner", /* BANNER - hide */ "-loglevel", "quiet", /* LOG - hide */ "-i", "http://streamurl/live/1.ts", /* STREAM - source */ "-vcodec", "copy", "-reset_timestamps", "1", "-movflags", "frag_keyframe+empty_moov", "-f", "mp4", "-"
], { detached: false }); // Pipe the video output to the client response
command.stdout.pipe(res); // Kill the subprocesses when client disconnects
res.on("close", function(){ command.kill();
})
});
But i would like to define output stream file name so that it will be accessable using this link:
http://myserverip:port/1.ts
And so on (each stream will be have its own name)....i see that ffmpeg command have parameter:
-f http://127.0.0.1:8081/1.ts
but i im not sure what code i need to write in nodejs to get this link working for example if my server ip is: 86.69.86.61 then when i enter link i vlc player: http://86.69.86.61:8081/1.ts it need to start playing video.
Examples using ffmpeg in nodejs i see only using stdout and not defined ffmpeg output using -f parameter.
UPDATED QUESTION:
I would like to make restreamer using ffmpeg to enter in ffmpeg this links:
http://169.56.89.65:8001/1.ts
http://58.69.89.78:5026/2.ts
http://63.69.89.78:4012/3.ts
and suppose that my server ip is: 86.69.86.61 i would like when i enter in vlc link:
http://86.69.86.61:8081/1.ts
http://86.69.86.61:8081/2.ts
http://86.69.86.61:8081/3.ts
i start restreaming using ffmpeg manually but i can't get above url working...how to do that in node js? do i need to route 1.ts 2.ts 3.ts to port or?
-- http://86.69.86.61:8081/1.ts