Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/weizhenye/ass-compiler
Parses and compiles ASS subtitle format to easy-to-use data structure
https://github.com/weizhenye/ass-compiler
ass compiler parser ssa subtitle
Last synced: 2 days ago
JSON representation
Parses and compiles ASS subtitle format to easy-to-use data structure
- Host: GitHub
- URL: https://github.com/weizhenye/ass-compiler
- Owner: weizhenye
- License: mit
- Created: 2017-05-29T20:51:47.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-08-11T16:15:55.000Z (3 months ago)
- Last Synced: 2024-10-13T03:10:49.016Z (about 1 month ago)
- Topics: ass, compiler, parser, ssa, subtitle
- Language: JavaScript
- Homepage: https://ass.js.org/ass-compiler/
- Size: 235 KB
- Stars: 107
- Watchers: 5
- Forks: 18
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ass-compiler
[![GitHub Action](https://img.shields.io/github/actions/workflow/status/weizhenye/ass-compiler/ci.yml?logo=github)](https://github.com/weizhenye/ass-compiler/actions)
[![Codecov](https://img.shields.io/codecov/c/gh/weizhenye/ass-compiler?logo=codecov)](https://codecov.io/gh/weizhenye/ass-compiler)
[![License](https://img.shields.io/npm/l/ass-compiler)](https://github.com/weizhenye/ass-compiler/blob/master/LICENSE)
[![NPM Version](https://img.shields.io/npm/v/ass-compiler?logo=npm)](https://www.npmjs.com/package/ass-compiler)
[![jsDelivr](https://img.shields.io/jsdelivr/npm/hm/ass-compiler?logo=jsdelivr)](https://www.jsdelivr.com/package/npm/ass-compiler)
[![File size](https://img.shields.io/bundlejs/size/ass-compiler)](https://bundlephobia.com/result?p=ass-compiler)Parses and compiles ASS subtitle format to easy-to-use data structure.
[Online Viewer](https://ass.js.org/ass-compiler/)
## Installation
```bash
npm install ass-compiler
```## Usage
You can use `parse` or `compile` as your need.
```js
import { parse, stringify, compile, decompile } from 'ass-compiler';// ASS file content
const text = `
[Script Info]
; ...
`;// parse just turn ASS text into JSON
const parsedASS = parse(text);
const stringifiedText = stringify(parsedASS);// compile will get rid of invalid tags, merge duplicated tags, transform drawings, etc.
const compiledASS = compile(text, options);
const decompiledText = decompile(compiledASS);
```### options
```js
{
// A Style named `Default` will be automatic generated by options.defaultStyle
// if it is not exists in `[V4+ Style]` section.
defaultStyle: {
Name: 'Default',
Fontname: 'Arial',
Fontsize: '20',
PrimaryColour: '&H00FFFFFF&',
SecondaryColour: '&H000000FF&',
OutlineColour: '&H00000000&',
BackColour: '&H00000000&',
Bold: '0',
Italic: '0',
Underline: '0',
StrikeOut: '0',
ScaleX: '100',
ScaleY: '100',
Spacing: '0',
Angle: '0',
BorderStyle: '1',
Outline: '2',
Shadow: '2',
Alignment: '2',
MarginL: '10',
MarginR: '10',
MarginV: '10',
Encoding: '1',
},
}
```For details of data structure, please use the [online viewer](https://ass.js.org/ass-compiler/).