Giter Site home page Giter Site logo

srt2vtt's Introduction

@naholyr's fork:

  • includes fixed codepage issue
  • install with @naholyr/srt2vtt

srt2vtt

NPM

Encoding-aware .srt (SubRip Text) to .vtt (WebVTT) converter.

Handles CP1252 and UTF8/16/16LE/32/32LE.

Quick Example

var fs = require('fs');
var srt2vtt = require('srt2vtt');

var srtData = fs.readFileSync('captions.srt');
srt2vtt(srtData, function(err, vttData) {
  if (err) throw new Error(err);
  fs.writeFileSync('captions.vtt', vttData);
});
## Download

For Node.js, use npm:

npm install srt2vtt

Documentation

### srt2vtt (srtBuffer, callback) ### srt2vtt (srtBuffer, defaultCodepageOverride, callback)

It assumes input srtBuffer has the default CP1252 encoding, unless a UTF8, UTF16, UTF16LE, UTF32, or UTF32LE BOM is found at the start.

If the defaultCodepageOverride is given, that codepage is used instead of CP1252.

Callback is assumed to be a function(error, vttBuffer).

Arguments

  • srtBuffer - Buffer containing the .srt file.
  • defaultCodepageOverride (optional) - int number of codepage to use instead of CP1252 when no UTF BOM is found. This must be a numeric value, so e.g. give 1256 for codepage CP1256 (Arabic).
  • callback - function(error, vttBuffer), in which error will be null if the conversion were successful, or an error message if not successful. vttBuffer is a UTF8-encoded buffer containing the converted WEBVTT file data.
### bin/convert.js

A command-line utility that expects a .srt file in stdin, will transform it to .vtt, and send it to stdout.

Example

$ node bin/convert.js < mighty_jack.srt > mighty_jack.vtt

srt2vtt's People

Contributors

deestan avatar naholyr avatar xat avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.