说,我有一个vtt文件,我想在nodejs环境中获取所有提示及其相关属性,例如startTime,endTime等。
我搜索了所有可以提出的关键字,例如通过javascript'解析vtt文件,但结果全部都是mozilla/vtt.js。但是我不需要与浏览器/窗口交互,它只是一个静态的vtt文件,我需要通过JavaScript提取数据。
有人可以给我一些提示吗?谢谢!
示例vtt内容:
WEBVTT FILE
1
00:00:03.500 --> 00:00:05.000 D:vertical A:start
Everyone wants the most from life
2
00:00:06.000 --> 00:00:09.000 A:start
Like internet experiences that are rich <b>and</b> entertaining
3
00:00:11.000 --> 00:00:14.000 A:end
Phone conversations where people truly <c.highlight>connect</c>
4
00:00:14.500 --> 00:00:18.000
Your favourite TV programmes ready to watch at the touch of a button
5
00:00:19.000 --> 00:00:24.000
Which is why we are bringing TV, internet and phone together in <c.highlight>one</c> super package
6
00:00:24.500 --> 00:00:26.000
<c.highlight>One</c> simple way to get everything
7
00:00:26.500 --> 00:00:27.500 L:12%
UPC
8
00:00:28.000 --> 00:00:30.000 L:75%
Simply for <u>everyone</u>
答案 0 :(得分:2)
您可以使用npm软件包 node-webvtt
npm install node-webvtt
import * as webvtt from "node-webvtt" //if you are using typescript
const parsed = webvtt.parse("Your text")
这将为您提供以下内容:
答案 1 :(得分:0)
这一个帮助了我https://www.npmjs.com/package/vtt-to-json 它可以将vtt解析为json,我可以使用它来获取所有属性/值。