我正在尝试使用node的fluent-ffmpeg,express和ejs创建视频流服务器和客户端。我已经尝试了一段时间,但还没有解决问题。
我的目标是按照特定时间开始播放视频。
以下代码可以在Windows上使用Safari浏览器实现,但在其他浏览器上会循环几秒钟或显示:
不支持的视频格式
服务器代码(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>
请帮忙。我已经到处搜索解决方案,但是没有找到。
res.set('Content-Type', 'video/mp4')
在响应中设置Content-Type
头。 - Svenskunganka