Skip to content

NodeJS module for converting captions from one format to another.

License

Notifications You must be signed in to change notification settings

jasonrojas/node-captions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

Synopsis

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.

Code Example

Conversion from SCC to SRT

const captions = require('node-captions'),
const 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), (err, result) =>  {
        if (err) { throw err; }
    });
});

Read SCC adjust by X and write out SRT with adjusted data

const captions = require('node-captions'),
const fs = require('fs');

captions.scc.read('path/to/scc/file.scc', {}, (err, data) => {
    if (err) { throw err; }
    captions.time.adjust('300', 'seconds', captions.scc.toJSON(data), (err, adjustedCaptions) => {
        if (err) { throw err; }
        fs.writeFile('path/to/srt/file.srt', captions.srt.generate(adjustedCaptions), (err, result) => {
            if (err) { throw err; }
        });
    });
});

Motivation

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.

Installation

npm install node-captions --save

API Reference

npm jsdoc

Tests

npm test

Contributors

Feel free to send pull requests in a branch.

License

node-captions' MIT License

About

NodeJS module for converting captions from one format to another.

Resources

License

Stars

Watchers

Forks

Packages

No packages published