@remotion/media-parser 4.0.204 → 4.0.205
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/dist/boxes/iso-base-media/esds/decoder-specific-config.js +6 -1
- package/dist/boxes/iso-base-media/make-track.js +3 -30
- package/dist/boxes/iso-base-media/mdat/mdat.js +25 -22
- package/dist/boxes/iso-base-media/mdhd.d.ts +2 -0
- package/dist/boxes/iso-base-media/mdhd.js +6 -7
- package/dist/boxes/iso-base-media/mvhd.js +11 -13
- package/dist/boxes/iso-base-media/process-box.js +36 -0
- package/dist/boxes/iso-base-media/tkhd.js +9 -12
- package/dist/boxes/webm/ebml.d.ts +1 -1
- package/dist/boxes/webm/get-track.js +2 -2
- package/dist/buffer-iterator.d.ts +1 -0
- package/dist/buffer-iterator.js +3 -2
- package/dist/create/cluster-segment.d.ts +10 -0
- package/dist/create/cluster-segment.js +41 -0
- package/dist/create/create-media.d.ts +7 -0
- package/dist/create/create-media.js +90 -0
- package/dist/create/matroska-header.d.ts +1 -0
- package/dist/create/matroska-header.js +66 -0
- package/dist/create/matroska-info.d.ts +4 -0
- package/dist/create/matroska-info.js +39 -0
- package/dist/create/matroska-segment.d.ts +2 -0
- package/dist/create/matroska-segment.js +12 -0
- package/dist/create/matroska-trackentry.d.ts +22 -0
- package/dist/create/matroska-trackentry.js +191 -0
- package/dist/get-duration.d.ts +3 -2
- package/dist/get-duration.js +24 -4
- package/dist/get-tracks.d.ts +4 -4
- package/dist/has-all-info.js +1 -1
- package/dist/parse-media.js +1 -1
- package/dist/parse-result.d.ts +4 -1
- package/dist/readers/from-fetch.d.ts +2 -0
- package/dist/readers/from-fetch.js +64 -0
- package/dist/readers/from-node.d.ts +2 -0
- package/dist/readers/from-node.js +40 -0
- package/dist/readers/from-web-file.d.ts +2 -0
- package/dist/readers/from-web-file.js +39 -0
- package/dist/readers/reader.d.ts +11 -0
- package/dist/readers/reader.js +2 -0
- package/dist/samples-from-moof.js +2 -1
- package/dist/traversal.d.ts +8 -1
- package/dist/traversal.js +39 -1
- package/dist/writers/web-fs.d.ts +2 -0
- package/dist/writers/web-fs.js +44 -0
- package/dist/writers/writer.d.ts +11 -0
- package/dist/writers/writer.js +2 -0
- package/package.json +2 -2
- package/src/boxes/iso-base-media/esds/decoder-specific-config.ts +8 -1
- package/src/samples-from-moof.ts +2 -1
- package/src/test/samples-from-moof.test.ts +3 -3
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -19,8 +19,9 @@ const getSamplesFromTraf = (trafSegment, moofOffset) => {
|
|
|
19
19
|
const samples = [];
|
|
20
20
|
for (const trunBox of trunBoxes) {
|
|
21
21
|
let i = -1;
|
|
22
|
-
if (
|
|
22
|
+
if (trunBox.dataOffset) {
|
|
23
23
|
dataOffset = trunBox.dataOffset;
|
|
24
|
+
offset = 0;
|
|
24
25
|
}
|
|
25
26
|
for (const sample of trunBox.samples) {
|
|
26
27
|
i++;
|
package/dist/traversal.d.ts
CHANGED
|
@@ -9,12 +9,16 @@ import type { StsdBox } from './boxes/iso-base-media/stsd/stsd';
|
|
|
9
9
|
import type { StssBox } from './boxes/iso-base-media/stsd/stss';
|
|
10
10
|
import type { StszBox } from './boxes/iso-base-media/stsd/stsz';
|
|
11
11
|
import type { SttsBox } from './boxes/iso-base-media/stsd/stts';
|
|
12
|
+
import type { TfdtBox } from './boxes/iso-base-media/tfdt';
|
|
13
|
+
import type { TfhdBox } from './boxes/iso-base-media/tfhd';
|
|
12
14
|
import type { TkhdBox } from './boxes/iso-base-media/tkhd';
|
|
13
15
|
import type { TrakBox } from './boxes/iso-base-media/trak/trak';
|
|
16
|
+
import type { TrunBox } from './boxes/iso-base-media/trun';
|
|
14
17
|
import type { AudioSegment, ClusterSegment, CodecIdSegment, DisplayHeightSegment, DisplayWidthSegment, HeightSegment, MainSegment, TimestampScaleSegment, TrackEntry, TrackTypeSegment, VideoSegment, WidthSegment } from './boxes/webm/segments/all-segments';
|
|
15
|
-
import type { AnySegment, RegularBox } from './parse-result';
|
|
18
|
+
import type { AnySegment, IsoBaseMediaBox, RegularBox } from './parse-result';
|
|
16
19
|
export declare const getFtypBox: (segments: AnySegment[]) => FtypBox | null;
|
|
17
20
|
export declare const getMoovBox: (segments: AnySegment[]) => MoovBox | null;
|
|
21
|
+
export declare const getMoofBox: (main: AnySegment[]) => IsoBaseMediaBox | null;
|
|
18
22
|
export declare const getMvhdBox: (moovBox: MoovBox) => MvhdBox | null;
|
|
19
23
|
export declare const getTraks: (moovBox: MoovBox) => TrakBox[];
|
|
20
24
|
export declare const getTkhdBox: (trakBox: TrakBox) => TkhdBox | null;
|
|
@@ -29,6 +33,9 @@ export declare const getCttsBox: (trakBox: TrakBox) => CttsBox | null;
|
|
|
29
33
|
export declare const getStszBox: (trakBox: TrakBox) => StszBox | null;
|
|
30
34
|
export declare const getStscBox: (trakBox: TrakBox) => StscBox | null;
|
|
31
35
|
export declare const getStssBox: (trakBox: TrakBox) => StssBox | null;
|
|
36
|
+
export declare const getTfdtBox: (segment: IsoBaseMediaBox) => TfdtBox | null;
|
|
37
|
+
export declare const getTfhdBox: (segment: IsoBaseMediaBox) => TfhdBox | null;
|
|
38
|
+
export declare const getTrunBoxes: (segment: IsoBaseMediaBox) => TrunBox[];
|
|
32
39
|
export declare const getClusterSegment: (segment: MainSegment) => ClusterSegment | null;
|
|
33
40
|
export declare const getTracksSegment: (segment: MainSegment) => {
|
|
34
41
|
type: "Tracks";
|
package/dist/traversal.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasSkippedMdatProcessing = exports.getCodecSegment = exports.getTrackId = exports.getTrackTypeSegment = exports.getDisplayHeightSegment = exports.getDisplayWidthSegment = exports.getHeightSegment = exports.getWidthSegment = exports.getPrivateData = exports.getBitDepth = exports.getNumberOfChannels = exports.getSampleRate = exports.getAudioSegment = exports.getVideoSegment = exports.getTimescaleSegment = exports.getTracksSegment = exports.getClusterSegment = exports.getStssBox = exports.getStscBox = exports.getStszBox = exports.getCttsBox = exports.getSttsBox = exports.getStcoBox = exports.getVideoDescriptors = exports.getStsdBox = exports.getStblBox = exports.getMdhdBox = exports.getMdiaBox = exports.getTkhdBox = exports.getTraks = exports.getMvhdBox = exports.getMoovBox = exports.getFtypBox = void 0;
|
|
3
|
+
exports.hasSkippedMdatProcessing = exports.getCodecSegment = exports.getTrackId = exports.getTrackTypeSegment = exports.getDisplayHeightSegment = exports.getDisplayWidthSegment = exports.getHeightSegment = exports.getWidthSegment = exports.getPrivateData = exports.getBitDepth = exports.getNumberOfChannels = exports.getSampleRate = exports.getAudioSegment = exports.getVideoSegment = exports.getTimescaleSegment = exports.getTracksSegment = exports.getClusterSegment = exports.getTrunBoxes = exports.getTfhdBox = exports.getTfdtBox = exports.getStssBox = exports.getStscBox = exports.getStszBox = exports.getCttsBox = exports.getSttsBox = exports.getStcoBox = exports.getVideoDescriptors = exports.getStsdBox = exports.getStblBox = exports.getMdhdBox = exports.getMdiaBox = exports.getTkhdBox = exports.getTraks = exports.getMvhdBox = exports.getMoofBox = exports.getMoovBox = exports.getFtypBox = void 0;
|
|
4
4
|
const getFtypBox = (segments) => {
|
|
5
5
|
const ftypBox = segments.find((s) => s.type === 'ftyp-box');
|
|
6
6
|
if (!ftypBox || ftypBox.type !== 'ftyp-box') {
|
|
@@ -17,6 +17,14 @@ const getMoovBox = (segments) => {
|
|
|
17
17
|
return moovBox;
|
|
18
18
|
};
|
|
19
19
|
exports.getMoovBox = getMoovBox;
|
|
20
|
+
const getMoofBox = (main) => {
|
|
21
|
+
const moofBox = main.find((s) => s.type === 'regular-box' && s.boxType === 'moof');
|
|
22
|
+
if (!moofBox || moofBox.type !== 'regular-box') {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return moofBox;
|
|
26
|
+
};
|
|
27
|
+
exports.getMoofBox = getMoofBox;
|
|
20
28
|
const getMvhdBox = (moovBox) => {
|
|
21
29
|
const mvHdBox = moovBox.children.find((s) => s.type === 'mvhd-box');
|
|
22
30
|
if (!mvHdBox || mvHdBox.type !== 'mvhd-box') {
|
|
@@ -150,6 +158,36 @@ const getStssBox = (trakBox) => {
|
|
|
150
158
|
return stssBox;
|
|
151
159
|
};
|
|
152
160
|
exports.getStssBox = getStssBox;
|
|
161
|
+
const getTfdtBox = (segment) => {
|
|
162
|
+
if (segment.type !== 'regular-box' || segment.boxType !== 'traf') {
|
|
163
|
+
throw new Error('Expected traf-box');
|
|
164
|
+
}
|
|
165
|
+
const tfhdBox = segment.children.find((c) => c.type === 'tfdt-box');
|
|
166
|
+
if (!tfhdBox || tfhdBox.type !== 'tfdt-box') {
|
|
167
|
+
throw new Error('Expected tfhd-box');
|
|
168
|
+
}
|
|
169
|
+
return tfhdBox;
|
|
170
|
+
};
|
|
171
|
+
exports.getTfdtBox = getTfdtBox;
|
|
172
|
+
const getTfhdBox = (segment) => {
|
|
173
|
+
if (segment.type !== 'regular-box' || segment.boxType !== 'traf') {
|
|
174
|
+
throw new Error('Expected traf-box');
|
|
175
|
+
}
|
|
176
|
+
const tfhdBox = segment.children.find((c) => c.type === 'tfhd-box');
|
|
177
|
+
if (!tfhdBox || tfhdBox.type !== 'tfhd-box') {
|
|
178
|
+
throw new Error('Expected tfhd-box');
|
|
179
|
+
}
|
|
180
|
+
return tfhdBox;
|
|
181
|
+
};
|
|
182
|
+
exports.getTfhdBox = getTfhdBox;
|
|
183
|
+
const getTrunBoxes = (segment) => {
|
|
184
|
+
if (segment.type !== 'regular-box' || segment.boxType !== 'traf') {
|
|
185
|
+
throw new Error('Expected traf-box');
|
|
186
|
+
}
|
|
187
|
+
const trunBoxes = segment.children.filter((c) => c.type === 'trun-box');
|
|
188
|
+
return trunBoxes;
|
|
189
|
+
};
|
|
190
|
+
exports.getTrunBoxes = getTrunBoxes;
|
|
153
191
|
const getClusterSegment = (segment) => {
|
|
154
192
|
const clusterSegment = segment.value.find((b) => b.type === 'Cluster');
|
|
155
193
|
return clusterSegment !== null && clusterSegment !== void 0 ? clusterSegment : null;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.webFsWriter = void 0;
|
|
4
|
+
const createContent = async () => {
|
|
5
|
+
const directoryHandle = await navigator.storage.getDirectory();
|
|
6
|
+
const filename = `media-parser-${Math.random().toString().replace('0.', '')}.webm`;
|
|
7
|
+
const fileHandle = await directoryHandle.getFileHandle(filename, {
|
|
8
|
+
create: true,
|
|
9
|
+
});
|
|
10
|
+
const writable = await fileHandle.createWritable();
|
|
11
|
+
let written = 0;
|
|
12
|
+
const writer = {
|
|
13
|
+
write: async (arr) => {
|
|
14
|
+
await writable.write(arr);
|
|
15
|
+
written += arr.byteLength;
|
|
16
|
+
},
|
|
17
|
+
save: async () => {
|
|
18
|
+
await writable.close();
|
|
19
|
+
const picker = await window.showSaveFilePicker({
|
|
20
|
+
suggestedName: `${Math.random().toString().replace('.', '')}.webm`,
|
|
21
|
+
});
|
|
22
|
+
const newHandle = await directoryHandle.getFileHandle(filename, {
|
|
23
|
+
create: true,
|
|
24
|
+
});
|
|
25
|
+
const newFile = await newHandle.getFile();
|
|
26
|
+
const pickerWriteable = await picker.createWritable();
|
|
27
|
+
const stream = newFile.stream();
|
|
28
|
+
await stream.pipeTo(pickerWriteable);
|
|
29
|
+
await directoryHandle.removeEntry(filename, {
|
|
30
|
+
recursive: true,
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
getWrittenByteCount: () => written,
|
|
34
|
+
updateDataAt: async (position, vint) => {
|
|
35
|
+
await writable.seek(position);
|
|
36
|
+
await writable.write(vint);
|
|
37
|
+
await writable.seek(written);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
return writer;
|
|
41
|
+
};
|
|
42
|
+
exports.webFsWriter = {
|
|
43
|
+
createContent,
|
|
44
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type Writer = {
|
|
2
|
+
write: (arr: Uint8Array) => Promise<void>;
|
|
3
|
+
save: () => Promise<void>;
|
|
4
|
+
getWrittenByteCount: () => number;
|
|
5
|
+
updateDataAt: (position: number, vint: Uint8Array) => Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
type CreateContent = () => Promise<Writer>;
|
|
8
|
+
export type WriterInterface = {
|
|
9
|
+
createContent: CreateContent;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
package/package.json
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
"url": "https://github.com/remotion-dev/remotion/tree/main/packages/media-parser"
|
|
4
4
|
},
|
|
5
5
|
"name": "@remotion/media-parser",
|
|
6
|
-
"version": "4.0.
|
|
6
|
+
"version": "4.0.205",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"devDependencies": {
|
|
10
|
-
"@remotion/renderer": "4.0.
|
|
10
|
+
"@remotion/renderer": "4.0.205"
|
|
11
11
|
},
|
|
12
12
|
"publishConfig": {
|
|
13
13
|
"access": "public"
|
|
@@ -51,11 +51,18 @@ export const parseDecoderSpecificConfig = (
|
|
|
51
51
|
iterator.discard(layerSize - read);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
// Working around Chrome bug
|
|
55
|
+
// https://issues.chromium.org/issues/360083330#comment5
|
|
56
|
+
const patchedAsBytes =
|
|
57
|
+
bytes.byteLength === 2 && bytes[0] === 17 && bytes[1] === 136
|
|
58
|
+
? new Uint8Array([17, 144])
|
|
59
|
+
: bytes;
|
|
60
|
+
|
|
54
61
|
return {
|
|
55
62
|
type: 'audio-specific-config',
|
|
56
63
|
audioObjectType,
|
|
57
64
|
samplingFrequencyIndex,
|
|
58
65
|
channelConfiguration,
|
|
59
|
-
asBytes:
|
|
66
|
+
asBytes: patchedAsBytes,
|
|
60
67
|
};
|
|
61
68
|
};
|
package/src/samples-from-moof.ts
CHANGED
|
@@ -28,8 +28,9 @@ const getSamplesFromTraf = (
|
|
|
28
28
|
for (const trunBox of trunBoxes) {
|
|
29
29
|
let i = -1;
|
|
30
30
|
|
|
31
|
-
if (
|
|
31
|
+
if (trunBox.dataOffset) {
|
|
32
32
|
dataOffset = trunBox.dataOffset;
|
|
33
|
+
offset = 0;
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
for (const sample of trunBox.samples) {
|
|
@@ -2338,7 +2338,7 @@ test('Should be able to parse video sample positions from a moof atom', () => {
|
|
|
2338
2338
|
dts: 327,
|
|
2339
2339
|
duration: 19,
|
|
2340
2340
|
isKeyframe: true,
|
|
2341
|
-
offset:
|
|
2341
|
+
offset: 572709,
|
|
2342
2342
|
size: 34739,
|
|
2343
2343
|
},
|
|
2344
2344
|
]);
|
|
@@ -2348,7 +2348,7 @@ test('Should be able to parse video sample positions from a moof atom', () => {
|
|
|
2348
2348
|
dts: 2567,
|
|
2349
2349
|
duration: 1,
|
|
2350
2350
|
isKeyframe: false,
|
|
2351
|
-
offset:
|
|
2351
|
+
offset: 5481634,
|
|
2352
2352
|
size: 45308,
|
|
2353
2353
|
});
|
|
2354
2354
|
});
|
|
@@ -2490,7 +2490,7 @@ test('Should be able to parse audio sample positions from a moof atom', () => {
|
|
|
2490
2490
|
dts: 204800,
|
|
2491
2491
|
duration: 1024,
|
|
2492
2492
|
isKeyframe: true,
|
|
2493
|
-
offset:
|
|
2493
|
+
offset: 5532567,
|
|
2494
2494
|
size: 698,
|
|
2495
2495
|
});
|
|
2496
2496
|
});
|