node-captions is a simple module set to convert from one caption to another. Currently only supports (SCC | SRT) -> SRT | VTT | SAMI | TTML | SMPTE-TT.
var captions = require('node-captions'),
fs = require('fs');
captions.scc.read('path/to/scc/file.scc', {}, function (err, data) {
if (err) { throw err; }
fs.writeFile('path/to/srt/file.srt', captions.srt.generate(captions.scc.toJSON(data), function(err, result) {
if (err) { throw err; }
});
});
var captions = require('node-captions'),
fs = require('fs');
captions.scc.read('path/to/scc/file.scc', {}, function (err, data) {
if (err) { throw err; }
captions.time.adjust('300', 'seconds', captions.scc.toJSON(data), function (err, adjustedCaptions) {
if (err) { throw err; }
fs.writeFile('path/to/srt/file.srt', captions.srt.generate(adjustedCaptions), function(err, result) {
if (err) { throw err; }
});
});
});
This project was created so a nodeJS application can do stuff with caption files to support different players. Big thanks to pycaption for being the standard for quite some time and having the needed maps for the SCC conversion. Some of the features I added in the headers and such (check the config dir) may need to be tuned to your liking, the ones there work for me and seem to work for the players I have tested.
npm install node-captions
npm jsdoc
npm test
Feel free to send pull requests in a branch.