ebml.js 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/testing.yml +28 -0
- package/.husky/pre-commit +4 -0
- package/.prettierrc.json +4 -0
- package/.vscode/settings.json +19 -0
- package/LICENSE +17 -0
- package/README.md +154 -0
- package/dist/ebml.js +10452 -0
- package/dist/ebml.js.map +1 -0
- package/dist/ebml.min.js +12 -0
- package/dist/ebml.min.js.map +1 -0
- package/dist/ebml.min.node.js +2 -0
- package/dist/ebml.min.node.js.map +1 -0
- package/dist/ebml.node.js +4036 -0
- package/dist/ebml.node.js.map +1 -0
- package/example.js +14 -0
- package/media/test.webm +0 -0
- package/package.json +56 -0
- package/src/debug-log.js +12 -0
- package/src/decoder.js +301 -0
- package/src/decoder.test.js +158 -0
- package/src/encoder.js +246 -0
- package/src/encoder.test.js +206 -0
- package/src/index.js +11 -0
- package/src/schema.js +3023 -0
- package/src/tools.js +355 -0
- package/src/tools.test.js +738 -0
- package/src/types/schema.types.js +30 -0
- package/src/types/tag.types.js +25 -0
- package/streamExample.js +17 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: Node-EBML Tests
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [master]
|
|
5
|
+
pull_request:
|
|
6
|
+
branches: [master]
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
matrix:
|
|
13
|
+
node-version: [6.x, 8.x, 10.x]
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v2
|
|
17
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
18
|
+
uses: actions/setup-node@v1
|
|
19
|
+
run: npm install -g codecov
|
|
20
|
+
with:
|
|
21
|
+
node-version: ${{ matrix.node-version }}
|
|
22
|
+
cache: 'npm'
|
|
23
|
+
- name: Install dependencies
|
|
24
|
+
run: yarn --frozen-lockfile
|
|
25
|
+
- run: yarn build
|
|
26
|
+
- run: yarn test
|
|
27
|
+
- run: codecov
|
|
28
|
+
|
package/.prettierrc.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cSpell.words": [
|
|
3
|
+
"Buus",
|
|
4
|
+
"Deursen",
|
|
5
|
+
"Markowski",
|
|
6
|
+
"Schmale",
|
|
7
|
+
"Vint",
|
|
8
|
+
"Wiedenmann",
|
|
9
|
+
"funkensturm",
|
|
10
|
+
"greenkeeperio",
|
|
11
|
+
"iife",
|
|
12
|
+
"incuray",
|
|
13
|
+
"kawanet",
|
|
14
|
+
"masch",
|
|
15
|
+
"mathiasbuus",
|
|
16
|
+
"maxogden",
|
|
17
|
+
"vandeursen"
|
|
18
|
+
]
|
|
19
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Copyright (c) 2013-2018 Mark Schmale and contributors
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
5
|
+
the Software without restriction, including without limitation the rights to
|
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
8
|
+
so, subject to the following conditions:
|
|
9
|
+
The above copyright notice and this permission notice shall be included in all
|
|
10
|
+
copies or substantial portions of the Software.
|
|
11
|
+
|
|
12
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
13
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
14
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
15
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
16
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
17
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
|
package/README.md
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
# EBML [](https://www.npmjs.com/package/ebml) [](https://codecov.io/gh/node-ebml/node-ebml) [](https://greenkeeper.io/)
|
|
2
|
+
|
|
3
|
+
[EBML][ebml] stands for Extensible Binary Meta-Language and is somewhat of a
|
|
4
|
+
binary version of XML. It's used for container formats like [WebM][webm] or
|
|
5
|
+
[MKV][mkv].
|
|
6
|
+
|
|
7
|
+
## Note
|
|
8
|
+
|
|
9
|
+
this version fixes just the encoder
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
This is for version `3.0.0` and up, which has undergone a _massive_ rewrite and
|
|
14
|
+
now builds with [RollupJS][rollup].
|
|
15
|
+
|
|
16
|
+
Version `2.2.4` is the last version to have guaranteed legacy semantics.
|
|
17
|
+
|
|
18
|
+
# Install
|
|
19
|
+
|
|
20
|
+
Install via NPM or Yarn:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install ebml.js --save
|
|
24
|
+
# or
|
|
25
|
+
yarn add ebml.js
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
# Usage
|
|
29
|
+
|
|
30
|
+
The `Decoder()` class is implemented as a [Node Transform stream][node-stream-transform].
|
|
31
|
+
As input it takes EBML. As output it emits a sequence of chunks: two-element
|
|
32
|
+
arrays looking like this example.
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
[
|
|
36
|
+
'tag',
|
|
37
|
+
{
|
|
38
|
+
name: 'TimecodeScale',
|
|
39
|
+
type: 'u',
|
|
40
|
+
value: 1000000,
|
|
41
|
+
},
|
|
42
|
+
];
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The first element of the array is a short text string. For tags containing
|
|
46
|
+
values, like this example, the string is `'tag'`. ebml also has nesting tags.
|
|
47
|
+
The opening of those tags has the string `'start'` and the closing has the
|
|
48
|
+
string `'end'`. Integers stored in 6 bytes or less are represented as numbers,
|
|
49
|
+
and longer integers are represented as hexadecimal text strings.
|
|
50
|
+
|
|
51
|
+
The second element of the array is an object with these members, among others:
|
|
52
|
+
|
|
53
|
+
- `name` is the [Matroska][mkv] Element Name.
|
|
54
|
+
- `type` is the data type.
|
|
55
|
+
- `u`: unsigned integer. Some of these are UIDs, coded as 128-bit numbers.
|
|
56
|
+
- `i`: signed integer.
|
|
57
|
+
- `f`: IEEE-754 floating point number.
|
|
58
|
+
- `s`: printable ASCII text string.
|
|
59
|
+
- `8`: printable utf-8 Unicode text string.
|
|
60
|
+
- `d`: a 64-bit signed timestamp, in nanoseconds after (or before) `2001-01-01T00:00UTC`.
|
|
61
|
+
- `b` binary data, otherwise uninterpreted.
|
|
62
|
+
- `value` is the value of the data in the element, represented as a number or a string.
|
|
63
|
+
- `data` is the binary data of the entire element stored in a [`Uint8Array`][mdn-uint8array].
|
|
64
|
+
|
|
65
|
+
Elements with the [`Block`][mkv-block] and [`SimpleBlock`][mkv-sblock] types
|
|
66
|
+
get special treatment. They have these additional members:
|
|
67
|
+
|
|
68
|
+
- `payload` is the coded information in the element, stored in a [`Uint8Array`][mdn-uint8array].
|
|
69
|
+
- `track` is an unsigned integer indicating the payload's track.
|
|
70
|
+
- `keyframe` is a Boolean value set to true if the payload starts an I frame (`SimpleBlocks` only).
|
|
71
|
+
- `discardable` is a Boolean value showing the value of the element's Discardable flag. (`SimpleBlocks` only).
|
|
72
|
+
|
|
73
|
+
And the `value` member shows the block's Timecode value.
|
|
74
|
+
|
|
75
|
+
# Examples
|
|
76
|
+
|
|
77
|
+
This example reads a media file into memory and decodes it. The `decoder`
|
|
78
|
+
invokes its `data` event for each Element.
|
|
79
|
+
|
|
80
|
+
```js
|
|
81
|
+
const fs = require('fs');
|
|
82
|
+
const { Decoder } = require('ebml.js');
|
|
83
|
+
|
|
84
|
+
const decoder = new Decoder();
|
|
85
|
+
|
|
86
|
+
decoder.on('data', (chunk) => console.log(chunk));
|
|
87
|
+
|
|
88
|
+
fs.readFile('media/test.webm', (err, data) => {
|
|
89
|
+
if (err) {
|
|
90
|
+
throw err;
|
|
91
|
+
}
|
|
92
|
+
decoder.write(data);
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
This example does the same thing, but by piping the file stream into the decoder (a Transform stream).
|
|
97
|
+
|
|
98
|
+
```js
|
|
99
|
+
const { Decoder } = require('ebml.js');
|
|
100
|
+
|
|
101
|
+
const ebmlDecoder = new Decoder();
|
|
102
|
+
const counts = {};
|
|
103
|
+
|
|
104
|
+
require('fs')
|
|
105
|
+
.createReadStream('media/test.webm')
|
|
106
|
+
.pipe(ebmlDecoder)
|
|
107
|
+
.on('data', (chunk) => {
|
|
108
|
+
const { name } = chunk[1];
|
|
109
|
+
if (!counts[name]) {
|
|
110
|
+
counts[name] = 0;
|
|
111
|
+
}
|
|
112
|
+
counts[name] += 1;
|
|
113
|
+
})
|
|
114
|
+
.on('finish', () => console.log(counts));
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
# State of this project
|
|
118
|
+
|
|
119
|
+
Parsing should work. If it doesn't, please create [an issue][new-issue].
|
|
120
|
+
|
|
121
|
+
`d`-type elements (timestamps) are not yet decoded to Javascript timestamp
|
|
122
|
+
values.
|
|
123
|
+
|
|
124
|
+
Thanks to @chrisprice we got an encoder!
|
|
125
|
+
|
|
126
|
+
# License
|
|
127
|
+
|
|
128
|
+
[MIT](./LICENSE)
|
|
129
|
+
|
|
130
|
+
# Contributors
|
|
131
|
+
|
|
132
|
+
(in alphabetical order)
|
|
133
|
+
|
|
134
|
+
- [Chris Price](https://github.com/chrisprice)
|
|
135
|
+
- [Davy Van Deursen](https://github.com/dvdeurse)
|
|
136
|
+
- [Ed Markowski](https://github.com/siphontv)
|
|
137
|
+
- [Jonathan Sifuentes](https://github.com/jayands)
|
|
138
|
+
- [Manuel Wiedenmann](https://github.com/fsmanuel)
|
|
139
|
+
- [Mark Schmale](https://github.com/themasch)
|
|
140
|
+
- [Mathias Buus](https://github.com/mafintosh)
|
|
141
|
+
- [Max Ogden](https://github.com/maxogden)
|
|
142
|
+
- [Morgas](https://github.com/Morgas01)
|
|
143
|
+
- [Oliver Jones](https://github.com/OllieJones)
|
|
144
|
+
- [Oliver Walzer](https://github.com/owcd)
|
|
145
|
+
|
|
146
|
+
[ebml]: http://ebml.sourceforge.net/
|
|
147
|
+
[new-issue]: https://github.com/node-ebml/node-ebml/issues/new
|
|
148
|
+
[mdn-uint8array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array
|
|
149
|
+
[node-stream-transform]: https://nodejs.org/api/stream.html#stream_class_stream_transform
|
|
150
|
+
[mkv]: http://www.matroska.org/technical/specs/index.html
|
|
151
|
+
[rollup]: https://rollupjs.org/
|
|
152
|
+
[mkv-block]: https://www.matroska.org/technical/specs/index.html#block_structure
|
|
153
|
+
[mkv-sblock]: https://www.matroska.org/technical/specs/index.html#simpleblock_structure
|
|
154
|
+
[webm]: https://www.webmproject.org/
|