subtitle.js
Parse and manipulate SRT (SubRip) format.
Installation
npm install subtitle --save
Usage
var Subtitle = ; var captions = ; captions; console;
It's gonna return an array like this:
index: 1 start: '00:00:20,000' end: '00:00:24,400' text: 'Bla Bla Bla Bla' index: 2 start: '00:00:24,600' end: '00:00:27,800' text: 'Bla Bla Bla Bla'
You can also pass options to the getSubtitles()
method.
captions;
Here's the result:
index: 1 start: 20000 end: 24400 duration: 4400 text: 'Bla Bla Bla Bla' index: 2 start: 24600 end: 27800 duration: 3200 text: 'Bla Bla Bla Bla'
You can also add new captions.
var captions = ; captions; // You can use time in MS if you prefercaptions;
And what about resync your captions?
// Advance 1scaptions; // Delay 500mscaptions;
Then, you can stringfy your changes:
captions; // Returns a valid SRT
Tests
npm test
Roadmap
- Basic SRT parser
- Basic manipulation
- Stringfy
- Time conversion
- Duration property
- WebVTT support
- Browser support (including for Browserify)
- Better docs