# srt2vtt

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

Latest version **1.3.1** (published 2016-02-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install srt2vtt
pnpm add srt2vtt
yarn add srt2vtt
bun add srt2vtt
```

## Health

**Score 5/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score; declining downloads.

## Facts

| | |
|---|---|
| Version | 1.3.1 |
| Published | 2016-02-25 |
| First published | 2014-08-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 31 |
| Author | Helge Skogly Holm |
| Maintainers | deestan |

## Links

- npm: https://www.npmjs.com/package/srt2vtt
- Repository: https://github.com/deestan/srt2vtt
- Homepage: https://github.com/deestan/srt2vtt#readme
- Issues: http://github.com/deestan/srt2vtt/issues
- npm.io page: https://npm.io/package/srt2vtt

## Dependencies (2)

- [utfx](https://npm.io/package/utfx.md) ~1.0.0
- [codepage](https://npm.io/package/codepage.md) ~1.4.0

## Recent versions

- 1.3.1 (latest) — 2016-02-25
- 1.3.0 — 2015-06-16
- 1.2.1 — 2015-06-15
- 1.2.0 — 2014-11-26
- 1.0.0 — 2014-08-12

## README

# srt2vtt

[![NPM](https://nodei.co/npm/srt2vtt.png)](https://nodei.co/npm/srt2vtt/)

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

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

## Quick Example

```javascript
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);
});
```

<a name="download" />
## Download

For [Node.js](http://nodejs.org/), use [npm](http://npmjs.org/):

    npm install srt2vtt

## Documentation

<a name="srt2vtt" />
### 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.

<a name="convert" />
### 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
```

---
_Source: https://npm.io/package/srt2vtt · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
