stream节点fluent-ffmpegstreammp4video

我正在尝试创buildvideostream服务器和客户端节点fluent-ffmpegexpressejs 。 而且有一段时间没有解决这个问题。 我想要做的是从一定时间开始播放video。 下面的代码使用Safari浏览器在Windows上,但与其他人做了几秒钟的循环或说

不支持video格式

服务器代码(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}); }); 

客户端代码(index.ejs):

 <html> <head></head> <body> <video> <source src="video/" type='video/mp4' /> </video> </body> </html> 

请帮助。 我到处search解决scheme,但我没有find

我相信,为了在mp4或mp3中search,您需要让浏览器知道该内容的长度。 在你打电话给ffmpeg之前,尝试插入这个快速简介。 这应该获得video文件的大小,并且可以在传输数据之前相应地在响应中设置标题。

在ffmpeg调用之前插入

 var fs = require('fs'); var stat = fs.statSync(pathToMovie); res.writeHead(200, { 'Content-Type': 'video/mp4', 'Content-Length': stat.size });