@remotion/media-parser 4.0.213 → 4.0.215
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/webm/ebml.d.ts +1 -1
- package/dist/boxes/webm/make-header.js +2 -2
- package/dist/boxes/webm/segments/block-simple-block-flags.d.ts +1 -1
- package/dist/esm/from-node.mjs +3 -3
- package/dist/esm/index.mjs +51 -51
- package/dist/readers/from-fetch.js +2 -2
- package/dist/truthy.js +1 -2
- package/package.json +3 -3
- package/dist/av1-codec-string.d.ts +0 -3
- package/dist/av1-codec-string.js +0 -91
- package/dist/boxes/iso-base-media/ftype.d.ts +0 -9
- package/dist/boxes/iso-base-media/ftype.js +0 -31
- package/dist/boxes/iso-base-media/stsd/avcc-hvcc.d.ts +0 -20
- package/dist/boxes/iso-base-media/stsd/avcc-hvcc.js +0 -73
- package/dist/boxes/iso-base-media/stts/stts.d.ts +0 -15
- package/dist/boxes/iso-base-media/stts/stts.js +0 -35
- package/dist/boxes/webm/bitstream/av1/bitstream-frame-header.d.ts +0 -14
- package/dist/boxes/webm/bitstream/av1/bitstream-frame-header.js +0 -67
- package/dist/boxes/webm/bitstream/av1/bitstream-frame.d.ts +0 -11
- package/dist/boxes/webm/bitstream/av1/bitstream-frame.js +0 -14
- package/dist/boxes/webm/bitstream/av1/chroma-sample-position.d.ts +0 -6
- package/dist/boxes/webm/bitstream/av1/chroma-sample-position.js +0 -9
- package/dist/boxes/webm/bitstream/av1/color-config.d.ts +0 -16
- package/dist/boxes/webm/bitstream/av1/color-config.js +0 -103
- package/dist/boxes/webm/bitstream/av1/color-primaries.d.ts +0 -14
- package/dist/boxes/webm/bitstream/av1/color-primaries.js +0 -17
- package/dist/boxes/webm/bitstream/av1/decoder-model-info.d.ts +0 -9
- package/dist/boxes/webm/bitstream/av1/decoder-model-info.js +0 -17
- package/dist/boxes/webm/bitstream/av1/frame.d.ts +0 -0
- package/dist/boxes/webm/bitstream/av1/frame.js +0 -1
- package/dist/boxes/webm/bitstream/av1/header-segment.d.ts +0 -51
- package/dist/boxes/webm/bitstream/av1/header-segment.js +0 -183
- package/dist/boxes/webm/bitstream/av1/matrix-coefficients.d.ts +0 -17
- package/dist/boxes/webm/bitstream/av1/matrix-coefficients.js +0 -20
- package/dist/boxes/webm/bitstream/av1/operating-parameters-info.d.ts +0 -10
- package/dist/boxes/webm/bitstream/av1/operating-parameters-info.js +0 -15
- package/dist/boxes/webm/bitstream/av1/temporal-point-info.d.ts +0 -5
- package/dist/boxes/webm/bitstream/av1/temporal-point-info.js +0 -8
- package/dist/boxes/webm/bitstream/av1/timing-info.d.ts +0 -8
- package/dist/boxes/webm/bitstream/av1/timing-info.js +0 -20
- package/dist/boxes/webm/bitstream/av1/transfer-characteristics.d.ts +0 -21
- package/dist/boxes/webm/bitstream/av1/transfer-characteristics.js +0 -24
- package/dist/boxes/webm/bitstream/av1/uvlc.d.ts +0 -2
- package/dist/boxes/webm/bitstream/av1/uvlc.js +0 -20
- package/dist/boxes/webm/bitstream/av1.d.ts +0 -20
- package/dist/boxes/webm/bitstream/av1.js +0 -118
- package/dist/boxes/webm/bitstream/h264/get-h264-descriptor.d.ts +0 -0
- package/dist/boxes/webm/bitstream/h264/get-h264-descriptor.js +0 -1
- package/dist/boxes/webm/get-track.d.ts +0 -6
- package/dist/boxes/webm/get-track.js +0 -184
- package/dist/boxes/webm/segments/duration.d.ts +0 -6
- package/dist/boxes/webm/segments/duration.js +0 -19
- package/dist/boxes/webm/segments/info.d.ts +0 -9
- package/dist/boxes/webm/segments/info.js +0 -22
- package/dist/boxes/webm/segments/main.d.ts +0 -5
- package/dist/boxes/webm/segments/main.js +0 -2
- package/dist/boxes/webm/segments/muxing.d.ts +0 -6
- package/dist/boxes/webm/segments/muxing.js +0 -11
- package/dist/boxes/webm/segments/seek-head.d.ts +0 -9
- package/dist/boxes/webm/segments/seek-head.js +0 -22
- package/dist/boxes/webm/segments/seek-position.d.ts +0 -6
- package/dist/boxes/webm/segments/seek-position.js +0 -11
- package/dist/boxes/webm/segments/seek.d.ts +0 -13
- package/dist/boxes/webm/segments/seek.js +0 -35
- package/dist/boxes/webm/segments/timestamp-scale.d.ts +0 -6
- package/dist/boxes/webm/segments/timestamp-scale.js +0 -11
- package/dist/boxes/webm/segments/tracks.d.ts +0 -8
- package/dist/boxes/webm/segments/tracks.js +0 -21
- package/dist/boxes/webm/segments/unknown.d.ts +0 -6
- package/dist/boxes/webm/segments/unknown.js +0 -11
- package/dist/boxes/webm/segments/void.d.ts +0 -6
- package/dist/boxes/webm/segments/void.js +0 -11
- package/dist/boxes/webm/segments/writing.d.ts +0 -6
- package/dist/boxes/webm/segments/writing.js +0 -11
- package/dist/boxes/webm/tracks.d.ts +0 -8
- package/dist/boxes/webm/tracks.js +0 -21
- package/dist/combine-uint8array.d.ts +0 -1
- package/dist/combine-uint8array.js +0 -13
- package/dist/create/cues.d.ts +0 -0
- package/dist/create/cues.js +0 -1
- package/dist/from-fetch.d.ts +0 -2
- package/dist/from-fetch.js +0 -64
- package/dist/from-node.d.ts +0 -2
- package/dist/from-node.js +0 -40
- package/dist/from-web-file.d.ts +0 -2
- package/dist/from-web-file.js +0 -39
- package/dist/from-web.d.ts +0 -2
- package/dist/from-web.js +0 -45
- package/dist/get-video-metadata.d.ts +0 -2
- package/dist/get-video-metadata.js +0 -44
- package/dist/read-and-increment-offset.d.ts +0 -28
- package/dist/read-and-increment-offset.js +0 -177
- package/dist/reader.d.ts +0 -11
- package/dist/reader.js +0 -2
- package/dist/traversal.d.ts +0 -65
- package/dist/traversal.js +0 -368
- package/dist/understand-vorbis.d.ts +0 -1
- package/dist/understand-vorbis.js +0 -12
package/dist/traversal.d.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { FtypBox } from './boxes/iso-base-media/ftyp';
|
|
2
|
-
import type { MdhdBox } from './boxes/iso-base-media/mdhd';
|
|
3
|
-
import type { MoovBox } from './boxes/iso-base-media/moov/moov';
|
|
4
|
-
import type { MvhdBox } from './boxes/iso-base-media/mvhd';
|
|
5
|
-
import type { CttsBox } from './boxes/iso-base-media/stsd/ctts';
|
|
6
|
-
import type { StcoBox } from './boxes/iso-base-media/stsd/stco';
|
|
7
|
-
import type { StscBox } from './boxes/iso-base-media/stsd/stsc';
|
|
8
|
-
import type { StsdBox } from './boxes/iso-base-media/stsd/stsd';
|
|
9
|
-
import type { StssBox } from './boxes/iso-base-media/stsd/stss';
|
|
10
|
-
import type { StszBox } from './boxes/iso-base-media/stsd/stsz';
|
|
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';
|
|
14
|
-
import type { TkhdBox } from './boxes/iso-base-media/tkhd';
|
|
15
|
-
import type { TrakBox } from './boxes/iso-base-media/trak/trak';
|
|
16
|
-
import type { TrunBox } from './boxes/iso-base-media/trun';
|
|
17
|
-
import type { AudioSegment, ClusterSegment, CodecIdSegment, DisplayHeightSegment, DisplayWidthSegment, HeightSegment, MainSegment, TimestampScaleSegment, TrackEntry, TrackTypeSegment, VideoSegment, WidthSegment } from './boxes/webm/segments/all-segments';
|
|
18
|
-
import type { AnySegment, IsoBaseMediaBox, RegularBox } from './parse-result';
|
|
19
|
-
export declare const getFtypBox: (segments: AnySegment[]) => FtypBox | null;
|
|
20
|
-
export declare const getMoovBox: (segments: AnySegment[]) => MoovBox | null;
|
|
21
|
-
export declare const getMoofBox: (main: AnySegment[]) => IsoBaseMediaBox | null;
|
|
22
|
-
export declare const getMvhdBox: (moovBox: MoovBox) => MvhdBox | null;
|
|
23
|
-
export declare const getTraks: (moovBox: MoovBox) => TrakBox[];
|
|
24
|
-
export declare const getTkhdBox: (trakBox: TrakBox) => TkhdBox | null;
|
|
25
|
-
export declare const getMdiaBox: (trakBox: TrakBox) => RegularBox | null;
|
|
26
|
-
export declare const getMdhdBox: (trakBox: TrakBox) => MdhdBox | null;
|
|
27
|
-
export declare const getStblBox: (trakBox: TrakBox) => RegularBox | null;
|
|
28
|
-
export declare const getStsdBox: (trakBox: TrakBox) => StsdBox | null;
|
|
29
|
-
export declare const getVideoDescriptors: (trakBox: TrakBox) => Uint8Array | null;
|
|
30
|
-
export declare const getStcoBox: (trakBox: TrakBox) => StcoBox | null;
|
|
31
|
-
export declare const getSttsBox: (trakBox: TrakBox) => SttsBox | null;
|
|
32
|
-
export declare const getCttsBox: (trakBox: TrakBox) => CttsBox | null;
|
|
33
|
-
export declare const getStszBox: (trakBox: TrakBox) => StszBox | null;
|
|
34
|
-
export declare const getStscBox: (trakBox: TrakBox) => StscBox | null;
|
|
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[];
|
|
39
|
-
export declare const getClusterSegment: (segment: MainSegment) => ClusterSegment | null;
|
|
40
|
-
export declare const getTracksSegment: (segment: MainSegment) => {
|
|
41
|
-
type: "Tracks";
|
|
42
|
-
value: import("./boxes/webm/segments/all-segments").PossibleEbml[];
|
|
43
|
-
minVintWidth: number | null;
|
|
44
|
-
} | null;
|
|
45
|
-
export declare const getTimescaleSegment: (segment: MainSegment) => TimestampScaleSegment | null;
|
|
46
|
-
export declare const getVideoSegment: (track: TrackEntry) => VideoSegment | null;
|
|
47
|
-
export declare const getAudioSegment: (track: TrackEntry) => AudioSegment | null;
|
|
48
|
-
export declare const getSampleRate: (track: TrackEntry) => number | null;
|
|
49
|
-
export declare const getNumberOfChannels: (track: TrackEntry) => number;
|
|
50
|
-
export declare const getBitDepth: (track: TrackEntry) => number | null;
|
|
51
|
-
export declare const getPrivateData: (track: TrackEntry) => Uint8Array | null;
|
|
52
|
-
export declare const getWidthSegment: (track: TrackEntry) => WidthSegment | null;
|
|
53
|
-
export declare const getHeightSegment: (track: TrackEntry) => HeightSegment | null;
|
|
54
|
-
export declare const getDisplayWidthSegment: (track: TrackEntry) => DisplayWidthSegment | null;
|
|
55
|
-
export declare const getDisplayHeightSegment: (track: TrackEntry) => DisplayHeightSegment | null;
|
|
56
|
-
export declare const getTrackTypeSegment: (track: TrackEntry) => TrackTypeSegment | null;
|
|
57
|
-
export declare const getTrackId: (track: TrackEntry) => number;
|
|
58
|
-
export declare const getCodecSegment: (track: TrackEntry) => CodecIdSegment | null;
|
|
59
|
-
export declare const hasSkippedMdatProcessing: (anySegment: AnySegment[]) => {
|
|
60
|
-
skipped: false;
|
|
61
|
-
fileOffset?: undefined;
|
|
62
|
-
} | {
|
|
63
|
-
skipped: boolean;
|
|
64
|
-
fileOffset: number;
|
|
65
|
-
};
|
package/dist/traversal.js
DELETED
|
@@ -1,368 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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.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
|
-
const getFtypBox = (segments) => {
|
|
5
|
-
const ftypBox = segments.find((s) => s.type === 'ftyp-box');
|
|
6
|
-
if (!ftypBox || ftypBox.type !== 'ftyp-box') {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
return ftypBox;
|
|
10
|
-
};
|
|
11
|
-
exports.getFtypBox = getFtypBox;
|
|
12
|
-
const getMoovBox = (segments) => {
|
|
13
|
-
const moovBox = segments.find((s) => s.type === 'moov-box');
|
|
14
|
-
if (!moovBox || moovBox.type !== 'moov-box') {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
return moovBox;
|
|
18
|
-
};
|
|
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;
|
|
28
|
-
const getMvhdBox = (moovBox) => {
|
|
29
|
-
const mvHdBox = moovBox.children.find((s) => s.type === 'mvhd-box');
|
|
30
|
-
if (!mvHdBox || mvHdBox.type !== 'mvhd-box') {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
return mvHdBox;
|
|
34
|
-
};
|
|
35
|
-
exports.getMvhdBox = getMvhdBox;
|
|
36
|
-
const getTraks = (moovBox) => {
|
|
37
|
-
return moovBox.children.filter((s) => s.type === 'trak-box');
|
|
38
|
-
};
|
|
39
|
-
exports.getTraks = getTraks;
|
|
40
|
-
const getTkhdBox = (trakBox) => {
|
|
41
|
-
const tkhdBox = trakBox.children.find((s) => s.type === 'tkhd-box');
|
|
42
|
-
return tkhdBox;
|
|
43
|
-
};
|
|
44
|
-
exports.getTkhdBox = getTkhdBox;
|
|
45
|
-
const getMdiaBox = (trakBox) => {
|
|
46
|
-
const mdiaBox = trakBox.children.find((s) => s.type === 'regular-box' && s.boxType === 'mdia');
|
|
47
|
-
if (!mdiaBox || mdiaBox.type !== 'regular-box') {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
return mdiaBox;
|
|
51
|
-
};
|
|
52
|
-
exports.getMdiaBox = getMdiaBox;
|
|
53
|
-
const getMdhdBox = (trakBox) => {
|
|
54
|
-
const mdiaBox = (0, exports.getMdiaBox)(trakBox);
|
|
55
|
-
if (!mdiaBox) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
const mdhdBox = mdiaBox.children.find((c) => c.type === 'mdhd-box');
|
|
59
|
-
return mdhdBox;
|
|
60
|
-
};
|
|
61
|
-
exports.getMdhdBox = getMdhdBox;
|
|
62
|
-
const getStblBox = (trakBox) => {
|
|
63
|
-
const mdiaBox = (0, exports.getMdiaBox)(trakBox);
|
|
64
|
-
if (!mdiaBox) {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
const minfBox = mdiaBox.children.find((s) => s.type === 'regular-box' && s.boxType === 'minf');
|
|
68
|
-
if (!minfBox || minfBox.type !== 'regular-box') {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
const stblBox = minfBox.children.find((s) => s.type === 'regular-box' && s.boxType === 'stbl');
|
|
72
|
-
if (!stblBox || stblBox.type !== 'regular-box') {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
return stblBox;
|
|
76
|
-
};
|
|
77
|
-
exports.getStblBox = getStblBox;
|
|
78
|
-
const getStsdBox = (trakBox) => {
|
|
79
|
-
const stblBox = (0, exports.getStblBox)(trakBox);
|
|
80
|
-
if (!stblBox || stblBox.type !== 'regular-box') {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
const stsdBox = stblBox.children.find((s) => s.type === 'stsd-box');
|
|
84
|
-
return stsdBox;
|
|
85
|
-
};
|
|
86
|
-
exports.getStsdBox = getStsdBox;
|
|
87
|
-
const getVideoDescriptors = (trakBox) => {
|
|
88
|
-
var _a;
|
|
89
|
-
const stsdBox = (0, exports.getStsdBox)(trakBox);
|
|
90
|
-
if (!stsdBox) {
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
const descriptors = stsdBox.samples.map((s) => {
|
|
94
|
-
return s.type === 'video'
|
|
95
|
-
? s.descriptors.map((d) => {
|
|
96
|
-
return d.type === 'avcc-box'
|
|
97
|
-
? d.description
|
|
98
|
-
: d.type === 'hvcc-box'
|
|
99
|
-
? d.data
|
|
100
|
-
: null;
|
|
101
|
-
})
|
|
102
|
-
: [];
|
|
103
|
-
});
|
|
104
|
-
return (_a = descriptors.flat(1).filter(Boolean)[0]) !== null && _a !== void 0 ? _a : null;
|
|
105
|
-
};
|
|
106
|
-
exports.getVideoDescriptors = getVideoDescriptors;
|
|
107
|
-
const getStcoBox = (trakBox) => {
|
|
108
|
-
const stblBox = (0, exports.getStblBox)(trakBox);
|
|
109
|
-
if (!stblBox || stblBox.type !== 'regular-box') {
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
const stcoBox = stblBox.children.find((s) => s.type === 'stco-box');
|
|
113
|
-
return stcoBox;
|
|
114
|
-
};
|
|
115
|
-
exports.getStcoBox = getStcoBox;
|
|
116
|
-
const getSttsBox = (trakBox) => {
|
|
117
|
-
const stblBox = (0, exports.getStblBox)(trakBox);
|
|
118
|
-
if (!stblBox || stblBox.type !== 'regular-box') {
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
const sttsBox = stblBox.children.find((s) => s.type === 'stts-box');
|
|
122
|
-
return sttsBox;
|
|
123
|
-
};
|
|
124
|
-
exports.getSttsBox = getSttsBox;
|
|
125
|
-
const getCttsBox = (trakBox) => {
|
|
126
|
-
const stblBox = (0, exports.getStblBox)(trakBox);
|
|
127
|
-
if (!stblBox || stblBox.type !== 'regular-box') {
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
const cttsBox = stblBox.children.find((s) => s.type === 'ctts-box');
|
|
131
|
-
return cttsBox;
|
|
132
|
-
};
|
|
133
|
-
exports.getCttsBox = getCttsBox;
|
|
134
|
-
const getStszBox = (trakBox) => {
|
|
135
|
-
const stblBox = (0, exports.getStblBox)(trakBox);
|
|
136
|
-
if (!stblBox || stblBox.type !== 'regular-box') {
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
const stszBox = stblBox.children.find((s) => s.type === 'stsz-box');
|
|
140
|
-
return stszBox;
|
|
141
|
-
};
|
|
142
|
-
exports.getStszBox = getStszBox;
|
|
143
|
-
const getStscBox = (trakBox) => {
|
|
144
|
-
const stblBox = (0, exports.getStblBox)(trakBox);
|
|
145
|
-
if (!stblBox || stblBox.type !== 'regular-box') {
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
148
|
-
const stcoBox = stblBox.children.find((b) => b.type === 'stsc-box');
|
|
149
|
-
return stcoBox;
|
|
150
|
-
};
|
|
151
|
-
exports.getStscBox = getStscBox;
|
|
152
|
-
const getStssBox = (trakBox) => {
|
|
153
|
-
const stblBox = (0, exports.getStblBox)(trakBox);
|
|
154
|
-
if (!stblBox || stblBox.type !== 'regular-box') {
|
|
155
|
-
return null;
|
|
156
|
-
}
|
|
157
|
-
const stssBox = stblBox.children.find((b) => b.type === 'stss-box');
|
|
158
|
-
return stssBox;
|
|
159
|
-
};
|
|
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;
|
|
191
|
-
const getClusterSegment = (segment) => {
|
|
192
|
-
const clusterSegment = segment.value.find((b) => b.type === 'Cluster');
|
|
193
|
-
return clusterSegment !== null && clusterSegment !== void 0 ? clusterSegment : null;
|
|
194
|
-
};
|
|
195
|
-
exports.getClusterSegment = getClusterSegment;
|
|
196
|
-
const getTracksSegment = (segment) => {
|
|
197
|
-
const tracksSegment = segment.value.find((b) => b.type === 'Tracks');
|
|
198
|
-
if (!tracksSegment || tracksSegment.type !== 'Tracks') {
|
|
199
|
-
return null;
|
|
200
|
-
}
|
|
201
|
-
return tracksSegment;
|
|
202
|
-
};
|
|
203
|
-
exports.getTracksSegment = getTracksSegment;
|
|
204
|
-
const getTimescaleSegment = (segment) => {
|
|
205
|
-
const infoSegment = segment.value.find((b) => b.type === 'Info');
|
|
206
|
-
if (!infoSegment || infoSegment.type !== 'Info') {
|
|
207
|
-
return null;
|
|
208
|
-
}
|
|
209
|
-
const timescale = infoSegment.value.find((b) => b.type === 'TimestampScale');
|
|
210
|
-
if (!timescale || timescale.type !== 'TimestampScale') {
|
|
211
|
-
return null;
|
|
212
|
-
}
|
|
213
|
-
return timescale;
|
|
214
|
-
};
|
|
215
|
-
exports.getTimescaleSegment = getTimescaleSegment;
|
|
216
|
-
const getVideoSegment = (track) => {
|
|
217
|
-
const videoSegment = track.value.find((b) => b.type === 'Video');
|
|
218
|
-
if (!videoSegment || videoSegment.type !== 'Video') {
|
|
219
|
-
return null;
|
|
220
|
-
}
|
|
221
|
-
return videoSegment !== null && videoSegment !== void 0 ? videoSegment : null;
|
|
222
|
-
};
|
|
223
|
-
exports.getVideoSegment = getVideoSegment;
|
|
224
|
-
const getAudioSegment = (track) => {
|
|
225
|
-
const audioSegment = track.value.find((b) => b.type === 'Audio');
|
|
226
|
-
if (!audioSegment || audioSegment.type !== 'Audio') {
|
|
227
|
-
return null;
|
|
228
|
-
}
|
|
229
|
-
return audioSegment !== null && audioSegment !== void 0 ? audioSegment : null;
|
|
230
|
-
};
|
|
231
|
-
exports.getAudioSegment = getAudioSegment;
|
|
232
|
-
const getSampleRate = (track) => {
|
|
233
|
-
const audioSegment = (0, exports.getAudioSegment)(track);
|
|
234
|
-
if (!audioSegment) {
|
|
235
|
-
return null;
|
|
236
|
-
}
|
|
237
|
-
const samplingFrequency = audioSegment.value.find((b) => b.type === 'SamplingFrequency');
|
|
238
|
-
if (!samplingFrequency || samplingFrequency.type !== 'SamplingFrequency') {
|
|
239
|
-
return null;
|
|
240
|
-
}
|
|
241
|
-
return samplingFrequency.value.value;
|
|
242
|
-
};
|
|
243
|
-
exports.getSampleRate = getSampleRate;
|
|
244
|
-
const getNumberOfChannels = (track) => {
|
|
245
|
-
const audioSegment = (0, exports.getAudioSegment)(track);
|
|
246
|
-
if (!audioSegment) {
|
|
247
|
-
throw new Error('Could not find audio segment');
|
|
248
|
-
}
|
|
249
|
-
const channels = audioSegment.value.find((b) => b.type === 'Channels');
|
|
250
|
-
if (!channels || channels.type !== 'Channels') {
|
|
251
|
-
return 1;
|
|
252
|
-
}
|
|
253
|
-
return channels.value.value;
|
|
254
|
-
};
|
|
255
|
-
exports.getNumberOfChannels = getNumberOfChannels;
|
|
256
|
-
const getBitDepth = (track) => {
|
|
257
|
-
const audioSegment = (0, exports.getAudioSegment)(track);
|
|
258
|
-
if (!audioSegment) {
|
|
259
|
-
return null;
|
|
260
|
-
}
|
|
261
|
-
const bitDepth = audioSegment.value.find((b) => b.type === 'BitDepth');
|
|
262
|
-
if (!bitDepth || bitDepth.type !== 'BitDepth') {
|
|
263
|
-
return null;
|
|
264
|
-
}
|
|
265
|
-
return bitDepth.value.value;
|
|
266
|
-
};
|
|
267
|
-
exports.getBitDepth = getBitDepth;
|
|
268
|
-
const getPrivateData = (track) => {
|
|
269
|
-
const privateData = track.value.find((b) => b.type === 'CodecPrivate');
|
|
270
|
-
if (!privateData || privateData.type !== 'CodecPrivate') {
|
|
271
|
-
return null;
|
|
272
|
-
}
|
|
273
|
-
return privateData.value;
|
|
274
|
-
};
|
|
275
|
-
exports.getPrivateData = getPrivateData;
|
|
276
|
-
const getWidthSegment = (track) => {
|
|
277
|
-
const videoSegment = (0, exports.getVideoSegment)(track);
|
|
278
|
-
if (!videoSegment) {
|
|
279
|
-
return null;
|
|
280
|
-
}
|
|
281
|
-
const width = videoSegment.value.find((b) => b.type === 'PixelWidth');
|
|
282
|
-
if (!width || width.type !== 'PixelWidth') {
|
|
283
|
-
return null;
|
|
284
|
-
}
|
|
285
|
-
return width;
|
|
286
|
-
};
|
|
287
|
-
exports.getWidthSegment = getWidthSegment;
|
|
288
|
-
const getHeightSegment = (track) => {
|
|
289
|
-
const videoSegment = (0, exports.getVideoSegment)(track);
|
|
290
|
-
if (!videoSegment) {
|
|
291
|
-
return null;
|
|
292
|
-
}
|
|
293
|
-
const height = videoSegment.value.find((b) => b.type === 'PixelHeight');
|
|
294
|
-
if (!height || height.type !== 'PixelHeight') {
|
|
295
|
-
return null;
|
|
296
|
-
}
|
|
297
|
-
return height;
|
|
298
|
-
};
|
|
299
|
-
exports.getHeightSegment = getHeightSegment;
|
|
300
|
-
const getDisplayWidthSegment = (track) => {
|
|
301
|
-
const videoSegment = (0, exports.getVideoSegment)(track);
|
|
302
|
-
if (!videoSegment) {
|
|
303
|
-
return null;
|
|
304
|
-
}
|
|
305
|
-
const displayWidth = videoSegment.value.find((b) => b.type === 'DisplayWidth');
|
|
306
|
-
if (!displayWidth || displayWidth.type !== 'DisplayWidth') {
|
|
307
|
-
return null;
|
|
308
|
-
}
|
|
309
|
-
return displayWidth;
|
|
310
|
-
};
|
|
311
|
-
exports.getDisplayWidthSegment = getDisplayWidthSegment;
|
|
312
|
-
const getDisplayHeightSegment = (track) => {
|
|
313
|
-
const videoSegment = (0, exports.getVideoSegment)(track);
|
|
314
|
-
if (!videoSegment) {
|
|
315
|
-
return null;
|
|
316
|
-
}
|
|
317
|
-
const displayHeight = videoSegment.value.find((b) => b.type === 'DisplayHeight');
|
|
318
|
-
if (!displayHeight || displayHeight.type !== 'DisplayHeight') {
|
|
319
|
-
return null;
|
|
320
|
-
}
|
|
321
|
-
return displayHeight;
|
|
322
|
-
};
|
|
323
|
-
exports.getDisplayHeightSegment = getDisplayHeightSegment;
|
|
324
|
-
const getTrackTypeSegment = (track) => {
|
|
325
|
-
const trackType = track.value.find((b) => b.type === 'TrackType');
|
|
326
|
-
if (!trackType || trackType.type !== 'TrackType') {
|
|
327
|
-
return null;
|
|
328
|
-
}
|
|
329
|
-
return trackType;
|
|
330
|
-
};
|
|
331
|
-
exports.getTrackTypeSegment = getTrackTypeSegment;
|
|
332
|
-
const getTrackId = (track) => {
|
|
333
|
-
const trackId = track.value.find((b) => b.type === 'TrackNumber');
|
|
334
|
-
if (!trackId || trackId.type !== 'TrackNumber') {
|
|
335
|
-
throw new Error('Expected track number segment');
|
|
336
|
-
}
|
|
337
|
-
return trackId.value.value;
|
|
338
|
-
};
|
|
339
|
-
exports.getTrackId = getTrackId;
|
|
340
|
-
const getCodecSegment = (track) => {
|
|
341
|
-
const codec = track.value.find((b) => b.type === 'CodecID');
|
|
342
|
-
if (!codec || codec.type !== 'CodecID') {
|
|
343
|
-
return null;
|
|
344
|
-
}
|
|
345
|
-
return codec;
|
|
346
|
-
};
|
|
347
|
-
exports.getCodecSegment = getCodecSegment;
|
|
348
|
-
const hasSkippedMdatProcessing = (anySegment) => {
|
|
349
|
-
const mdat = anySegment.find((b) => b.type === 'mdat-box');
|
|
350
|
-
if (!mdat) {
|
|
351
|
-
return {
|
|
352
|
-
skipped: false,
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
|
-
if (mdat.type !== 'mdat-box') {
|
|
356
|
-
throw new Error('Expected mdat-box');
|
|
357
|
-
}
|
|
358
|
-
if (mdat.samplesProcessed) {
|
|
359
|
-
return {
|
|
360
|
-
skipped: false,
|
|
361
|
-
};
|
|
362
|
-
}
|
|
363
|
-
return {
|
|
364
|
-
skipped: true,
|
|
365
|
-
fileOffset: mdat.fileOffset,
|
|
366
|
-
};
|
|
367
|
-
};
|
|
368
|
-
exports.hasSkippedMdatProcessing = hasSkippedMdatProcessing;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
declare const understand: (src: string) => Promise<void>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const understand = async (src) => {
|
|
3
|
-
const content = await Bun.file(src).arrayBuffer();
|
|
4
|
-
const firstBit = new DataView(content).getUint8(0);
|
|
5
|
-
const offset = new DataView(content).getUint8(1);
|
|
6
|
-
const offset2 = new DataView(content).getUint8(2);
|
|
7
|
-
const globalOffset = firstBit + 1;
|
|
8
|
-
const header = new TextDecoder().decode(content.slice(globalOffset, globalOffset + offset));
|
|
9
|
-
const comment = new TextDecoder().decode(content.slice(globalOffset + offset, globalOffset + offset2));
|
|
10
|
-
const rest = new TextDecoder().decode(content.slice(globalOffset + offset2 + offset, globalOffset + offset2 + offset + 50));
|
|
11
|
-
console.log({ firstBit, offset, offset2, header, comment, rest });
|
|
12
|
-
};
|