@remotion/media-parser 4.0.193 → 4.0.194

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.
Files changed (49) hide show
  1. package/dist/boxes/iso-base-media/esds-descriptors.d.ts +21 -0
  2. package/dist/boxes/iso-base-media/esds-descriptors.js +62 -0
  3. package/dist/boxes/iso-base-media/esds.d.ts +15 -0
  4. package/dist/boxes/iso-base-media/esds.js +27 -0
  5. package/dist/boxes/iso-base-media/mdat/mdat.d.ts +12 -0
  6. package/dist/boxes/iso-base-media/mdat/mdat.js +13 -0
  7. package/dist/boxes/iso-base-media/process-box.js +50 -0
  8. package/dist/boxes/iso-base-media/stsd/stco.d.ts +14 -0
  9. package/dist/boxes/iso-base-media/stsd/stco.js +30 -0
  10. package/dist/boxes/iso-base-media/stsd/stsc.d.ts +19 -0
  11. package/dist/boxes/iso-base-media/stsd/stsc.js +34 -0
  12. package/dist/boxes/iso-base-media/stsd/stsz.d.ts +15 -0
  13. package/dist/boxes/iso-base-media/stsd/stsz.js +32 -0
  14. package/dist/buffer-iterator.d.ts +1 -0
  15. package/dist/buffer-iterator.js +14 -0
  16. package/dist/from-node.js +6 -2
  17. package/dist/from-web.js +9 -6
  18. package/dist/get-codec.d.ts +4 -0
  19. package/dist/get-codec.js +22 -0
  20. package/dist/get-sample-positions.d.ts +12 -0
  21. package/dist/get-sample-positions.js +25 -0
  22. package/dist/get-samples.d.ts +0 -0
  23. package/dist/get-samples.js +1 -0
  24. package/dist/get-tracks.d.ts +10 -0
  25. package/dist/get-tracks.js +66 -0
  26. package/dist/parse-media.js +14 -3
  27. package/dist/parse-result.d.ts +1 -0
  28. package/dist/parse-video.d.ts +1 -0
  29. package/dist/parse-video.js +1 -0
  30. package/dist/reader.d.ts +1 -1
  31. package/dist/traversal.d.ts +19 -0
  32. package/dist/traversal.js +88 -0
  33. package/package.json +2 -2
  34. package/src/boxes/iso-base-media/process-box.ts +55 -0
  35. package/src/buffer-iterator.ts +20 -0
  36. package/src/from-node.ts +7 -2
  37. package/src/from-web.ts +9 -6
  38. package/src/parse-media.ts +21 -3
  39. package/src/parse-result.ts +1 -0
  40. package/src/parse-video.ts +2 -0
  41. package/src/reader.ts +1 -1
  42. package/src/test/stream-local.test.ts +1 -1
  43. package/tsconfig.tsbuildinfo +1 -1
  44. package/dist/boxes/iso-base-media/ftype.d.ts +0 -9
  45. package/dist/boxes/iso-base-media/ftype.js +0 -31
  46. package/dist/get-video-metadata.d.ts +0 -2
  47. package/dist/get-video-metadata.js +0 -44
  48. package/dist/read-and-increment-offset.d.ts +0 -28
  49. package/dist/read-and-increment-offset.js +0 -177
@@ -1,177 +0,0 @@
1
- "use strict";
2
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
- if (kind === "m") throw new TypeError("Private method is not writable");
4
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
- };
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
- var _OffsetCounter_offset;
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.getArrayBufferIterator = exports.OffsetCounter = void 0;
16
- class OffsetCounter {
17
- constructor(initial) {
18
- _OffsetCounter_offset.set(this, void 0);
19
- __classPrivateFieldSet(this, _OffsetCounter_offset, initial, "f");
20
- }
21
- increment(amount) {
22
- if (amount < 0) {
23
- throw new Error('Cannot increment by a negative amount');
24
- }
25
- __classPrivateFieldSet(this, _OffsetCounter_offset, __classPrivateFieldGet(this, _OffsetCounter_offset, "f") + amount, "f");
26
- }
27
- getOffset() {
28
- return __classPrivateFieldGet(this, _OffsetCounter_offset, "f");
29
- }
30
- }
31
- exports.OffsetCounter = OffsetCounter;
32
- _OffsetCounter_offset = new WeakMap();
33
- const makeOffsetCounter = (initial) => {
34
- return new OffsetCounter(initial);
35
- };
36
- const getArrayBufferIterator = (data, initialOffset) => {
37
- const view = new DataView(data);
38
- const counter = makeOffsetCounter(initialOffset);
39
- const getSlice = (amount) => {
40
- const value = data.slice(counter.getOffset(), counter.getOffset() + amount);
41
- counter.increment(amount);
42
- return value;
43
- };
44
- const getUint8 = () => {
45
- const val = view.getUint8(counter.getOffset());
46
- counter.increment(1);
47
- return val;
48
- };
49
- const getUint32 = () => {
50
- const val = view.getUint32(counter.getOffset());
51
- counter.increment(4);
52
- return val;
53
- };
54
- return {
55
- view,
56
- counter,
57
- data,
58
- discard: (length) => {
59
- counter.increment(length);
60
- },
61
- getSlice,
62
- getAtom: () => {
63
- const atom = getSlice(4);
64
- return new TextDecoder().decode(atom);
65
- },
66
- getMatroskaSegmentId: () => {
67
- const first = getSlice(1);
68
- const firstOneString = `0x${Array.from(new Uint8Array(first))
69
- .map((b) => {
70
- return b.toString(16).padStart(2, '0');
71
- })
72
- .join('')}`;
73
- // Catch void block
74
- const knownIdsWithOneLength = ['0xec', '0xae'];
75
- if (knownIdsWithOneLength.includes(firstOneString)) {
76
- return firstOneString;
77
- }
78
- const firstTwo = getSlice(1);
79
- const knownIdsWithTwoLength = ['0x4dbb', '0x53ac', '0xec01'];
80
- const firstTwoString = `${firstOneString}${Array.from(new Uint8Array(firstTwo))
81
- .map((b) => {
82
- return b.toString(16).padStart(2, '0');
83
- })
84
- .join('')}`;
85
- if (knownIdsWithTwoLength.includes(firstTwoString)) {
86
- return firstTwoString;
87
- }
88
- const knownIdsWithThreeLength = ['0x4d808c', '0x57418c', '0x448988'];
89
- const firstThree = getSlice(1);
90
- const firstThreeString = `${firstTwoString}${Array.from(new Uint8Array(firstThree))
91
- .map((b) => {
92
- return b.toString(16).padStart(2, '0');
93
- })
94
- .join('')}`;
95
- if (knownIdsWithThreeLength.includes(firstThreeString)) {
96
- return firstThreeString;
97
- }
98
- const segmentId = getSlice(1);
99
- return `${firstThreeString}${Array.from(new Uint8Array(segmentId))
100
- .map((b) => {
101
- return b.toString(16).padStart(2, '0');
102
- })
103
- .join('')}`;
104
- },
105
- getVint: (bytes) => {
106
- const slice = getSlice(bytes);
107
- const d = [...Array.from(new Uint8Array(slice))];
108
- const totalLength = d[0];
109
- if (totalLength === 0) {
110
- return 0;
111
- }
112
- // Calculate the actual length of the data based on the first set bit
113
- let actualLength = 0;
114
- while (((totalLength >> (7 - actualLength)) & 0x01) === 0) {
115
- actualLength++;
116
- }
117
- actualLength += 1; // Include the first byte set as 1
118
- // Combine the numbers to form the integer value
119
- let value = 0;
120
- // Mask the first byte properly then start combining
121
- value = totalLength & (0xff >> actualLength);
122
- for (let i = 1; i < actualLength; i++) {
123
- value = (value << 8) | d[i];
124
- }
125
- return value;
126
- },
127
- getUint8,
128
- getEBML: () => {
129
- const val = getUint8();
130
- // https://darkcoding.net/software/reading-mediarecorders-webm-opus-output/#:~:text=The%20first%20four%20bytes%20(%201A,%E2%80%93%20read%20on%20for%20why).
131
- // You drop the initial 0 bits and the first 1 bit to get the value. 0x81 is 0b10000001, so there are zero inital 0 bits, meaning length one byte, and the value is 1. The 0x9F value for length of the EBML header we saw earlier is 0b10011111, still one byte, value is 0b0011111, which is 31 (the python repl is very helpful for these conversions).
132
- const actualValue = val & 0x7f; // 0x7F is binary 01111111, which masks out the first bit
133
- return actualValue;
134
- },
135
- getInt8: () => {
136
- const val = view.getInt8(counter.getOffset());
137
- counter.increment(1);
138
- return val;
139
- },
140
- getUint16: () => {
141
- const val = view.getUint16(counter.getOffset());
142
- counter.increment(2);
143
- return val;
144
- },
145
- getInt16: () => {
146
- const val = view.getInt16(counter.getOffset());
147
- counter.increment(2);
148
- return val;
149
- },
150
- getUint32,
151
- // https://developer.apple.com/documentation/quicktime-file-format/sound_sample_description_version_1
152
- // A 32-bit unsigned fixed-point number (16.16) that indicates the rate at which the sound samples were obtained.
153
- getFixedPoint1616Number: () => {
154
- const val = getUint32();
155
- return val / 2 ** 16;
156
- },
157
- getPascalString: () => {
158
- const val = getSlice(32);
159
- return [...Array.from(new Uint8Array(val))];
160
- },
161
- getDecimalBytes(length) {
162
- const bytes = getSlice(length);
163
- const numbers = [...Array.from(new Uint8Array(bytes))];
164
- return numbers.reduce((acc, byte, index) => acc + (byte << (8 * (numbers.length - index - 1))), 0);
165
- },
166
- getByteString(length) {
167
- const bytes = getSlice(length);
168
- return new TextDecoder().decode(bytes);
169
- },
170
- getFloat64: () => {
171
- const val = view.getFloat64(counter.getOffset());
172
- counter.increment(8);
173
- return val;
174
- },
175
- };
176
- };
177
- exports.getArrayBufferIterator = getArrayBufferIterator;