subtitle-transform
Transform various subtitle formats
Last updated 5 months ago by will118 .
ISC · Original npm · Tarball · package.json
$ cnpm install subtitle-transform 
SYNC missed versions from official npm registry.

subtitle-transform

Parses various subtitle formats (VTT/TTML/TTAF) into a type called SubtitleData.

There are various generators that take SubtitleData and emit text (SRT/ASS).

Usage

CLI

npm i -g subtitle-transform

With a file:

subtitle-transform --input=ep1.vtt --inputFormat=vtt --outputFormat=ass

or pipe:

cat ep1.vtt | subtitle-transform --inputFormat=vtt --outputFormat=ass

You can also pass --timestampSkew=-2.1 to adjust timestamps.

Library

npm i -S subtitle-transform
import { parseTT, generateASS } from 'subtitle-transform';

const inputContents = `<?xml version="1.0" encoding="utf-8"?>
  <tt xmlns="http://www.w3.org/2006/10/ttaf1" xml:lang="en" xmlns:ttm="http://www.w3.org/2006/10/ttaf1#metadata">
  <head>
    <!--Created on 1/11/2011 at 00:30:00-->
    <metadata>
      <ttm:title>
        Yellow eggs and potatoes
      </ttm:title>
      <ttm:copyright>
        Paul
      </ttm:copyright>
    </metadata>
    <styling>
      <style id="s0" tts:backgroundColor="black" tts:fontStyle="normal" tts:fontSize="16" tts:fontFamily="sansSerif" tts:color="white" />
      <style id="s1" style="s0" tts:color="yellow" />
    </styling>
  </head>
  <body tts:textAlign="center" style="s0">
    <div>
      <p begin="00:01:57.32" id="p0" end="00:01:58.36">First caption!</p>
      <p begin="00:02:11.44" id="p3" end="00:02:16.44">A what<br />oh</p>
      <p style="s1" begin="00:03:01.88" id="p14" end="00:03:04.64"><span tts:color="white">This line is white<br /></span>This line is something else</p>
    </div>
  </body>
</tt>`;

const subtitleData = parseTT(inputContents, {});
const output = generateASS(subtitleData, { enableStyles: true });

console.log(output);

Progress

Parsing

  • [x] VTT parsing
    • [x] Style support
  • [x] TT parsing
    • [x] Style support
  • [ ] ASS parsing
    • [ ] Style support

Generating

  • [x] SRT output
    • [x] Style support
  • [x] ASS output
    • [x] Style support
    • [ ] Region support
  • [ ] VTT output
    • [ ] Style support
    • [ ] Region support

Resources used:

Current Tags

  • 1.0.2                                ...           latest (5 months ago)

4 Versions

  • 1.0.2                                ...           5 months ago
  • 1.0.1                                ...           5 months ago
  • 1.0.0                                ...           5 months ago
  • 0.0.1                                ...           7 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 4
Dependencies (4)
Dev Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |