matroska-subtitles
Advanced tools
Comparing version 2.0.4 to 3.0.0
{ | ||
"name": "matroska-subtitles", | ||
"version": "2.0.4", | ||
"description": "Writable stream for parsing embedded .mkv subtitles.", | ||
"main": "index.js", | ||
"files": [ | ||
"lib" | ||
], | ||
"version": "3.0.0", | ||
"description": "Streaming parser for embedded .mkv subtitles.", | ||
"source": "src/index.js", | ||
"main": "dist/matroska-subtitles.js", | ||
"module": "dist/matroska-subtitles.module.js", | ||
"unpkg": "dist/matroska-subtitles.umd.js", | ||
"dependencies": { | ||
"ebml": "^2.2.0", | ||
"ebml-block": "^1.1.0" | ||
"ebml": "^3.0.0", | ||
"ebml-block": "^1.1.2", | ||
"readable-stream": "^3.6.0" | ||
}, | ||
"devDependencies": {}, | ||
"devDependencies": { | ||
"dev-null": "^0.1.1", | ||
"microbundle": "^0.12.3", | ||
"standard": "*" | ||
}, | ||
"scripts": { | ||
"test": "standard" | ||
"test": "standard && node tests/test.js", | ||
"build": "microbundle --name=MatroskaSubtitles", | ||
"prepare": "npm run build", | ||
"prepublishOnly": "npm test" | ||
}, | ||
@@ -37,3 +45,6 @@ "keywords": [ | ||
"example": "examples" | ||
} | ||
}, | ||
"files": [ | ||
"dist" | ||
] | ||
} |
@@ -1,11 +0,9 @@ | ||
# matroska-subtitles [![npm][npm-img]][npm-url] [![dependencies][dep-img]][dep-url] [![license][lic-img]][lic-url] | ||
# matroska-subtitles | ||
[npm-img]: https://img.shields.io/npm/v/matroska-subtitles.svg | ||
[npm-url]: https://www.npmjs.com/package/matroska-subtitles | ||
[dep-img]: https://david-dm.org/mathiasvr/matroska-subtitles.svg | ||
[dep-url]: https://david-dm.org/mathiasvr/matroska-subtitles | ||
[lic-img]: http://img.shields.io/:license-MIT-blue.svg | ||
[lic-url]: http://mvr.mit-license.org | ||
[![npm](https://img.shields.io/npm/v/matroska-subtitles.svg)](https://npm.im/matroska-subtitles) | ||
![downloads](https://img.shields.io/npm/dt/matroska-subtitles.svg) | ||
[![dependencies](https://david-dm.org/mathiasvr/matroska-subtitles.svg)](https://david-dm.org/mathiasvr/matroska-subtitles) | ||
[![license](https://img.shields.io/:license-MIT-blue.svg)](https://mvr.mit-license.org) | ||
Writable stream for parsing embedded .mkv subtitles. | ||
Streaming parser for embedded .mkv subtitles. | ||
@@ -16,6 +14,11 @@ Supported formats: `.srt`, `.ssa`, `.ass`. | ||
```bash | ||
npm install matroska-subtitles | ||
```shell | ||
$ npm install matroska-subtitles | ||
``` | ||
or include it directly: | ||
```html | ||
<script src="https://unpkg.com/matroska-subtitles@3.0.0"></script> | ||
``` | ||
## example | ||
@@ -25,16 +28,14 @@ | ||
const fs = require('fs') | ||
const MatroskaSubtitles = require('matroska-subtitles') | ||
const { SubtitleParser } = require('matroska-subtitles') | ||
var parser = new MatroskaSubtitles() | ||
const parser = new SubtitleParser() | ||
// first an array of subtitle track information is emitted | ||
parser.once('tracks', function (tracks) { | ||
console.log(tracks) | ||
}) | ||
parser.once('tracks', (tracks) => console.log(tracks)) | ||
// afterwards each subtitle is emitted | ||
parser.on('subtitle', function (subtitle, trackNumber) { | ||
console.log('Track ' + trackNumber + ':', subtitle) | ||
}) | ||
parser.on('subtitle', (subtitle, trackNumber) => | ||
console.log('Track ' + trackNumber + ':', subtitle)) | ||
fs.createReadStream('Sintel.2010.720p.mkv').pipe(parser) | ||
@@ -54,3 +55,3 @@ ``` | ||
> Note that the `language` may be `undefined` if the mkv track doesn't specify it. | ||
> The `language` attribute can be `undefined` if the mkv track does not specify it. | ||
@@ -67,13 +68,21 @@ ### `subtitle` event response format | ||
> May also contain additional `.ass` specific values | ||
## random access | ||
The parser must obtain the `tracks` metadata event before it can begin to emit subtitles. | ||
To read subtitles from a specific position in the stream, | ||
you can pass in a previous instance as parameter: `parser = new MatroskaSubtitles(parser)` | ||
after the `tracks` event and pipe from a given position. See [examples/random-access.js](https://github.com/mathiasvr/matroska-subtitles/blob/master/examples/random-access.js) for an example. | ||
This module also includes a `SubtitleStream` class for intercepting subtitles | ||
in mkv streams with support for seeking. | ||
```js | ||
const { SubtitleStream } = require('matroska-subtitles') | ||
let subtitleStream = new SubtitleStream() | ||
subtitleStream.once('tracks', (tracks) => { | ||
// seek to different stream offset | ||
}) | ||
``` | ||
See [examples/random-access.js](examples/random-access.js) for a detailed example. | ||
## see also | ||
[mkv-subtitle-extractor](https://www.npmjs.com/package/mkv-subtitle-extractor) | ||
[mkv-subtitle-extractor](https://npm.im/mkv-subtitle-extractor) | ||
@@ -80,0 +89,0 @@ ## license |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
59495
11
88
3
3
54
2
1
+ Addedreadable-stream@^3.6.0
+ Addedebml@3.0.0(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedutil-deprecate@1.0.2(transitive)
- Removedebml@2.2.4(transitive)
Updatedebml@^3.0.0
Updatedebml-block@^1.1.2