I'm trying to create video stream server and client with node fluent-ffmpeg, express and ejs. And a haven't solve this for a while. What I want to do is to play video beginning by certain time. The following codes make it with Safari browser on windows but with others it makes a loop of a few seconds or it says
video format not supported
server code (run.js) :
app.get('/video', function(req, res) {
//define file path,time to seek the beegining and set ffmpeg binary
var pathToMovie = '../videos/test.mp4';
var seektime = 100;
proc.setFfmpegPath(__dirname + "/ffmpeg/ffmpeg");
//encoding the video source
var proc = new ffmpeg({source: pathToMovie})
.seekInput(seektime)
.withVideoBitrate(1024)
.withVideoCodec('libx264')
.withAspect('16:9')
.withFps(24)
.withAudioBitrate('128k')
.withAudioCodec('libfaac')
.toFormat('mp4');
//pipe
.pipe(res, {end: true});
});
client code (index.ejs):
<html>
<head></head>
<body>
<video>
<source src="video/" type='video/mp4' />
</video>
</body>
</html>
Help please. I searched everywhere solution but I didn't find
Content-Type
header in the response withres.set('Content-Type', 'video/mp4');
. – Tom