@remotion/media-parser 4.0.244 → 4.0.245
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/LICENSE.md +1 -1
- package/dist/boxes/iso-base-media/mdat/mdat.js +17 -5
- package/dist/boxes/iso-base-media/process-box.js +0 -3
- package/dist/boxes/transport-stream/adts-header.d.ts +1 -1
- package/dist/boxes/transport-stream/discard-rest-of-packet.d.ts +1 -1
- package/dist/boxes/webm/ebml.d.ts +1 -1
- package/dist/boxes/webm/make-header.d.ts +3 -3
- package/dist/boxes/webm/segments/all-segments.d.ts +16 -0
- package/dist/boxes/webm/segments/all-segments.js +12 -2
- package/dist/create/iso-base-media/codec-specific/avc1.d.ts +1 -1
- package/dist/create/iso-base-media/codec-specific/create-codec-specific-data.d.ts +1 -1
- package/dist/create/iso-base-media/codec-specific/mp4a.d.ts +1 -1
- package/dist/create/iso-base-media/create-colr.d.ts +1 -1
- package/dist/create/iso-base-media/create-ftyp.d.ts +2 -2
- package/dist/create/iso-base-media/create-ilst.d.ts +1 -1
- package/dist/create/iso-base-media/create-mdia.d.ts +1 -1
- package/dist/create/iso-base-media/create-moov.d.ts +1 -1
- package/dist/create/iso-base-media/create-mvhd.d.ts +1 -1
- package/dist/create/iso-base-media/create-trak.d.ts +1 -1
- package/dist/create/iso-base-media/create-udta.d.ts +1 -1
- package/dist/create/iso-base-media/create-url.d.ts +1 -1
- package/dist/create/iso-base-media/ilst/create-cmt.d.ts +1 -1
- package/dist/create/iso-base-media/ilst/create-too.d.ts +1 -1
- package/dist/create/iso-base-media/mdia/create-mdhd.d.ts +1 -1
- package/dist/create/iso-base-media/mp4-header.d.ts +1 -1
- package/dist/create/iso-base-media/primitives.d.ts +13 -13
- package/dist/create/iso-base-media/serialize-track.d.ts +1 -1
- package/dist/create/iso-base-media/trak/create-tkhd.d.ts +2 -2
- package/dist/create/iso-base-media/trak/mdia/create-minf.d.ts +1 -1
- package/dist/create/iso-base-media/trak/mdia/minf/create-dinf.d.ts +1 -1
- package/dist/create/iso-base-media/trak/mdia/minf/create-smhd.d.ts +1 -1
- package/dist/create/iso-base-media/trak/mdia/minf/create-stbl.d.ts +1 -1
- package/dist/create/iso-base-media/trak/mdia/minf/create-vmhd.d.ts +1 -1
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-ctts.d.ts +1 -1
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stco.d.ts +1 -1
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stsc.d.ts +1 -1
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stss.d.ts +1 -1
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stsz.d.ts +1 -1
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stts.d.ts +1 -1
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/stsd/create-avc1.d.ts +1 -1
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/stsd/create-avcc.d.ts +1 -1
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/stsd/create-pasp.d.ts +1 -1
- package/dist/create/iso-base-media/udta/create-meta.d.ts +1 -1
- package/dist/create/iso-base-media/udta/meta/create-hdlr.d.ts +1 -1
- package/dist/create/matroska/cluster-segment.d.ts +1 -1
- package/dist/emit-available-info.js +1 -11
- package/dist/esm/index.mjs +23 -20
- package/dist/esm/web-fs.mjs +9 -8
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/writers/web-fs.js +9 -8
- package/package.json +3 -3
- package/dist/boxes/avc/codec-private.d.ts +0 -2
- package/dist/boxes/avc/codec-private.js +0 -28
- package/dist/errors/detect-file-type.d.ts +0 -1
- package/dist/errors/detect-file-type.js +0 -88
- package/dist/errors/file-types.d.ts +0 -1
- package/dist/errors/file-types.js +0 -88
- package/dist/file-types/get-jpeg-dimensions.d.ts +0 -4
- package/dist/file-types/get-jpeg-dimensions.js +0 -32
- package/dist/file-types.d.ts +0 -1
- package/dist/file-types.js +0 -88
- package/dist/parser-context.d.ts +0 -10
- package/dist/parser-context.js +0 -2
- package/dist/probing/detect-file-type.d.ts +0 -1
- package/dist/probing/detect-file-type.js +0 -88
- package/dist/probing/get-jpeg-dimensions.d.ts +0 -4
- package/dist/probing/get-jpeg-dimensions.js +0 -32
- package/dist/state/tracks-and-samples.d.ts +0 -0
- package/dist/state/tracks-and-samples.js +0 -1
package/LICENSE.md
CHANGED
|
@@ -77,7 +77,7 @@ const parseMdat = async ({ data, size, fileOffset, existingBoxes, state, signal,
|
|
|
77
77
|
break;
|
|
78
78
|
}
|
|
79
79
|
const bytes = data.getSlice(samplesWithIndex.samplePosition.size);
|
|
80
|
-
const { cts, dts, duration } = samplesWithIndex.samplePosition;
|
|
80
|
+
const { cts, dts, duration, isKeyframe, offset } = samplesWithIndex.samplePosition;
|
|
81
81
|
if (samplesWithIndex.track.type === 'audio') {
|
|
82
82
|
await state.callbacks.onAudioSample(samplesWithIndex.track.trackId, (0, convert_audio_or_video_sample_1.convertAudioOrVideoSampleToWebCodecsTimestamps)({
|
|
83
83
|
data: bytes,
|
|
@@ -86,12 +86,24 @@ const parseMdat = async ({ data, size, fileOffset, existingBoxes, state, signal,
|
|
|
86
86
|
cts,
|
|
87
87
|
dts,
|
|
88
88
|
trackId: samplesWithIndex.track.trackId,
|
|
89
|
-
type:
|
|
90
|
-
offset
|
|
89
|
+
type: isKeyframe ? 'key' : 'delta',
|
|
90
|
+
offset,
|
|
91
91
|
timescale: samplesWithIndex.track.timescale,
|
|
92
92
|
}, samplesWithIndex.track.timescale));
|
|
93
93
|
}
|
|
94
94
|
if (samplesWithIndex.track.type === 'video') {
|
|
95
|
+
// https://remotion-assets.s3.eu-central-1.amazonaws.com/example-videos/sei_checkpoint.mp4
|
|
96
|
+
// Position in file 0x0001aba615
|
|
97
|
+
// https://github.com/remotion-dev/remotion/issues/4680
|
|
98
|
+
// In Chrome, we may not treat recovery points as keyframes
|
|
99
|
+
// otherwise "a keyframe is required after flushing"
|
|
100
|
+
const nalUnitType = bytes[4] & 0b00011111;
|
|
101
|
+
let isRecoveryPoint = false;
|
|
102
|
+
// SEI (Supplemental enhancement information)
|
|
103
|
+
if (nalUnitType === 6) {
|
|
104
|
+
const seiType = bytes[5];
|
|
105
|
+
isRecoveryPoint = seiType === 6;
|
|
106
|
+
}
|
|
95
107
|
await state.callbacks.onVideoSample(samplesWithIndex.track.trackId, (0, convert_audio_or_video_sample_1.convertAudioOrVideoSampleToWebCodecsTimestamps)({
|
|
96
108
|
data: bytes,
|
|
97
109
|
timestamp: cts,
|
|
@@ -99,8 +111,8 @@ const parseMdat = async ({ data, size, fileOffset, existingBoxes, state, signal,
|
|
|
99
111
|
cts,
|
|
100
112
|
dts,
|
|
101
113
|
trackId: samplesWithIndex.track.trackId,
|
|
102
|
-
type:
|
|
103
|
-
offset
|
|
114
|
+
type: isKeyframe && !isRecoveryPoint ? 'key' : 'delta',
|
|
115
|
+
offset,
|
|
104
116
|
timescale: samplesWithIndex.track.timescale,
|
|
105
117
|
}, samplesWithIndex.track.timescale));
|
|
106
118
|
}
|
|
@@ -612,9 +612,6 @@ const parseIsoBaseMediaBoxes = async ({ iterator, maxBytes, allowIncompleteBoxes
|
|
|
612
612
|
initialBoxes = initialBoxes.filter((b) => b.type !== 'mdat-box');
|
|
613
613
|
initialBoxes.push(result.box);
|
|
614
614
|
iterator.allowDiscard();
|
|
615
|
-
if (result.box.status !== 'samples-processed') {
|
|
616
|
-
throw new Error('unexpected');
|
|
617
|
-
}
|
|
618
615
|
break;
|
|
619
616
|
}
|
|
620
617
|
else {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { BufferIterator } from '../../buffer-iterator';
|
|
2
2
|
export declare const discardRestOfPacket: (iterator: BufferIterator) => void;
|
|
3
|
-
export declare const getRestOfPacket: (iterator: BufferIterator) => Uint8Array
|
|
3
|
+
export declare const getRestOfPacket: (iterator: BufferIterator) => Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const measureEBMLVarInt: (value: number) =>
|
|
1
|
+
export declare const measureEBMLVarInt: (value: number) => 2 | 1 | 6 | 5 | 3 | 4;
|
|
2
2
|
export declare const getVariableInt: (value: number, minWidth: number | null) => Uint8Array;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { BytesAndOffset, PossibleEbmlOrUint8Array } from './segments/all-segments';
|
|
2
2
|
import { matroskaElements } from './segments/all-segments';
|
|
3
|
-
export declare const webmPattern: Uint8Array
|
|
4
|
-
export declare const matroskaToHex: (matrId: (typeof matroskaElements)[keyof typeof matroskaElements]) => Uint8Array
|
|
3
|
+
export declare const webmPattern: Uint8Array;
|
|
4
|
+
export declare const matroskaToHex: (matrId: (typeof matroskaElements)[keyof typeof matroskaElements]) => Uint8Array;
|
|
5
5
|
export declare const makeMatroskaBytes: (fields: PossibleEbmlOrUint8Array) => BytesAndOffset;
|
|
6
6
|
export declare const padMatroskaBytes: (fields: PossibleEbmlOrUint8Array, totalLength: number) => BytesAndOffset[];
|
|
7
|
-
export declare const combineUint8Arrays: (arrays: Uint8Array[]) => Uint8Array
|
|
7
|
+
export declare const combineUint8Arrays: (arrays: Uint8Array[]) => Uint8Array;
|
|
8
8
|
export declare function serializeUint16(value: number): Uint8Array;
|
|
@@ -352,6 +352,14 @@ export declare const _name: {
|
|
|
352
352
|
readonly name: "Name";
|
|
353
353
|
readonly type: "string";
|
|
354
354
|
};
|
|
355
|
+
export declare const minCache: {
|
|
356
|
+
readonly name: "MinCache";
|
|
357
|
+
readonly type: "uint";
|
|
358
|
+
};
|
|
359
|
+
export declare const maxCache: {
|
|
360
|
+
readonly name: "MaxCache";
|
|
361
|
+
readonly type: "uint";
|
|
362
|
+
};
|
|
355
363
|
export declare const seekPosition: {
|
|
356
364
|
readonly name: "SeekPosition";
|
|
357
365
|
readonly type: "uint";
|
|
@@ -771,6 +779,14 @@ export declare const ebmlMap: {
|
|
|
771
779
|
readonly name: "Name";
|
|
772
780
|
readonly type: "string";
|
|
773
781
|
};
|
|
782
|
+
readonly "0x6de7": {
|
|
783
|
+
readonly name: "MinCache";
|
|
784
|
+
readonly type: "uint";
|
|
785
|
+
};
|
|
786
|
+
readonly "0x6df8": {
|
|
787
|
+
readonly name: "MaxCache";
|
|
788
|
+
readonly type: "uint";
|
|
789
|
+
};
|
|
774
790
|
readonly "0x53ac": {
|
|
775
791
|
readonly name: "SeekPosition";
|
|
776
792
|
readonly type: "uint";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.incrementOffsetAndChildren = exports.ebmlMap = exports.tagStringType = exports.tagNameType = exports.simpleTagType = exports.targetsType = exports.cluster = exports.segment = exports.blockGroup = exports.simpleBlock = exports.block = exports.timestampEntry = exports.tracks = exports.trackEntry = exports.trackTimestampScale = exports.codecName = exports.blockElement = exports.blockDurationSegment = exports.referenceBlock = exports.flagDefault = exports.videoSegment = exports.audioSegment = exports.maxBlockAdditionIdSegment = exports.blockAdditionsSegment = exports.codecPrivate = exports.defaultDuration = exports.language = void 0;
|
|
3
|
+
exports.range = exports.primaries = exports.matrixCoefficients = exports.transferCharacteristics = exports.color = exports.trackUID = exports.trackNumber = exports.tags = exports.tagSegment = exports.flagLacing = exports.displayHeight = exports.displayWidth = exports.bitDepth = exports.interlaced = exports.alphaMode = exports.channels = exports.samplingFrequency = exports.tagTrackUidType = exports.titleType = exports.infoType = exports.writingApp = exports.timestampScale = exports.duration = exports.muxingApp = exports.heightType = exports.widthType = exports.trackType = exports.codecID = exports.voidHeader = exports.seekHead = exports.seek = exports.seekPosition = exports.maxCache = exports.minCache = exports._name = exports.seekId = exports.matroskaHeader = exports.docTypeReadVersion = exports.docTypeVersion = exports.docType = exports.ebmlMaxSizeLength = exports.ebmlMaxIdLength = exports.ebmlReadVersion = exports.ebmlVersion = exports.getIdForName = exports.getSegmentName = exports.knownIdsWithThreeLength = exports.knownIdsWithTwoLength = exports.knownIdsWithOneLength = exports.matroskaElements = void 0;
|
|
4
|
+
exports.incrementOffsetAndChildren = exports.ebmlMap = exports.tagStringType = exports.tagNameType = exports.simpleTagType = exports.targetsType = exports.cluster = exports.segment = exports.blockGroup = exports.simpleBlock = exports.block = exports.timestampEntry = exports.tracks = exports.trackEntry = exports.trackTimestampScale = exports.codecName = exports.blockElement = exports.blockDurationSegment = exports.referenceBlock = exports.flagDefault = exports.videoSegment = exports.audioSegment = exports.maxBlockAdditionIdSegment = exports.blockAdditionsSegment = exports.codecPrivate = exports.defaultDuration = exports.language = exports.ChromaSitingVert = exports.ChromaSitingHorz = void 0;
|
|
5
5
|
exports.matroskaElements = {
|
|
6
6
|
Header: '0x1a45dfa3',
|
|
7
7
|
EBMLMaxIDLength: '0x42f2',
|
|
@@ -335,6 +335,14 @@ exports._name = {
|
|
|
335
335
|
name: 'Name',
|
|
336
336
|
type: 'string',
|
|
337
337
|
};
|
|
338
|
+
exports.minCache = {
|
|
339
|
+
name: 'MinCache',
|
|
340
|
+
type: 'uint',
|
|
341
|
+
};
|
|
342
|
+
exports.maxCache = {
|
|
343
|
+
name: 'MaxCache',
|
|
344
|
+
type: 'uint',
|
|
345
|
+
};
|
|
338
346
|
exports.seekPosition = {
|
|
339
347
|
name: 'SeekPosition',
|
|
340
348
|
type: 'uint',
|
|
@@ -652,6 +660,8 @@ exports.ebmlMap = {
|
|
|
652
660
|
[exports.matroskaElements.Seek]: exports.seek,
|
|
653
661
|
[exports.matroskaElements.SeekID]: exports.seekId,
|
|
654
662
|
[exports.matroskaElements.Name]: exports._name,
|
|
663
|
+
[exports.matroskaElements.MinCache]: exports.minCache,
|
|
664
|
+
[exports.matroskaElements.MaxCache]: exports.maxCache,
|
|
655
665
|
[exports.matroskaElements.SeekPosition]: exports.seekPosition,
|
|
656
666
|
[exports.matroskaElements.Crc32]: {
|
|
657
667
|
name: 'Crc32',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Avc1Data } from './create-codec-specific-data';
|
|
2
|
-
export declare const createAvc1Data: ({ avccBox, pasp, width, height, horizontalResolution, verticalResolution, compressorName, depth, }: Avc1Data) => Uint8Array
|
|
2
|
+
export declare const createAvc1Data: ({ avccBox, pasp, width, height, horizontalResolution, verticalResolution, compressorName, depth, }: Avc1Data) => Uint8Array;
|
|
@@ -19,4 +19,4 @@ export type Mp4aData = {
|
|
|
19
19
|
codecPrivate: Uint8Array | null;
|
|
20
20
|
};
|
|
21
21
|
export type CodecSpecificData = Avc1Data | Mp4aData;
|
|
22
|
-
export declare const createCodecSpecificData: (track: MakeTrackAudio | MakeTrackVideo) => Uint8Array
|
|
22
|
+
export declare const createCodecSpecificData: (track: MakeTrackAudio | MakeTrackVideo) => Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Mp4aData } from './create-codec-specific-data';
|
|
2
|
-
export declare const createMp4a: ({ sampleRate, channelCount, avgBitrate, maxBitrate, codecPrivate, }: Mp4aData) => Uint8Array
|
|
2
|
+
export declare const createMp4a: ({ sampleRate, channelCount, avgBitrate, maxBitrate, codecPrivate, }: Mp4aData) => Uint8Array;
|
|
@@ -2,9 +2,9 @@ export declare const createFtyp: ({ majorBrand, minorBrand, compatibleBrands, }:
|
|
|
2
2
|
majorBrand: string;
|
|
3
3
|
minorBrand: number;
|
|
4
4
|
compatibleBrands: string[];
|
|
5
|
-
}) => Uint8Array
|
|
5
|
+
}) => Uint8Array;
|
|
6
6
|
export declare const createIsoBaseMediaFtyp: ({ majorBrand, minorBrand, compatibleBrands, }: {
|
|
7
7
|
majorBrand: string;
|
|
8
8
|
minorBrand: number;
|
|
9
9
|
compatibleBrands: string[];
|
|
10
|
-
}) => Uint8Array
|
|
10
|
+
}) => Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const createIlst: (items: Uint8Array[]) => Uint8Array
|
|
1
|
+
export declare const createIlst: (items: Uint8Array[]) => Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const createUdta: (children: Uint8Array) => Uint8Array
|
|
1
|
+
export declare const createUdta: (children: Uint8Array) => Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const createUrlAtom: () => Uint8Array
|
|
1
|
+
export declare const createUrlAtom: () => Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const createCmt: (comment: string) => Uint8Array
|
|
1
|
+
export declare const createCmt: (comment: string) => Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const createToo: (value: string) => Uint8Array
|
|
1
|
+
export declare const createToo: (value: string) => Uint8Array;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { ThreeDMatrix } from '../../boxes/iso-base-media/mvhd';
|
|
2
|
-
export declare const stringsToUint8Array: (str: string) => Uint8Array
|
|
3
|
-
export declare const numberTo32BitUIntOrInt: (num: number) => Uint8Array
|
|
4
|
-
export declare const numberTo32BitUIntOrIntLeading128: (num: number) => Uint8Array
|
|
5
|
-
export declare const numberTo16BitUIntOrInt: (num: number) => Uint8Array
|
|
6
|
-
export declare const setFixedPointSignedOrUnsigned1616Number: (num: number) => Uint8Array
|
|
7
|
-
export declare const setFixedPointSigned230Number: (num: number) => Uint8Array
|
|
8
|
-
export declare const addSize: (arr: Uint8Array) => Uint8Array
|
|
9
|
-
export declare const addLeading128Size: (arr: Uint8Array) => Uint8Array
|
|
10
|
-
export declare const floatTo16Point1632Bit: (number: number) => Uint8Array
|
|
11
|
-
export declare const floatTo16Point16_16Bit: (number: number) => Uint8Array
|
|
12
|
-
export declare const serializeMatrix: (matrix: number[]) => Uint8Array
|
|
13
|
-
export declare const stringToPascalString: (str: string) => Uint8Array
|
|
14
|
-
export declare const padIsoBaseMediaBytes: (data: Uint8Array, totalLength: number) => Uint8Array
|
|
2
|
+
export declare const stringsToUint8Array: (str: string) => Uint8Array;
|
|
3
|
+
export declare const numberTo32BitUIntOrInt: (num: number) => Uint8Array;
|
|
4
|
+
export declare const numberTo32BitUIntOrIntLeading128: (num: number) => Uint8Array;
|
|
5
|
+
export declare const numberTo16BitUIntOrInt: (num: number) => Uint8Array;
|
|
6
|
+
export declare const setFixedPointSignedOrUnsigned1616Number: (num: number) => Uint8Array;
|
|
7
|
+
export declare const setFixedPointSigned230Number: (num: number) => Uint8Array;
|
|
8
|
+
export declare const addSize: (arr: Uint8Array) => Uint8Array;
|
|
9
|
+
export declare const addLeading128Size: (arr: Uint8Array) => Uint8Array;
|
|
10
|
+
export declare const floatTo16Point1632Bit: (number: number) => Uint8Array;
|
|
11
|
+
export declare const floatTo16Point16_16Bit: (number: number) => Uint8Array;
|
|
12
|
+
export declare const serializeMatrix: (matrix: number[]) => Uint8Array;
|
|
13
|
+
export declare const stringToPascalString: (str: string) => Uint8Array;
|
|
14
|
+
export declare const padIsoBaseMediaBytes: (data: Uint8Array, totalLength: number) => Uint8Array;
|
|
15
15
|
export declare const IDENTITY_MATRIX: ThreeDMatrix;
|
|
@@ -6,4 +6,4 @@ export type IsoBaseMediaTrackData = {
|
|
|
6
6
|
samplePositions: SamplePosition[];
|
|
7
7
|
timescale: number;
|
|
8
8
|
};
|
|
9
|
-
export declare const serializeTrack: ({ track, durationInUnits, samplePositions, timescale, }: IsoBaseMediaTrackData) => Uint8Array
|
|
9
|
+
export declare const serializeTrack: ({ track, durationInUnits, samplePositions, timescale, }: IsoBaseMediaTrackData) => Uint8Array;
|
|
@@ -12,7 +12,7 @@ export declare const createTkhdForAudio: ({ creationTime, modificationTime, flag
|
|
|
12
12
|
duration: number;
|
|
13
13
|
volume: number;
|
|
14
14
|
timescale: number;
|
|
15
|
-
}) => Uint8Array
|
|
15
|
+
}) => Uint8Array;
|
|
16
16
|
export declare const createTkhdForVideo: ({ creationTime, modificationTime, duration, trackId, volume, matrix, width, height, flags, timescale, }: {
|
|
17
17
|
creationTime: number | null;
|
|
18
18
|
modificationTime: number | null;
|
|
@@ -24,4 +24,4 @@ export declare const createTkhdForVideo: ({ creationTime, modificationTime, dura
|
|
|
24
24
|
height: number;
|
|
25
25
|
flags: number;
|
|
26
26
|
timescale: number;
|
|
27
|
-
}) => Uint8Array
|
|
27
|
+
}) => Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const createDinf: () => Uint8Array
|
|
1
|
+
export declare const createDinf: () => Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const createSmhd: () => Uint8Array
|
|
1
|
+
export declare const createSmhd: () => Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const createVmhd: () => Uint8Array
|
|
1
|
+
export declare const createVmhd: () => Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { SamplePosition } from '../../../../../../get-sample-positions';
|
|
2
|
-
export declare const createCttsBox: (samplePositions: SamplePosition[]) => Uint8Array
|
|
2
|
+
export declare const createCttsBox: (samplePositions: SamplePosition[]) => Uint8Array | null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { SamplePosition } from '../../../../../../get-sample-positions';
|
|
2
|
-
export declare const createStcoAtom: (samplePositions: SamplePosition[]) => Uint8Array
|
|
2
|
+
export declare const createStcoAtom: (samplePositions: SamplePosition[]) => Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { SamplePosition } from '../../../../../../get-sample-positions';
|
|
2
|
-
export declare const createStsc: (samplePositions: SamplePosition[]) => Uint8Array
|
|
2
|
+
export declare const createStsc: (samplePositions: SamplePosition[]) => Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { SamplePosition } from '../../../../../../get-sample-positions';
|
|
2
|
-
export declare const createStss: (samplePositions: SamplePosition[]) => Uint8Array
|
|
2
|
+
export declare const createStss: (samplePositions: SamplePosition[]) => Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { SamplePosition } from '../../../../../../get-sample-positions';
|
|
2
|
-
export declare const createStsz: (samplePositions: SamplePosition[]) => Uint8Array
|
|
2
|
+
export declare const createStsz: (samplePositions: SamplePosition[]) => Uint8Array;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { SamplePosition } from '../../../../../../get-sample-positions';
|
|
2
|
-
export declare const createSttsAtom: (samplePositions: SamplePosition[]) => Uint8Array
|
|
2
|
+
export declare const createSttsAtom: (samplePositions: SamplePosition[]) => Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const createStsdData: (codecSpecificData: Uint8Array) => Uint8Array
|
|
1
|
+
export declare const createStsdData: (codecSpecificData: Uint8Array) => Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const createAvccBox: (privateData: Uint8Array | null) => Uint8Array
|
|
1
|
+
export declare const createAvccBox: (privateData: Uint8Array | null) => Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const createPasp: (x: number, y: number) => Uint8Array
|
|
1
|
+
export declare const createPasp: (x: number, y: number) => Uint8Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const createHdlr: (type: "video" | "audio" | "mdir") => Uint8Array
|
|
1
|
+
export declare const createHdlr: (type: "video" | "audio" | "mdir") => Uint8Array;
|
|
@@ -41,16 +41,6 @@ const emitAvailableInfo = ({ hasInfo, parseResult, callbacks, state, returnValue
|
|
|
41
41
|
}
|
|
42
42
|
emittedFields.durationInSeconds = true;
|
|
43
43
|
}
|
|
44
|
-
if (!emittedFields.slowDurationInSeconds) {
|
|
45
|
-
const durationInSeconds = (0, get_duration_1.getDuration)(segments, state);
|
|
46
|
-
if (durationInSeconds !== null) {
|
|
47
|
-
(_c = callbacks.onSlowDurationInSeconds) === null || _c === void 0 ? void 0 : _c.call(callbacks, durationInSeconds);
|
|
48
|
-
if (fieldsInReturnValue.slowDurationInSeconds) {
|
|
49
|
-
returnValue.slowDurationInSeconds = durationInSeconds;
|
|
50
|
-
}
|
|
51
|
-
emittedFields.slowDurationInSeconds = true;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
44
|
}
|
|
55
45
|
continue;
|
|
56
46
|
}
|
|
@@ -59,7 +49,7 @@ const emitAvailableInfo = ({ hasInfo, parseResult, callbacks, state, returnValue
|
|
|
59
49
|
!emittedFields.slowDurationInSeconds &&
|
|
60
50
|
parseResult &&
|
|
61
51
|
segments) {
|
|
62
|
-
const slowDurationInSeconds = state.slowDurationAndFps.getSlowDurationInSeconds();
|
|
52
|
+
const slowDurationInSeconds = (_c = (0, get_duration_1.getDuration)(segments, state)) !== null && _c !== void 0 ? _c : state.slowDurationAndFps.getSlowDurationInSeconds();
|
|
63
53
|
(_d = callbacks.onSlowDurationInSeconds) === null || _d === void 0 ? void 0 : _d.call(callbacks, slowDurationInSeconds);
|
|
64
54
|
if (fieldsInReturnValue.slowDurationInSeconds) {
|
|
65
55
|
returnValue.slowDurationInSeconds = slowDurationInSeconds;
|
package/dist/esm/index.mjs
CHANGED
|
@@ -667,6 +667,14 @@ var _name = {
|
|
|
667
667
|
name: "Name",
|
|
668
668
|
type: "string"
|
|
669
669
|
};
|
|
670
|
+
var minCache = {
|
|
671
|
+
name: "MinCache",
|
|
672
|
+
type: "uint"
|
|
673
|
+
};
|
|
674
|
+
var maxCache = {
|
|
675
|
+
name: "MaxCache",
|
|
676
|
+
type: "uint"
|
|
677
|
+
};
|
|
670
678
|
var seekPosition = {
|
|
671
679
|
name: "SeekPosition",
|
|
672
680
|
type: "uint"
|
|
@@ -956,6 +964,8 @@ var ebmlMap = {
|
|
|
956
964
|
[matroskaElements.Seek]: seek,
|
|
957
965
|
[matroskaElements.SeekID]: seekId,
|
|
958
966
|
[matroskaElements.Name]: _name,
|
|
967
|
+
[matroskaElements.MinCache]: minCache,
|
|
968
|
+
[matroskaElements.MaxCache]: maxCache,
|
|
959
969
|
[matroskaElements.SeekPosition]: seekPosition,
|
|
960
970
|
[matroskaElements.Crc32]: {
|
|
961
971
|
name: "Crc32",
|
|
@@ -1377,7 +1387,7 @@ var createIsoBaseMediaFtyp = ({
|
|
|
1377
1387
|
};
|
|
1378
1388
|
|
|
1379
1389
|
// src/version.ts
|
|
1380
|
-
var VERSION = "4.0.
|
|
1390
|
+
var VERSION = "4.0.245";
|
|
1381
1391
|
|
|
1382
1392
|
// src/create/iso-base-media/create-ilst.ts
|
|
1383
1393
|
var createIlst = (items) => {
|
|
@@ -6621,22 +6631,12 @@ var emitAvailableInfo = ({
|
|
|
6621
6631
|
}
|
|
6622
6632
|
emittedFields.durationInSeconds = true;
|
|
6623
6633
|
}
|
|
6624
|
-
if (!emittedFields.slowDurationInSeconds) {
|
|
6625
|
-
const durationInSeconds = getDuration(segments, state);
|
|
6626
|
-
if (durationInSeconds !== null) {
|
|
6627
|
-
callbacks.onSlowDurationInSeconds?.(durationInSeconds);
|
|
6628
|
-
if (fieldsInReturnValue.slowDurationInSeconds) {
|
|
6629
|
-
returnValue.slowDurationInSeconds = durationInSeconds;
|
|
6630
|
-
}
|
|
6631
|
-
emittedFields.slowDurationInSeconds = true;
|
|
6632
|
-
}
|
|
6633
|
-
}
|
|
6634
6634
|
}
|
|
6635
6635
|
continue;
|
|
6636
6636
|
}
|
|
6637
6637
|
if (key === "slowDurationInSeconds") {
|
|
6638
6638
|
if (hasInfo.slowDurationInSeconds && !emittedFields.slowDurationInSeconds && parseResult && segments) {
|
|
6639
|
-
const slowDurationInSeconds = state.slowDurationAndFps.getSlowDurationInSeconds();
|
|
6639
|
+
const slowDurationInSeconds = getDuration(segments, state) ?? state.slowDurationAndFps.getSlowDurationInSeconds();
|
|
6640
6640
|
callbacks.onSlowDurationInSeconds?.(slowDurationInSeconds);
|
|
6641
6641
|
if (fieldsInReturnValue.slowDurationInSeconds) {
|
|
6642
6642
|
returnValue.slowDurationInSeconds = slowDurationInSeconds;
|
|
@@ -7315,7 +7315,7 @@ var parseMdat = async ({
|
|
|
7315
7315
|
break;
|
|
7316
7316
|
}
|
|
7317
7317
|
const bytes = data.getSlice(samplesWithIndex.samplePosition.size);
|
|
7318
|
-
const { cts, dts, duration: duration2 } = samplesWithIndex.samplePosition;
|
|
7318
|
+
const { cts, dts, duration: duration2, isKeyframe, offset } = samplesWithIndex.samplePosition;
|
|
7319
7319
|
if (samplesWithIndex.track.type === "audio") {
|
|
7320
7320
|
await state.callbacks.onAudioSample(samplesWithIndex.track.trackId, convertAudioOrVideoSampleToWebCodecsTimestamps({
|
|
7321
7321
|
data: bytes,
|
|
@@ -7324,12 +7324,18 @@ var parseMdat = async ({
|
|
|
7324
7324
|
cts,
|
|
7325
7325
|
dts,
|
|
7326
7326
|
trackId: samplesWithIndex.track.trackId,
|
|
7327
|
-
type:
|
|
7328
|
-
offset
|
|
7327
|
+
type: isKeyframe ? "key" : "delta",
|
|
7328
|
+
offset,
|
|
7329
7329
|
timescale: samplesWithIndex.track.timescale
|
|
7330
7330
|
}, samplesWithIndex.track.timescale));
|
|
7331
7331
|
}
|
|
7332
7332
|
if (samplesWithIndex.track.type === "video") {
|
|
7333
|
+
const nalUnitType = bytes[4] & 31;
|
|
7334
|
+
let isRecoveryPoint = false;
|
|
7335
|
+
if (nalUnitType === 6) {
|
|
7336
|
+
const seiType = bytes[5];
|
|
7337
|
+
isRecoveryPoint = seiType === 6;
|
|
7338
|
+
}
|
|
7333
7339
|
await state.callbacks.onVideoSample(samplesWithIndex.track.trackId, convertAudioOrVideoSampleToWebCodecsTimestamps({
|
|
7334
7340
|
data: bytes,
|
|
7335
7341
|
timestamp: cts,
|
|
@@ -7337,8 +7343,8 @@ var parseMdat = async ({
|
|
|
7337
7343
|
cts,
|
|
7338
7344
|
dts,
|
|
7339
7345
|
trackId: samplesWithIndex.track.trackId,
|
|
7340
|
-
type:
|
|
7341
|
-
offset
|
|
7346
|
+
type: isKeyframe && !isRecoveryPoint ? "key" : "delta",
|
|
7347
|
+
offset,
|
|
7342
7348
|
timescale: samplesWithIndex.track.timescale
|
|
7343
7349
|
}, samplesWithIndex.track.timescale));
|
|
7344
7350
|
}
|
|
@@ -9254,9 +9260,6 @@ var parseIsoBaseMediaBoxes = async ({
|
|
|
9254
9260
|
initialBoxes = initialBoxes.filter((b) => b.type !== "mdat-box");
|
|
9255
9261
|
initialBoxes.push(result.box);
|
|
9256
9262
|
iterator.allowDiscard();
|
|
9257
|
-
if (result.box.status !== "samples-processed") {
|
|
9258
|
-
throw new Error("unexpected");
|
|
9259
|
-
}
|
|
9260
9263
|
break;
|
|
9261
9264
|
} else {
|
|
9262
9265
|
initialBoxes.push(result.box);
|
package/dist/esm/web-fs.mjs
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
// src/writers/web-fs.ts
|
|
2
2
|
var createContent = async ({ filename }) => {
|
|
3
3
|
const directoryHandle = await navigator.storage.getDirectory();
|
|
4
|
-
|
|
5
|
-
const
|
|
4
|
+
const actualFilename = `__remotion_mediaparser:${filename}`;
|
|
5
|
+
const remove = async () => {
|
|
6
|
+
await directoryHandle.removeEntry(actualFilename, {
|
|
7
|
+
recursive: true
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
await remove();
|
|
11
|
+
const fileHandle = await directoryHandle.getFileHandle(actualFilename, {
|
|
6
12
|
create: true
|
|
7
13
|
});
|
|
8
14
|
const writable = await fileHandle.createWritable();
|
|
@@ -17,11 +23,6 @@ var createContent = async ({ filename }) => {
|
|
|
17
23
|
await writable.write(data);
|
|
18
24
|
await writable.seek(written);
|
|
19
25
|
};
|
|
20
|
-
const remove = async () => {
|
|
21
|
-
await directoryHandle.removeEntry(filename, {
|
|
22
|
-
recursive: true
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
26
|
const writer = {
|
|
26
27
|
write: (arr) => {
|
|
27
28
|
writPromise = writPromise.then(() => write(arr));
|
|
@@ -32,7 +33,7 @@ var createContent = async ({ filename }) => {
|
|
|
32
33
|
await writable.close();
|
|
33
34
|
} catch {
|
|
34
35
|
}
|
|
35
|
-
const newHandle = await directoryHandle.getFileHandle(
|
|
36
|
+
const newHandle = await directoryHandle.getFileHandle(actualFilename, {
|
|
36
37
|
create: true
|
|
37
38
|
});
|
|
38
39
|
const newFile = await newHandle.getFile();
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "4.0.
|
|
1
|
+
export declare const VERSION = "4.0.245";
|
package/dist/version.js
CHANGED
package/dist/writers/web-fs.js
CHANGED
|
@@ -3,8 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.canUseWebFsWriter = exports.webFsWriter = void 0;
|
|
4
4
|
const createContent = async ({ filename }) => {
|
|
5
5
|
const directoryHandle = await navigator.storage.getDirectory();
|
|
6
|
-
|
|
7
|
-
const
|
|
6
|
+
const actualFilename = `__remotion_mediaparser:${filename}`;
|
|
7
|
+
const remove = async () => {
|
|
8
|
+
await directoryHandle.removeEntry(actualFilename, {
|
|
9
|
+
recursive: true,
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
await remove();
|
|
13
|
+
const fileHandle = await directoryHandle.getFileHandle(actualFilename, {
|
|
8
14
|
create: true,
|
|
9
15
|
});
|
|
10
16
|
const writable = await fileHandle.createWritable();
|
|
@@ -19,11 +25,6 @@ const createContent = async ({ filename }) => {
|
|
|
19
25
|
await writable.write(data);
|
|
20
26
|
await writable.seek(written);
|
|
21
27
|
};
|
|
22
|
-
const remove = async () => {
|
|
23
|
-
await directoryHandle.removeEntry(filename, {
|
|
24
|
-
recursive: true,
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
28
|
const writer = {
|
|
28
29
|
write: (arr) => {
|
|
29
30
|
writPromise = writPromise.then(() => write(arr));
|
|
@@ -36,7 +37,7 @@ const createContent = async ({ filename }) => {
|
|
|
36
37
|
catch (_a) {
|
|
37
38
|
// Ignore, could already be closed
|
|
38
39
|
}
|
|
39
|
-
const newHandle = await directoryHandle.getFileHandle(
|
|
40
|
+
const newHandle = await directoryHandle.getFileHandle(actualFilename, {
|
|
40
41
|
create: true,
|
|
41
42
|
});
|
|
42
43
|
const newFile = await newHandle.getFile();
|
package/package.json
CHANGED
|
@@ -3,14 +3,14 @@
|
|
|
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.245",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"@types/wicg-file-system-access": "2023.10.5",
|
|
11
11
|
"eslint": "9.14.0",
|
|
12
|
-
"@remotion/example-videos": "4.0.
|
|
13
|
-
"@remotion/eslint-config-internal": "4.0.
|
|
12
|
+
"@remotion/example-videos": "4.0.245",
|
|
13
|
+
"@remotion/eslint-config-internal": "4.0.245"
|
|
14
14
|
},
|
|
15
15
|
"publishConfig": {
|
|
16
16
|
"access": "public"
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAvccBoxContent = void 0;
|
|
4
|
-
const make_header_1 = require("../webm/make-header");
|
|
5
|
-
const getAvccBoxContent = (avc1Profile) => {
|
|
6
|
-
return (0, make_header_1.combineUint8Arrays)([
|
|
7
|
-
new Uint8Array([
|
|
8
|
-
// https://gist.github.com/uupaa/8493378ec15f644a3d2b
|
|
9
|
-
1, // version
|
|
10
|
-
avc1Profile.sps.spsData.profile,
|
|
11
|
-
avc1Profile.sps.spsData.compatibility,
|
|
12
|
-
avc1Profile.sps.spsData.level,
|
|
13
|
-
0xff,
|
|
14
|
-
0xe1,
|
|
15
|
-
]),
|
|
16
|
-
// sequence parameter set length
|
|
17
|
-
(0, make_header_1.serializeUint16)(avc1Profile.sps.sps.length),
|
|
18
|
-
// sequence parameter set
|
|
19
|
-
avc1Profile.sps.sps,
|
|
20
|
-
// num of PPS
|
|
21
|
-
new Uint8Array([0x01]),
|
|
22
|
-
// picture parameter set length
|
|
23
|
-
(0, make_header_1.serializeUint16)(avc1Profile.pps.pps.length),
|
|
24
|
-
// PPS
|
|
25
|
-
avc1Profile.pps.pps,
|
|
26
|
-
]);
|
|
27
|
-
};
|
|
28
|
-
exports.getAvccBoxContent = getAvccBoxContent;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const detectFileType: (data: Uint8Array) => "webp" | "riff" | "webm" | "iso-base-media" | "transport-stream" | "mp3" | "gif" | "png" | "bmp" | "jpeg" | "unknown";
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.detectFileType = void 0;
|
|
4
|
-
const make_header_1 = require("../boxes/webm/make-header");
|
|
5
|
-
const matchesPattern = (pattern) => {
|
|
6
|
-
return (data) => {
|
|
7
|
-
return pattern.every((value, index) => data[index] === value);
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
const isRiff = (data) => {
|
|
11
|
-
const riffPattern = new Uint8Array([0x52, 0x49, 0x46, 0x46]);
|
|
12
|
-
return matchesPattern(riffPattern)(data.subarray(0, 4));
|
|
13
|
-
};
|
|
14
|
-
const isWebm = (data) => {
|
|
15
|
-
return matchesPattern(make_header_1.webmPattern)(data.subarray(0, 4));
|
|
16
|
-
};
|
|
17
|
-
const isIsoBaseMedia = (data) => {
|
|
18
|
-
const isoBaseMediaMp4Pattern = new TextEncoder().encode('ftyp');
|
|
19
|
-
return matchesPattern(isoBaseMediaMp4Pattern)(data.subarray(4, 8));
|
|
20
|
-
};
|
|
21
|
-
const isTransportStream = (data) => {
|
|
22
|
-
return data[0] === 0x47 && data[188] === 0x47;
|
|
23
|
-
};
|
|
24
|
-
const isMp3 = (data) => {
|
|
25
|
-
const mpegPattern = new Uint8Array([0xff, 0xf3, 0xe4, 0x64]);
|
|
26
|
-
return matchesPattern(mpegPattern)(data.subarray(0, 4));
|
|
27
|
-
};
|
|
28
|
-
const isGif = (data) => {
|
|
29
|
-
const gifPattern = new Uint8Array([0x47, 0x49, 0x46, 0x38]);
|
|
30
|
-
return matchesPattern(gifPattern)(data.subarray(0, 4));
|
|
31
|
-
};
|
|
32
|
-
const isPng = (data) => {
|
|
33
|
-
const pngPattern = new Uint8Array([0x89, 0x50, 0x4e, 0x47]);
|
|
34
|
-
return matchesPattern(pngPattern)(data.subarray(0, 4));
|
|
35
|
-
};
|
|
36
|
-
const isBmp = (data) => {
|
|
37
|
-
const bmpPattern = new Uint8Array([0x42, 0x4d]);
|
|
38
|
-
return matchesPattern(bmpPattern)(data.subarray(0, 2));
|
|
39
|
-
};
|
|
40
|
-
const isJpeg = (data) => {
|
|
41
|
-
const jpegPattern = new Uint8Array([0xff, 0xd8]);
|
|
42
|
-
const jpeg = matchesPattern(jpegPattern)(data.subarray(0, 2));
|
|
43
|
-
if (!jpeg) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
const width = data[6] * 256 + data[7];
|
|
47
|
-
const height = data[8] * 256 + data[9];
|
|
48
|
-
console.log(width, height);
|
|
49
|
-
return true;
|
|
50
|
-
};
|
|
51
|
-
const isWebp = (data) => {
|
|
52
|
-
const webpPattern = new Uint8Array([0x52, 0x49, 0x46, 0x46]);
|
|
53
|
-
return matchesPattern(webpPattern)(data.subarray(0, 4));
|
|
54
|
-
};
|
|
55
|
-
const detectFileType = (data) => {
|
|
56
|
-
if (isWebp(data)) {
|
|
57
|
-
return 'webp';
|
|
58
|
-
}
|
|
59
|
-
if (isRiff(data)) {
|
|
60
|
-
return 'riff';
|
|
61
|
-
}
|
|
62
|
-
if (isWebm(data)) {
|
|
63
|
-
return 'webm';
|
|
64
|
-
}
|
|
65
|
-
if (isIsoBaseMedia(data)) {
|
|
66
|
-
return 'iso-base-media';
|
|
67
|
-
}
|
|
68
|
-
if (isTransportStream(data)) {
|
|
69
|
-
return 'transport-stream';
|
|
70
|
-
}
|
|
71
|
-
if (isMp3(data)) {
|
|
72
|
-
return 'mp3';
|
|
73
|
-
}
|
|
74
|
-
if (isGif(data)) {
|
|
75
|
-
return 'gif';
|
|
76
|
-
}
|
|
77
|
-
if (isPng(data)) {
|
|
78
|
-
return 'png';
|
|
79
|
-
}
|
|
80
|
-
if (isBmp(data)) {
|
|
81
|
-
return 'bmp';
|
|
82
|
-
}
|
|
83
|
-
if (isJpeg(data)) {
|
|
84
|
-
return 'jpeg';
|
|
85
|
-
}
|
|
86
|
-
return 'unknown';
|
|
87
|
-
};
|
|
88
|
-
exports.detectFileType = detectFileType;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const detectFileType: (data: Uint8Array) => "mp3" | "unknown" | "webm" | "transport-stream" | "iso-base-media" | "riff" | "gif" | "bmp" | "jpeg" | "png" | "webp";
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.detectFileType = void 0;
|
|
4
|
-
const make_header_1 = require("./boxes/webm/make-header");
|
|
5
|
-
const matchesPattern = (pattern) => {
|
|
6
|
-
return (data) => {
|
|
7
|
-
return pattern.every((value, index) => data[index] === value);
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
const isRiff = (data) => {
|
|
11
|
-
const riffPattern = new Uint8Array([0x52, 0x49, 0x46, 0x46]);
|
|
12
|
-
return matchesPattern(riffPattern)(data.subarray(0, 4));
|
|
13
|
-
};
|
|
14
|
-
const isWebm = (data) => {
|
|
15
|
-
return matchesPattern(make_header_1.webmPattern)(data.subarray(0, 4));
|
|
16
|
-
};
|
|
17
|
-
const isIsoBaseMedia = (data) => {
|
|
18
|
-
const isoBaseMediaMp4Pattern = new TextEncoder().encode('ftyp');
|
|
19
|
-
return matchesPattern(isoBaseMediaMp4Pattern)(data.subarray(4, 8));
|
|
20
|
-
};
|
|
21
|
-
const isTransportStream = (data) => {
|
|
22
|
-
return data[0] === 0x47 && data[188] === 0x47;
|
|
23
|
-
};
|
|
24
|
-
const isMp3 = (data) => {
|
|
25
|
-
const mpegPattern = new Uint8Array([0xff, 0xf3, 0xe4, 0x64]);
|
|
26
|
-
return matchesPattern(mpegPattern)(data.subarray(0, 4));
|
|
27
|
-
};
|
|
28
|
-
const isGif = (data) => {
|
|
29
|
-
const gifPattern = new Uint8Array([0x47, 0x49, 0x46, 0x38]);
|
|
30
|
-
return matchesPattern(gifPattern)(data.subarray(0, 4));
|
|
31
|
-
};
|
|
32
|
-
const isPng = (data) => {
|
|
33
|
-
const pngPattern = new Uint8Array([0x89, 0x50, 0x4e, 0x47]);
|
|
34
|
-
return matchesPattern(pngPattern)(data.subarray(0, 4));
|
|
35
|
-
};
|
|
36
|
-
const isBmp = (data) => {
|
|
37
|
-
const bmpPattern = new Uint8Array([0x42, 0x4d]);
|
|
38
|
-
return matchesPattern(bmpPattern)(data.subarray(0, 2));
|
|
39
|
-
};
|
|
40
|
-
const isJpeg = (data) => {
|
|
41
|
-
const jpegPattern = new Uint8Array([0xff, 0xd8]);
|
|
42
|
-
const jpeg = matchesPattern(jpegPattern)(data.subarray(0, 2));
|
|
43
|
-
if (!jpeg) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
const width = data[6] * 256 + data[7];
|
|
47
|
-
const height = data[8] * 256 + data[9];
|
|
48
|
-
console.log(width, height);
|
|
49
|
-
return true;
|
|
50
|
-
};
|
|
51
|
-
const isWebp = (data) => {
|
|
52
|
-
const webpPattern = new Uint8Array([0x52, 0x49, 0x46, 0x46]);
|
|
53
|
-
return matchesPattern(webpPattern)(data.subarray(0, 4));
|
|
54
|
-
};
|
|
55
|
-
const detectFileType = (data) => {
|
|
56
|
-
if (isWebp(data)) {
|
|
57
|
-
return 'webp';
|
|
58
|
-
}
|
|
59
|
-
if (isRiff(data)) {
|
|
60
|
-
return 'riff';
|
|
61
|
-
}
|
|
62
|
-
if (isWebm(data)) {
|
|
63
|
-
return 'webm';
|
|
64
|
-
}
|
|
65
|
-
if (isIsoBaseMedia(data)) {
|
|
66
|
-
return 'iso-base-media';
|
|
67
|
-
}
|
|
68
|
-
if (isTransportStream(data)) {
|
|
69
|
-
return 'transport-stream';
|
|
70
|
-
}
|
|
71
|
-
if (isMp3(data)) {
|
|
72
|
-
return 'mp3';
|
|
73
|
-
}
|
|
74
|
-
if (isGif(data)) {
|
|
75
|
-
return 'gif';
|
|
76
|
-
}
|
|
77
|
-
if (isPng(data)) {
|
|
78
|
-
return 'png';
|
|
79
|
-
}
|
|
80
|
-
if (isBmp(data)) {
|
|
81
|
-
return 'bmp';
|
|
82
|
-
}
|
|
83
|
-
if (isJpeg(data)) {
|
|
84
|
-
return 'jpeg';
|
|
85
|
-
}
|
|
86
|
-
return 'unknown';
|
|
87
|
-
};
|
|
88
|
-
exports.detectFileType = detectFileType;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getJpegDimensions = getJpegDimensions;
|
|
4
|
-
function getJpegDimensions(data) {
|
|
5
|
-
let offset = 0;
|
|
6
|
-
// Helper function to read a 16-bit big-endian integer
|
|
7
|
-
function readUint16BE(o) {
|
|
8
|
-
return (data[o] << 8) | data[o + 1];
|
|
9
|
-
}
|
|
10
|
-
// Skip the Start of Image (SOI) marker
|
|
11
|
-
if (readUint16BE(offset) !== 0xffd8) {
|
|
12
|
-
return null; // Not a valid JPEG file
|
|
13
|
-
}
|
|
14
|
-
offset += 2;
|
|
15
|
-
while (offset < data.length) {
|
|
16
|
-
if (data[offset] === 0xff) {
|
|
17
|
-
const marker = data[offset + 1];
|
|
18
|
-
if (marker === 0xc0 || marker === 0xc2) {
|
|
19
|
-
// SOF0 or SOF2
|
|
20
|
-
const height = readUint16BE(offset + 5);
|
|
21
|
-
const width = readUint16BE(offset + 7);
|
|
22
|
-
return { width, height };
|
|
23
|
-
}
|
|
24
|
-
const length = readUint16BE(offset + 2);
|
|
25
|
-
offset += length + 2; // Move to the next marker
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
offset++;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return null; // Return null if dimensions are not found
|
|
32
|
-
}
|
package/dist/file-types.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const detectFileType: (data: Uint8Array) => "webp" | "riff" | "webm" | "iso-base-media" | "transport-stream" | "mp3" | "gif" | "png" | "bmp" | "jpeg" | "unknown";
|
package/dist/file-types.js
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.detectFileType = void 0;
|
|
4
|
-
const make_header_1 = require("./boxes/webm/make-header");
|
|
5
|
-
const matchesPattern = (pattern) => {
|
|
6
|
-
return (data) => {
|
|
7
|
-
return pattern.every((value, index) => data[index] === value);
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
const isRiff = (data) => {
|
|
11
|
-
const riffPattern = new Uint8Array([0x52, 0x49, 0x46, 0x46]);
|
|
12
|
-
return matchesPattern(riffPattern)(data.subarray(0, 4));
|
|
13
|
-
};
|
|
14
|
-
const isWebm = (data) => {
|
|
15
|
-
return matchesPattern(make_header_1.webmPattern)(data.subarray(0, 4));
|
|
16
|
-
};
|
|
17
|
-
const isIsoBaseMedia = (data) => {
|
|
18
|
-
const isoBaseMediaMp4Pattern = new TextEncoder().encode('ftyp');
|
|
19
|
-
return matchesPattern(isoBaseMediaMp4Pattern)(data.subarray(4, 8));
|
|
20
|
-
};
|
|
21
|
-
const isTransportStream = (data) => {
|
|
22
|
-
return data[0] === 0x47 && data[188] === 0x47;
|
|
23
|
-
};
|
|
24
|
-
const isMp3 = (data) => {
|
|
25
|
-
const mpegPattern = new Uint8Array([0xff, 0xf3, 0xe4, 0x64]);
|
|
26
|
-
return matchesPattern(mpegPattern)(data.subarray(0, 4));
|
|
27
|
-
};
|
|
28
|
-
const isGif = (data) => {
|
|
29
|
-
const gifPattern = new Uint8Array([0x47, 0x49, 0x46, 0x38]);
|
|
30
|
-
return matchesPattern(gifPattern)(data.subarray(0, 4));
|
|
31
|
-
};
|
|
32
|
-
const isPng = (data) => {
|
|
33
|
-
const pngPattern = new Uint8Array([0x89, 0x50, 0x4e, 0x47]);
|
|
34
|
-
return matchesPattern(pngPattern)(data.subarray(0, 4));
|
|
35
|
-
};
|
|
36
|
-
const isBmp = (data) => {
|
|
37
|
-
const bmpPattern = new Uint8Array([0x42, 0x4d]);
|
|
38
|
-
return matchesPattern(bmpPattern)(data.subarray(0, 2));
|
|
39
|
-
};
|
|
40
|
-
const isJpeg = (data) => {
|
|
41
|
-
const jpegPattern = new Uint8Array([0xff, 0xd8]);
|
|
42
|
-
const jpeg = matchesPattern(jpegPattern)(data.subarray(0, 2));
|
|
43
|
-
if (!jpeg) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
const width = data[6] * 256 + data[7];
|
|
47
|
-
const height = data[8] * 256 + data[9];
|
|
48
|
-
console.log(width, height);
|
|
49
|
-
return true;
|
|
50
|
-
};
|
|
51
|
-
const isWebp = (data) => {
|
|
52
|
-
const webpPattern = new Uint8Array([0x52, 0x49, 0x46, 0x46]);
|
|
53
|
-
return matchesPattern(webpPattern)(data.subarray(0, 4));
|
|
54
|
-
};
|
|
55
|
-
const detectFileType = (data) => {
|
|
56
|
-
if (isWebp(data)) {
|
|
57
|
-
return 'webp';
|
|
58
|
-
}
|
|
59
|
-
if (isRiff(data)) {
|
|
60
|
-
return 'riff';
|
|
61
|
-
}
|
|
62
|
-
if (isWebm(data)) {
|
|
63
|
-
return 'webm';
|
|
64
|
-
}
|
|
65
|
-
if (isIsoBaseMedia(data)) {
|
|
66
|
-
return 'iso-base-media';
|
|
67
|
-
}
|
|
68
|
-
if (isTransportStream(data)) {
|
|
69
|
-
return 'transport-stream';
|
|
70
|
-
}
|
|
71
|
-
if (isMp3(data)) {
|
|
72
|
-
return 'mp3';
|
|
73
|
-
}
|
|
74
|
-
if (isGif(data)) {
|
|
75
|
-
return 'gif';
|
|
76
|
-
}
|
|
77
|
-
if (isPng(data)) {
|
|
78
|
-
return 'png';
|
|
79
|
-
}
|
|
80
|
-
if (isBmp(data)) {
|
|
81
|
-
return 'bmp';
|
|
82
|
-
}
|
|
83
|
-
if (isJpeg(data)) {
|
|
84
|
-
return 'jpeg';
|
|
85
|
-
}
|
|
86
|
-
return 'unknown';
|
|
87
|
-
};
|
|
88
|
-
exports.detectFileType = detectFileType;
|
package/dist/parser-context.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ParserState } from './state/parser-state';
|
|
2
|
-
import type { OnAudioTrack, OnVideoTrack } from './webcodec-sample-types';
|
|
3
|
-
export type ParserContext = {
|
|
4
|
-
onAudioTrack: OnAudioTrack | null;
|
|
5
|
-
onVideoTrack: OnVideoTrack | null;
|
|
6
|
-
parserState: ParserState;
|
|
7
|
-
nullifySamples: boolean;
|
|
8
|
-
supportsContentRange: boolean;
|
|
9
|
-
nextTrackIndex: number;
|
|
10
|
-
};
|
package/dist/parser-context.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const detectFileType: (data: Uint8Array) => "webp" | "riff" | "webm" | "iso-base-media" | "transport-stream" | "mp3" | "gif" | "png" | "bmp" | "jpeg" | "unknown";
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.detectFileType = void 0;
|
|
4
|
-
const make_header_1 = require("../boxes/webm/make-header");
|
|
5
|
-
const get_jpeg_dimensions_1 = require("./get-jpeg-dimensions");
|
|
6
|
-
const matchesPattern = (pattern) => {
|
|
7
|
-
return (data) => {
|
|
8
|
-
return pattern.every((value, index) => data[index] === value);
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
const isRiff = (data) => {
|
|
12
|
-
const riffPattern = new Uint8Array([0x52, 0x49, 0x46, 0x46]);
|
|
13
|
-
return matchesPattern(riffPattern)(data.subarray(0, 4));
|
|
14
|
-
};
|
|
15
|
-
const isWebm = (data) => {
|
|
16
|
-
return matchesPattern(make_header_1.webmPattern)(data.subarray(0, 4));
|
|
17
|
-
};
|
|
18
|
-
const isIsoBaseMedia = (data) => {
|
|
19
|
-
const isoBaseMediaMp4Pattern = new TextEncoder().encode('ftyp');
|
|
20
|
-
return matchesPattern(isoBaseMediaMp4Pattern)(data.subarray(4, 8));
|
|
21
|
-
};
|
|
22
|
-
const isTransportStream = (data) => {
|
|
23
|
-
return data[0] === 0x47 && data[188] === 0x47;
|
|
24
|
-
};
|
|
25
|
-
const isMp3 = (data) => {
|
|
26
|
-
const mpegPattern = new Uint8Array([0xff, 0xf3, 0xe4, 0x64]);
|
|
27
|
-
return matchesPattern(mpegPattern)(data.subarray(0, 4));
|
|
28
|
-
};
|
|
29
|
-
const isGif = (data) => {
|
|
30
|
-
const gifPattern = new Uint8Array([0x47, 0x49, 0x46, 0x38]);
|
|
31
|
-
return matchesPattern(gifPattern)(data.subarray(0, 4));
|
|
32
|
-
};
|
|
33
|
-
const isPng = (data) => {
|
|
34
|
-
const pngPattern = new Uint8Array([0x89, 0x50, 0x4e, 0x47]);
|
|
35
|
-
return matchesPattern(pngPattern)(data.subarray(0, 4));
|
|
36
|
-
};
|
|
37
|
-
const isBmp = (data) => {
|
|
38
|
-
const bmpPattern = new Uint8Array([0x42, 0x4d]);
|
|
39
|
-
return matchesPattern(bmpPattern)(data.subarray(0, 2));
|
|
40
|
-
};
|
|
41
|
-
const isJpeg = (data) => {
|
|
42
|
-
const jpegPattern = new Uint8Array([0xff, 0xd8]);
|
|
43
|
-
const jpeg = matchesPattern(jpegPattern)(data.subarray(0, 2));
|
|
44
|
-
if (!jpeg) {
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
const dim = (0, get_jpeg_dimensions_1.getJpegDimensions)(data);
|
|
48
|
-
console.log(dim);
|
|
49
|
-
return true;
|
|
50
|
-
};
|
|
51
|
-
const isWebp = (data) => {
|
|
52
|
-
const webpPattern = new Uint8Array([0x52, 0x49, 0x46, 0x46]);
|
|
53
|
-
return matchesPattern(webpPattern)(data.subarray(0, 4));
|
|
54
|
-
};
|
|
55
|
-
const detectFileType = (data) => {
|
|
56
|
-
if (isWebp(data)) {
|
|
57
|
-
return 'webp';
|
|
58
|
-
}
|
|
59
|
-
if (isRiff(data)) {
|
|
60
|
-
return 'riff';
|
|
61
|
-
}
|
|
62
|
-
if (isWebm(data)) {
|
|
63
|
-
return 'webm';
|
|
64
|
-
}
|
|
65
|
-
if (isIsoBaseMedia(data)) {
|
|
66
|
-
return 'iso-base-media';
|
|
67
|
-
}
|
|
68
|
-
if (isTransportStream(data)) {
|
|
69
|
-
return 'transport-stream';
|
|
70
|
-
}
|
|
71
|
-
if (isMp3(data)) {
|
|
72
|
-
return 'mp3';
|
|
73
|
-
}
|
|
74
|
-
if (isGif(data)) {
|
|
75
|
-
return 'gif';
|
|
76
|
-
}
|
|
77
|
-
if (isPng(data)) {
|
|
78
|
-
return 'png';
|
|
79
|
-
}
|
|
80
|
-
if (isBmp(data)) {
|
|
81
|
-
return 'bmp';
|
|
82
|
-
}
|
|
83
|
-
if (isJpeg(data)) {
|
|
84
|
-
return 'jpeg';
|
|
85
|
-
}
|
|
86
|
-
return 'unknown';
|
|
87
|
-
};
|
|
88
|
-
exports.detectFileType = detectFileType;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getJpegDimensions = getJpegDimensions;
|
|
4
|
-
function getJpegDimensions(data) {
|
|
5
|
-
let offset = 0;
|
|
6
|
-
// Helper function to read a 16-bit big-endian integer
|
|
7
|
-
function readUint16BE(o) {
|
|
8
|
-
return (data[o] << 8) | data[o + 1];
|
|
9
|
-
}
|
|
10
|
-
// Skip the Start of Image (SOI) marker
|
|
11
|
-
if (readUint16BE(offset) !== 0xffd8) {
|
|
12
|
-
return null; // Not a valid JPEG file
|
|
13
|
-
}
|
|
14
|
-
offset += 2;
|
|
15
|
-
while (offset < data.length) {
|
|
16
|
-
if (data[offset] === 0xff) {
|
|
17
|
-
const marker = data[offset + 1];
|
|
18
|
-
if (marker === 0xc0 || marker === 0xc2) {
|
|
19
|
-
// SOF0 or SOF2
|
|
20
|
-
const height = readUint16BE(offset + 5);
|
|
21
|
-
const width = readUint16BE(offset + 7);
|
|
22
|
-
return { width, height };
|
|
23
|
-
}
|
|
24
|
-
const length = readUint16BE(offset + 2);
|
|
25
|
-
offset += length + 2; // Move to the next marker
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
offset++;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return null; // Return null if dimensions are not found
|
|
32
|
-
}
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|