Skip to content

Latest commit

 

History

History
48 lines (34 loc) · 1.39 KB

README.md

File metadata and controls

48 lines (34 loc) · 1.39 KB

srt-stream-parser NPM version Build Status Dependency Status

Let's you stream decode srt files - gives you back a json string with the id, start, end and the dialogs. The start and end time are in milliseconds.

Installation

npm install srt-stream-parser --save-dev

Usage

var srt = require('srt-stream-parser');
var srt_file = fs.createReadStream('./path/to/your/file.srt');

var subutitles = [];
file.pipe(srt()).on('data', function(data) {
    var data = JSON.parse(data);
    subutitles.push(data);
}).on('end', function () {
    console.log('All done, parsed: ' + subutitles.length + ' subtitles');
});

Where in the single data entry concists of:

 {
     "id": "1337",
     "start": 56880000,
     "end": 57060000,
     "dialogs": ["A world without rules and controls,", "without borders or boundaries."]
 }

MIT License