【发布时间】:2021-02-24 13:42:37
【问题描述】:
我正在使用 Node/Express 将 mp4 视频发送到我使用 angular 的前端。视频发送顺利,一切正常。现在,我想发送包含字幕的 VTT 文件以及 mp4。我不知道该怎么做?我试过搜索,但找不到任何帮助。这是我的代码:
节点/快递
router.get('/playVideo', (req, res) => {
const path = "videos/testVideo.mp4";
const pathSubtitle = "videos/testsub.vtt";
const stat = fs.statSync(path);
const fileSize = stat.size;
const head = {
'Content-Length': fileSize,
'Accept-Ranges' : 'bytes',
'Content-Type': 'video/mp4'
}
res.writeHead(200, head);
fs.createReadStream(path).pipe(res);
});
角度
<div class="container-fluid">
<br>
<div class="jumbotron-fluid">
<video id = "videoPlayer" controls preload = "metadata" style = "width:
65%; position: fixed; border: 2px solid #7c2c6c;">
<source src="http://localhost:3000/playVideo" autoplay type =
"video/mp4">
</video>
</div>
</div>
如何在视频回复中附加字幕文件?或者,链接到任何其他详细解释的文档?
【问题讨论】:
-
在角度部分你使用视频标签吗?前端部分长什么样子?
-
@ste-xx,我已经编辑了代码。
-
只需为字幕创建一个类似的入口点并将