1.0.1 • Published 4 years ago

subtitling v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Subtitling

PRs Welcome Version

A subtitle parser written in TypeScript

# yarn
yarn add subtitling

# npm
npm i --save subtitling

Subrip

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.

Supported formats

  • Subrip (.srt)
  • WebVTT (.vtt)