I'm trying to use the module node-fluent-ffmpeg (https://github.com/schaermu/node-fluent-ffmpeg) to transcode and stream a videofile. Since I'm on a Windows machine, I first downloaded FFMpeg from the official site (http://ffmpeg.zeranoe.com/builds/). Then I extracted the files in the folder C:/FFmpeg and added the path to the system path (to the bin folder to be precise). I checked if FFmpeg worked by typing in the command prompt: ffmpeg -version. And it gave a successful response.
After that I went ahead and copied/altered the following code from the module (https://github.com/schaermu/node-fluent-ffmpeg/blob/master/examples/express-stream.js):
app.get('/video/:filename', function(req, res) {
res.contentType('avi');
console.log('Setting up stream')
var stream = 'c:/temp/' + req.params.filename
var proc = new ffmpeg({ source: configfileResults.moviepath + req.params.filename, nolog: true, timeout: 120, })
.usingPreset('divx')
.withAspect('4:3')
.withSize('640x480')
.writeToStream(res, function(retcode, error){
if (!error){
console.log('file has been converted succesfully',retcode);
}else{
console.log('file conversion error',error);
}
});
});
I've properly setup the client with flowplayer and tried to get it running but nothing happens. I checked the console and it said:
file conversion error timeout
After that I increased the timeout but somehow, It only starts when I reload the page. But of course immediately stops because of the page reload. Do I need to make a separate node server just for the transcoding of files? Or is there some sort of event I need to trigger?
I'm probably missing something simple but I can't seem to get it to work. Hopefully someone can point out what I've missed.
Thanks
I've fixed it by using videoJs instead of Flowplayer. The way flowplayer was launched did not work properly in my case. So I init the stream and then initialize videojs to show the stream. Which works great.