subtitling

A subtitle parser

Usage no npm install needed!

<script type="module">
  import subtitling from 'https://cdn.skypack.dev/subtitling';
</script>

README

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)