A subtitle parser written in TypeScript
# yarn
yarn add subtitling
# npm
npm i --save subtitling
import fs from 'fs'
import { Subrip } from 'subtitling'
const file = fs.readFileSync('path/to/subtitle.srt')
const subtitle = new Subrip(file)
console.log(subtitle.getFirstCue())
Output
SubripCue {
cue: {
id: 1,
time: {
startTime: '00:00:23,046',
endTime: '00:00:27,546',
startTimeMS: 23046,
endTimeMS: 27546
},
text: [ 'This is the first line.', 'This is the second line.' ]
}
}
There are methods for cues, like: getCPS()
, getDuration()
and many others.
- Subrip (.srt)
- WebVTT (.vtt)