0.1.9 • Published 2 years ago

subbox v0.1.9

Weekly downloads
1
License
ISC
Repository
github
Last release
2 years ago

Subbox

Composable subtitle parsing and transformations (including encoding/decoding) written in TypeScript

Installation

npm install --save data-future

Usage

import { StdContext, Pipeline, FileReader, DecoderPipeline, EncoderPipeline, FileWriter } from 'subbox';
import { ParserPipeline, OffsetPipeline, CompilerPipeline } from 'subbox';

const transformer = Pipeline.create(
    new FileReader(),
    new DecoderPipeline(),
    new ParserPipeline(),
    new OffsetPipeline( 2000 ) // Delay subtitles by 2 seconds
    // Convert the lines to text using the vtt format. If the format is omitted, the original one will be used
    new CompilerPipeline( 'vtt' ),
    new EncoderPipeline( 'utf8' )
);

const files = [ /** input file paths **/ ];

for ( let file of files ) {
    // Subbox Pipelines can be piped (similarly to NodeJS streams)
    // and return a new Pipeline that represents the composition
    const writer = transformer.pipe( new FileWriter( changeExtTo( file, '.vtt' ) ) );

    // We create a context (that holds the available formats, for example) and the input of the pipeline
    // The input of the pipeline is always the input of the first task in the pipeline,
    // which in this case for a FileReader is a string containing the file path to read from
    await writer.run( new StdContext(), file );
}
0.1.9

2 years ago

0.1.8

5 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago