@remotion/media-parser 4.0.229 → 4.0.230
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.d.ts +3 -2
- package/dist/boxes/iso-base-media/esds/decoder-specific-config.js +7 -8
- package/dist/boxes/iso-base-media/esds/esds-descriptors.d.ts +4 -2
- package/dist/boxes/iso-base-media/esds/esds-descriptors.js +5 -4
- package/dist/boxes/iso-base-media/esds/esds.d.ts +3 -1
- package/dist/boxes/iso-base-media/esds/esds.js +2 -2
- package/dist/boxes/iso-base-media/make-track.js +2 -1
- package/dist/boxes/iso-base-media/mdat/mdat.js +13 -7
- package/dist/boxes/iso-base-media/moov/moov.d.ts +3 -1
- package/dist/boxes/iso-base-media/moov/moov.js +2 -2
- package/dist/boxes/iso-base-media/mvhd.js +11 -9
- package/dist/boxes/iso-base-media/parse-icc-profile.d.ts +36 -0
- package/dist/boxes/iso-base-media/parse-icc-profile.js +115 -0
- package/dist/boxes/iso-base-media/process-box.d.ts +5 -4
- package/dist/boxes/iso-base-media/process-box.js +17 -14
- package/dist/boxes/iso-base-media/stsd/colr.d.ts +14 -4
- package/dist/boxes/iso-base-media/stsd/colr.js +13 -1
- package/dist/boxes/iso-base-media/stsd/mebx.d.ts +1 -2
- package/dist/boxes/iso-base-media/stsd/mebx.js +2 -2
- package/dist/boxes/iso-base-media/stsd/samples.d.ts +5 -2
- package/dist/boxes/iso-base-media/stsd/samples.js +7 -6
- package/dist/boxes/iso-base-media/stsd/stsd.js +1 -0
- package/dist/boxes/iso-base-media/to-date.d.ts +1 -0
- package/dist/boxes/iso-base-media/to-date.js +9 -1
- package/dist/boxes/iso-base-media/trak/trak.d.ts +3 -1
- package/dist/boxes/iso-base-media/trak/trak.js +2 -2
- package/dist/boxes/webm/av1-codec-private.js +1 -1
- package/dist/boxes/webm/ebml.d.ts +1 -1
- package/dist/boxes/webm/get-sample-from-block.d.ts +4 -4
- package/dist/boxes/webm/get-sample-from-block.js +4 -2
- package/dist/boxes/webm/make-track.js +1 -0
- package/dist/buffer-iterator.d.ts +1 -1
- package/dist/buffer-iterator.js +1 -8
- package/dist/create/iso-base-media/codec-specific/avc1.d.ts +2 -0
- package/dist/create/iso-base-media/codec-specific/avc1.js +48 -0
- package/dist/create/iso-base-media/codec-specific/create-codec-specific-data.d.ts +22 -0
- package/dist/create/iso-base-media/codec-specific/create-codec-specific-data.js +36 -0
- package/dist/create/iso-base-media/codec-specific/mp4a.d.ts +2 -0
- package/dist/create/iso-base-media/codec-specific/mp4a.js +90 -0
- package/dist/create/iso-base-media/create-colr.d.ts +6 -0
- package/dist/create/iso-base-media/create-colr.js +26 -0
- package/dist/create/iso-base-media/create-ftyp.d.ts +10 -0
- package/dist/create/iso-base-media/create-ftyp.js +22 -0
- package/dist/create/iso-base-media/create-ilst.d.ts +1 -0
- package/dist/create/iso-base-media/create-ilst.js +14 -0
- package/dist/create/iso-base-media/create-iso-base-media.d.ts +2 -0
- package/dist/create/iso-base-media/create-iso-base-media.js +168 -0
- package/dist/create/iso-base-media/create-mdia.d.ts +5 -0
- package/dist/create/iso-base-media/create-mdia.js +18 -0
- package/dist/create/iso-base-media/create-moov.d.ts +5 -0
- package/dist/create/iso-base-media/create-moov.js +18 -0
- package/dist/create/iso-base-media/create-mvhd.d.ts +10 -0
- package/dist/create/iso-base-media/create-mvhd.js +48 -0
- package/dist/create/iso-base-media/create-trak.d.ts +4 -0
- package/dist/create/iso-base-media/create-trak.js +17 -0
- package/dist/create/iso-base-media/create-udta.d.ts +1 -0
- package/dist/create/iso-base-media/create-udta.js +14 -0
- package/dist/create/iso-base-media/create-url.d.ts +1 -0
- package/dist/create/iso-base-media/create-url.js +16 -0
- package/dist/create/iso-base-media/example-stts.d.ts +3 -0
- package/dist/create/iso-base-media/example-stts.js +2797 -0
- package/dist/create/iso-base-media/ilst/create-cmt.d.ts +1 -0
- package/dist/create/iso-base-media/ilst/create-cmt.js +26 -0
- package/dist/create/iso-base-media/ilst/create-too.d.ts +1 -0
- package/dist/create/iso-base-media/ilst/create-too.js +27 -0
- package/dist/create/iso-base-media/mdia/create-mdhd.d.ts +6 -0
- package/dist/create/iso-base-media/mdia/create-mdhd.js +33 -0
- package/dist/create/iso-base-media/mp4-header.d.ts +6 -0
- package/dist/create/iso-base-media/mp4-header.js +47 -0
- package/dist/create/iso-base-media/primitives.d.ts +15 -0
- package/dist/create/iso-base-media/primitives.js +133 -0
- package/dist/create/iso-base-media/serialize-track.d.ts +9 -0
- package/dist/create/iso-base-media/serialize-track.js +63 -0
- package/dist/create/iso-base-media/trak/create-tkhd.d.ts +27 -0
- package/dist/create/iso-base-media/trak/create-tkhd.js +97 -0
- package/dist/create/iso-base-media/trak/mdia/create-minf.d.ts +4 -0
- package/dist/create/iso-base-media/trak/mdia/create-minf.js +19 -0
- package/dist/create/iso-base-media/trak/mdia/minf/create-dinf.d.ts +1 -0
- package/dist/create/iso-base-media/trak/mdia/minf/create-dinf.js +22 -0
- package/dist/create/iso-base-media/trak/mdia/minf/create-smhd.d.ts +1 -0
- package/dist/create/iso-base-media/trak/mdia/minf/create-smhd.js +20 -0
- package/dist/create/iso-base-media/trak/mdia/minf/create-stbl.d.ts +6 -0
- package/dist/create/iso-base-media/trak/mdia/minf/create-stbl.js +35 -0
- package/dist/create/iso-base-media/trak/mdia/minf/create-vmhd.d.ts +1 -0
- package/dist/create/iso-base-media/trak/mdia/minf/create-vmhd.js +20 -0
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-ctts.d.ts +2 -0
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-ctts.js +45 -0
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stco.d.ts +2 -0
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stco.js +28 -0
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stsc.d.ts +2 -0
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stsc.js +56 -0
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stss.d.ts +2 -0
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stss.js +23 -0
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stsz.d.ts +2 -0
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stsz.js +25 -0
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stts.d.ts +2 -0
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/create-stts.js +48 -0
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/stsd/create-avc1.d.ts +1 -0
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/stsd/create-avc1.js +20 -0
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/stsd/create-avcc.d.ts +1 -0
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/stsd/create-avcc.js +16 -0
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/stsd/create-pasp.d.ts +1 -0
- package/dist/create/iso-base-media/trak/mdia/minf/stbl/stsd/create-pasp.js +13 -0
- package/dist/create/iso-base-media/udta/create-meta.d.ts +4 -0
- package/dist/create/iso-base-media/udta/create-meta.js +20 -0
- package/dist/create/iso-base-media/udta/meta/create-hdlr.d.ts +1 -0
- package/dist/create/iso-base-media/udta/meta/create-hdlr.js +32 -0
- package/dist/create/make-track-info.d.ts +20 -0
- package/dist/create/make-track-info.js +2 -0
- package/dist/create/{cluster-segment.d.ts → matroska/cluster-segment.d.ts} +1 -1
- package/dist/create/{cluster-segment.js → matroska/cluster-segment.js} +2 -2
- package/dist/create/{cluster.d.ts → matroska/cluster.d.ts} +6 -5
- package/dist/create/{cluster.js → matroska/cluster.js} +16 -16
- package/dist/create/matroska/create-matroska-media.d.ts +2 -0
- package/dist/create/{create-media.js → matroska/create-matroska-media.js} +25 -18
- package/dist/create/matroska/make-duration-with-padding.d.ts +1 -0
- package/dist/create/{make-duration-with-padding.js → matroska/make-duration-with-padding.js} +1 -1
- package/dist/create/{matroska-cues.d.ts → matroska/matroska-cues.d.ts} +1 -1
- package/dist/create/{matroska-cues.js → matroska/matroska-cues.js} +1 -1
- package/dist/create/matroska/matroska-header.d.ts +1 -0
- package/dist/create/{matroska-header.js → matroska/matroska-header.js} +1 -1
- package/dist/create/{matroska-info.d.ts → matroska/matroska-info.d.ts} +1 -1
- package/dist/create/{matroska-info.js → matroska/matroska-info.js} +1 -1
- package/dist/create/matroska/matroska-seek.d.ts +6 -0
- package/dist/create/{matroska-seek.js → matroska/matroska-seek.js} +1 -1
- package/dist/create/{matroska-segment.d.ts → matroska/matroska-segment.d.ts} +1 -1
- package/dist/create/{matroska-segment.js → matroska/matroska-segment.js} +1 -1
- package/dist/create/matroska/matroska-trackentry.d.ts +10 -0
- package/dist/create/{matroska-trackentry.js → matroska/matroska-trackentry.js} +9 -3
- package/dist/create/{create-media.d.ts → media-fn.d.ts} +16 -4
- package/dist/create/media-fn.js +2 -0
- package/dist/create/timescale.d.ts +1 -1
- package/dist/create/timescale.js +2 -2
- package/dist/esm/buffer.mjs +1 -1
- package/dist/esm/index.mjs +1452 -209
- package/dist/get-audio-codec.d.ts +1 -0
- package/dist/get-audio-codec.js +27 -3
- package/dist/get-fps.d.ts +1 -0
- package/dist/get-fps.js +17 -13
- package/dist/get-sample-positions.d.ts +1 -0
- package/dist/get-sample-positions.js +1 -0
- package/dist/get-tracks.d.ts +1 -0
- package/dist/get-video-codec.js +4 -0
- package/dist/index.d.ts +4 -7
- package/dist/index.js +4 -2
- package/dist/options.d.ts +2 -0
- package/dist/parse-media.js +2 -1
- package/dist/parse-video.d.ts +3 -1
- package/dist/parse-video.js +3 -14
- package/dist/parser-state.d.ts +3 -3
- package/dist/samples-from-moof.js +1 -0
- package/dist/webcodec-sample-types.d.ts +7 -20
- package/dist/writers/buffer-implementation/writer.js +1 -1
- package/package.json +3 -3
- package/dist/create/make-duration-with-padding.d.ts +0 -1
- package/dist/create/matroska-header.d.ts +0 -1
- package/dist/create/matroska-seek.d.ts +0 -6
- package/dist/create/matroska-trackentry.d.ts +0 -27
- package/dist/create/polyfill-audio-sample.d.ts +0 -3
- package/dist/create/polyfill-audio-sample.js +0 -15
- package/dist/writers/buffer-implementation/multi-buffer.d.ts +0 -0
- package/dist/writers/buffer-implementation/multi-buffer.js +0 -1
package/dist/esm/index.mjs
CHANGED
|
@@ -1021,7 +1021,1111 @@ var combineUint8Arrays = (arrays) => {
|
|
|
1021
1021
|
return result;
|
|
1022
1022
|
};
|
|
1023
1023
|
|
|
1024
|
-
// src/
|
|
1024
|
+
// src/log.ts
|
|
1025
|
+
var logLevels = ["trace", "verbose", "info", "warn", "error"];
|
|
1026
|
+
var getNumberForLogLevel = (level) => {
|
|
1027
|
+
return logLevels.indexOf(level);
|
|
1028
|
+
};
|
|
1029
|
+
var isEqualOrBelowLogLevel = (currentLevel, level) => {
|
|
1030
|
+
return getNumberForLogLevel(currentLevel) <= getNumberForLogLevel(level);
|
|
1031
|
+
};
|
|
1032
|
+
var Log = {
|
|
1033
|
+
trace: (logLevel, ...args) => {
|
|
1034
|
+
if (isEqualOrBelowLogLevel(logLevel, "trace")) {
|
|
1035
|
+
return console.log(...args);
|
|
1036
|
+
}
|
|
1037
|
+
},
|
|
1038
|
+
verbose: (logLevel, ...args) => {
|
|
1039
|
+
if (isEqualOrBelowLogLevel(logLevel, "verbose")) {
|
|
1040
|
+
return console.log(...args);
|
|
1041
|
+
}
|
|
1042
|
+
},
|
|
1043
|
+
info: (logLevel, ...args) => {
|
|
1044
|
+
if (isEqualOrBelowLogLevel(logLevel, "info")) {
|
|
1045
|
+
return console.log(...args);
|
|
1046
|
+
}
|
|
1047
|
+
},
|
|
1048
|
+
warn: (logLevel, ...args) => {
|
|
1049
|
+
if (isEqualOrBelowLogLevel(logLevel, "warn")) {
|
|
1050
|
+
return console.warn(...args);
|
|
1051
|
+
}
|
|
1052
|
+
},
|
|
1053
|
+
error: (...args) => {
|
|
1054
|
+
return console.error(...args);
|
|
1055
|
+
}
|
|
1056
|
+
};
|
|
1057
|
+
|
|
1058
|
+
// src/create/iso-base-media/primitives.ts
|
|
1059
|
+
var stringsToUint8Array = (str) => {
|
|
1060
|
+
return new TextEncoder().encode(str);
|
|
1061
|
+
};
|
|
1062
|
+
var numberTo32BitUIntOrInt = (num) => {
|
|
1063
|
+
return new Uint8Array([
|
|
1064
|
+
num >> 24 & 255,
|
|
1065
|
+
num >> 16 & 255,
|
|
1066
|
+
num >> 8 & 255,
|
|
1067
|
+
num & 255
|
|
1068
|
+
]);
|
|
1069
|
+
};
|
|
1070
|
+
var numberTo32BitUIntOrIntLeading128 = (num) => {
|
|
1071
|
+
const arr = [
|
|
1072
|
+
num >> 24 & 255,
|
|
1073
|
+
num >> 16 & 255,
|
|
1074
|
+
num >> 8 & 255,
|
|
1075
|
+
num & 255
|
|
1076
|
+
];
|
|
1077
|
+
for (const i in arr) {
|
|
1078
|
+
if (arr[i] === 0) {
|
|
1079
|
+
arr[i] = 128;
|
|
1080
|
+
} else {
|
|
1081
|
+
break;
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
return new Uint8Array(arr);
|
|
1085
|
+
};
|
|
1086
|
+
var numberTo16BitUIntOrInt = (num) => {
|
|
1087
|
+
return new Uint8Array([num >> 8 & 255, num & 255]);
|
|
1088
|
+
};
|
|
1089
|
+
var setFixedPointSignedOrUnsigned1616Number = (num) => {
|
|
1090
|
+
const val = Math.round(num * 2 ** 16);
|
|
1091
|
+
return numberTo32BitUIntOrInt(val);
|
|
1092
|
+
};
|
|
1093
|
+
var setFixedPointSigned230Number = (num) => {
|
|
1094
|
+
const val = Math.round(num * 2 ** 30);
|
|
1095
|
+
return numberTo32BitUIntOrInt(val);
|
|
1096
|
+
};
|
|
1097
|
+
var addSize = (arr) => {
|
|
1098
|
+
return combineUint8Arrays([numberTo32BitUIntOrInt(arr.length + 4), arr]);
|
|
1099
|
+
};
|
|
1100
|
+
var addLeading128Size = (arr) => {
|
|
1101
|
+
return combineUint8Arrays([
|
|
1102
|
+
numberTo32BitUIntOrIntLeading128(arr.length),
|
|
1103
|
+
arr
|
|
1104
|
+
]);
|
|
1105
|
+
};
|
|
1106
|
+
var floatTo16Point1632Bit = (number) => {
|
|
1107
|
+
const fixedNumber = Number(number.toFixed(2));
|
|
1108
|
+
const result = new Uint8Array(4);
|
|
1109
|
+
const tens = Math.floor(fixedNumber / 10);
|
|
1110
|
+
const ones = Math.floor(fixedNumber % 10);
|
|
1111
|
+
const tenths = Math.floor(fixedNumber * 10 % 10);
|
|
1112
|
+
const hundredths = Math.floor(fixedNumber * 100 % 10);
|
|
1113
|
+
result[0] = tens;
|
|
1114
|
+
result[1] = ones;
|
|
1115
|
+
result[2] = tenths;
|
|
1116
|
+
result[3] = hundredths;
|
|
1117
|
+
return result;
|
|
1118
|
+
};
|
|
1119
|
+
var floatTo16Point16_16Bit = (number) => {
|
|
1120
|
+
const fixedNumber = Number(number.toFixed(2));
|
|
1121
|
+
const result = new Uint8Array(2);
|
|
1122
|
+
const ones = Math.floor(fixedNumber % 10);
|
|
1123
|
+
const tenths = Math.floor(fixedNumber * 10 % 10);
|
|
1124
|
+
result[0] = ones;
|
|
1125
|
+
result[1] = tenths;
|
|
1126
|
+
return result;
|
|
1127
|
+
};
|
|
1128
|
+
var serializeMatrix = (matrix) => {
|
|
1129
|
+
return combineUint8Arrays([
|
|
1130
|
+
setFixedPointSignedOrUnsigned1616Number(matrix[0]),
|
|
1131
|
+
setFixedPointSignedOrUnsigned1616Number(matrix[1]),
|
|
1132
|
+
setFixedPointSigned230Number(matrix[2]),
|
|
1133
|
+
setFixedPointSignedOrUnsigned1616Number(matrix[3]),
|
|
1134
|
+
setFixedPointSignedOrUnsigned1616Number(matrix[4]),
|
|
1135
|
+
setFixedPointSigned230Number(matrix[5]),
|
|
1136
|
+
setFixedPointSignedOrUnsigned1616Number(matrix[6]),
|
|
1137
|
+
setFixedPointSignedOrUnsigned1616Number(matrix[7]),
|
|
1138
|
+
setFixedPointSigned230Number(matrix[8])
|
|
1139
|
+
]);
|
|
1140
|
+
};
|
|
1141
|
+
var stringToPascalString = (str) => {
|
|
1142
|
+
const buffer = new Uint8Array(32);
|
|
1143
|
+
for (let i = 0;i < Math.min(str.length, 32); i++) {
|
|
1144
|
+
buffer[i] = str.charCodeAt(i);
|
|
1145
|
+
}
|
|
1146
|
+
return buffer;
|
|
1147
|
+
};
|
|
1148
|
+
var padIsoBaseMediaBytes = (data, totalLength) => {
|
|
1149
|
+
if (data.length - 8 > totalLength) {
|
|
1150
|
+
throw new Error(`Data is longer than the total length: ${data.length - 8} > ${totalLength}`);
|
|
1151
|
+
}
|
|
1152
|
+
if (data.length - 8 === totalLength) {
|
|
1153
|
+
return data;
|
|
1154
|
+
}
|
|
1155
|
+
return combineUint8Arrays([
|
|
1156
|
+
data,
|
|
1157
|
+
addSize(combineUint8Arrays([
|
|
1158
|
+
stringsToUint8Array("free"),
|
|
1159
|
+
new Uint8Array(totalLength - (data.length - 8))
|
|
1160
|
+
]))
|
|
1161
|
+
]);
|
|
1162
|
+
};
|
|
1163
|
+
var IDENTITY_MATRIX = [1, 0, 0, 0, 1, 0, 0, 0, 1];
|
|
1164
|
+
|
|
1165
|
+
// src/create/iso-base-media/create-ftyp.ts
|
|
1166
|
+
var createFtyp = ({
|
|
1167
|
+
majorBrand,
|
|
1168
|
+
minorBrand,
|
|
1169
|
+
compatibleBrands
|
|
1170
|
+
}) => {
|
|
1171
|
+
const type = stringsToUint8Array("ftyp");
|
|
1172
|
+
const majorBrandArr = stringsToUint8Array(majorBrand);
|
|
1173
|
+
const minorBrandArr = numberTo32BitUIntOrInt(minorBrand);
|
|
1174
|
+
const compatibleBrandsArr = combineUint8Arrays(compatibleBrands.map((b) => stringsToUint8Array(b)));
|
|
1175
|
+
return addSize(combineUint8Arrays([
|
|
1176
|
+
type,
|
|
1177
|
+
majorBrandArr,
|
|
1178
|
+
minorBrandArr,
|
|
1179
|
+
compatibleBrandsArr
|
|
1180
|
+
]));
|
|
1181
|
+
};
|
|
1182
|
+
var createIsoBaseMediaFtyp = ({
|
|
1183
|
+
majorBrand,
|
|
1184
|
+
minorBrand,
|
|
1185
|
+
compatibleBrands
|
|
1186
|
+
}) => {
|
|
1187
|
+
return createFtyp({ compatibleBrands, majorBrand, minorBrand });
|
|
1188
|
+
};
|
|
1189
|
+
|
|
1190
|
+
// src/create/iso-base-media/create-ilst.ts
|
|
1191
|
+
var createIlst = (items) => {
|
|
1192
|
+
return addSize(combineUint8Arrays([
|
|
1193
|
+
stringsToUint8Array("ilst"),
|
|
1194
|
+
...items
|
|
1195
|
+
]));
|
|
1196
|
+
};
|
|
1197
|
+
|
|
1198
|
+
// src/create/iso-base-media/create-moov.ts
|
|
1199
|
+
var createMoov = ({
|
|
1200
|
+
mvhd,
|
|
1201
|
+
traks,
|
|
1202
|
+
udta
|
|
1203
|
+
}) => {
|
|
1204
|
+
return addSize(combineUint8Arrays([
|
|
1205
|
+
stringsToUint8Array("moov"),
|
|
1206
|
+
mvhd,
|
|
1207
|
+
...traks,
|
|
1208
|
+
udta
|
|
1209
|
+
]));
|
|
1210
|
+
};
|
|
1211
|
+
|
|
1212
|
+
// src/boxes/iso-base-media/to-date.ts
|
|
1213
|
+
var toUnixTimestamp = (value) => {
|
|
1214
|
+
if (value === 0) {
|
|
1215
|
+
return null;
|
|
1216
|
+
}
|
|
1217
|
+
const baseDate = new Date("1904-01-01T00:00:00Z");
|
|
1218
|
+
return Math.floor(value + baseDate.getTime() / 1000) * 1000;
|
|
1219
|
+
};
|
|
1220
|
+
var fromUnixTimestamp = (value) => {
|
|
1221
|
+
if (value === null) {
|
|
1222
|
+
return 0;
|
|
1223
|
+
}
|
|
1224
|
+
const baseDate = new Date("1904-01-01T00:00:00Z");
|
|
1225
|
+
return Math.floor(value / 1000 - baseDate.getTime() / 1000);
|
|
1226
|
+
};
|
|
1227
|
+
|
|
1228
|
+
// src/create/iso-base-media/create-mvhd.ts
|
|
1229
|
+
var createMvhd = ({
|
|
1230
|
+
timescale,
|
|
1231
|
+
durationInUnits,
|
|
1232
|
+
rate,
|
|
1233
|
+
volume,
|
|
1234
|
+
nextTrackId,
|
|
1235
|
+
matrix,
|
|
1236
|
+
creationTime,
|
|
1237
|
+
modificationTime
|
|
1238
|
+
}) => {
|
|
1239
|
+
if (matrix.length !== 9) {
|
|
1240
|
+
throw new Error("Matrix must be 9 elements long");
|
|
1241
|
+
}
|
|
1242
|
+
const content = combineUint8Arrays([
|
|
1243
|
+
stringsToUint8Array("mvhd"),
|
|
1244
|
+
new Uint8Array([0]),
|
|
1245
|
+
new Uint8Array([0, 0, 0]),
|
|
1246
|
+
creationTime === null ? numberTo32BitUIntOrInt(0) : numberTo32BitUIntOrInt(fromUnixTimestamp(creationTime)),
|
|
1247
|
+
modificationTime === null ? numberTo32BitUIntOrInt(0) : numberTo32BitUIntOrInt(fromUnixTimestamp(modificationTime)),
|
|
1248
|
+
numberTo32BitUIntOrInt(timescale),
|
|
1249
|
+
numberTo32BitUIntOrInt(durationInUnits),
|
|
1250
|
+
floatTo16Point1632Bit(rate),
|
|
1251
|
+
floatTo16Point16_16Bit(volume),
|
|
1252
|
+
new Uint8Array([0, 0]),
|
|
1253
|
+
new Uint8Array([0, 0, 0, 0]),
|
|
1254
|
+
new Uint8Array([0, 0, 0, 0]),
|
|
1255
|
+
serializeMatrix(matrix),
|
|
1256
|
+
combineUint8Arrays(new Array(6).fill(new Uint8Array([0, 0, 0, 0]))),
|
|
1257
|
+
numberTo32BitUIntOrInt(nextTrackId)
|
|
1258
|
+
]);
|
|
1259
|
+
return addSize(content);
|
|
1260
|
+
};
|
|
1261
|
+
|
|
1262
|
+
// src/create/iso-base-media/create-udta.ts
|
|
1263
|
+
var createUdta = (children) => {
|
|
1264
|
+
return addSize(combineUint8Arrays([
|
|
1265
|
+
stringsToUint8Array("udta"),
|
|
1266
|
+
children
|
|
1267
|
+
]));
|
|
1268
|
+
};
|
|
1269
|
+
|
|
1270
|
+
// src/create/iso-base-media/ilst/create-cmt.ts
|
|
1271
|
+
var createCmt = (comment) => {
|
|
1272
|
+
return addSize(combineUint8Arrays([
|
|
1273
|
+
new Uint8Array([169, 99, 109, 116]),
|
|
1274
|
+
addSize(combineUint8Arrays([
|
|
1275
|
+
stringsToUint8Array("data"),
|
|
1276
|
+
new Uint8Array([0, 0]),
|
|
1277
|
+
new Uint8Array([0, 1]),
|
|
1278
|
+
new Uint8Array([0, 0]),
|
|
1279
|
+
new Uint8Array([0, 0]),
|
|
1280
|
+
stringsToUint8Array(comment)
|
|
1281
|
+
]))
|
|
1282
|
+
]));
|
|
1283
|
+
};
|
|
1284
|
+
|
|
1285
|
+
// src/create/iso-base-media/ilst/create-too.ts
|
|
1286
|
+
var createToo = (value) => {
|
|
1287
|
+
return addSize(combineUint8Arrays([
|
|
1288
|
+
new Uint8Array([169, 116, 111, 111]),
|
|
1289
|
+
addSize(combineUint8Arrays([
|
|
1290
|
+
new Uint8Array([100, 97, 116, 97]),
|
|
1291
|
+
new Uint8Array([0, 0]),
|
|
1292
|
+
new Uint8Array([0, 1]),
|
|
1293
|
+
new Uint8Array([0, 0]),
|
|
1294
|
+
new Uint8Array([0, 0]),
|
|
1295
|
+
stringsToUint8Array(value)
|
|
1296
|
+
]))
|
|
1297
|
+
]));
|
|
1298
|
+
};
|
|
1299
|
+
|
|
1300
|
+
// src/create/iso-base-media/trak/mdia/minf/stbl/stsd/create-avcc.ts
|
|
1301
|
+
var createAvccBox = (privateData) => {
|
|
1302
|
+
if (!privateData) {
|
|
1303
|
+
throw new Error("privateData is required");
|
|
1304
|
+
}
|
|
1305
|
+
return addSize(combineUint8Arrays([
|
|
1306
|
+
stringsToUint8Array("avcC"),
|
|
1307
|
+
privateData
|
|
1308
|
+
]));
|
|
1309
|
+
};
|
|
1310
|
+
|
|
1311
|
+
// src/create/iso-base-media/trak/mdia/minf/stbl/stsd/create-pasp.ts
|
|
1312
|
+
var createPasp = (x, y) => {
|
|
1313
|
+
return addSize(combineUint8Arrays([
|
|
1314
|
+
stringsToUint8Array("pasp"),
|
|
1315
|
+
numberTo32BitUIntOrInt(x),
|
|
1316
|
+
numberTo32BitUIntOrInt(y)
|
|
1317
|
+
]));
|
|
1318
|
+
};
|
|
1319
|
+
|
|
1320
|
+
// src/create/iso-base-media/codec-specific/avc1.ts
|
|
1321
|
+
var createAvc1Data = ({
|
|
1322
|
+
avccBox,
|
|
1323
|
+
pasp,
|
|
1324
|
+
width,
|
|
1325
|
+
height,
|
|
1326
|
+
horizontalResolution,
|
|
1327
|
+
verticalResolution,
|
|
1328
|
+
compressorName,
|
|
1329
|
+
depth
|
|
1330
|
+
}) => {
|
|
1331
|
+
return addSize(combineUint8Arrays([
|
|
1332
|
+
stringsToUint8Array("avc1"),
|
|
1333
|
+
new Uint8Array([0, 0, 0, 0, 0, 0]),
|
|
1334
|
+
new Uint8Array([0, 1]),
|
|
1335
|
+
new Uint8Array([0, 0]),
|
|
1336
|
+
new Uint8Array([0, 0]),
|
|
1337
|
+
new Uint8Array([0, 0, 0, 0]),
|
|
1338
|
+
new Uint8Array([0, 0, 0, 0]),
|
|
1339
|
+
new Uint8Array([0, 0, 0, 0]),
|
|
1340
|
+
numberTo16BitUIntOrInt(width),
|
|
1341
|
+
numberTo16BitUIntOrInt(height),
|
|
1342
|
+
setFixedPointSignedOrUnsigned1616Number(horizontalResolution),
|
|
1343
|
+
setFixedPointSignedOrUnsigned1616Number(verticalResolution),
|
|
1344
|
+
new Uint8Array([0, 0, 0, 0]),
|
|
1345
|
+
numberTo16BitUIntOrInt(1),
|
|
1346
|
+
stringToPascalString(compressorName),
|
|
1347
|
+
numberTo16BitUIntOrInt(depth),
|
|
1348
|
+
numberTo16BitUIntOrInt(-1),
|
|
1349
|
+
avccBox,
|
|
1350
|
+
pasp
|
|
1351
|
+
]));
|
|
1352
|
+
};
|
|
1353
|
+
|
|
1354
|
+
// src/create/iso-base-media/codec-specific/mp4a.ts
|
|
1355
|
+
var createMp4a = ({
|
|
1356
|
+
sampleRate,
|
|
1357
|
+
channelCount,
|
|
1358
|
+
avgBitrate,
|
|
1359
|
+
maxBitrate,
|
|
1360
|
+
codecPrivate: codecPrivate2
|
|
1361
|
+
}) => {
|
|
1362
|
+
if (!codecPrivate2) {
|
|
1363
|
+
throw new Error("Need codecPrivate for mp4a");
|
|
1364
|
+
}
|
|
1365
|
+
const esdsAtom = addSize(combineUint8Arrays([
|
|
1366
|
+
stringsToUint8Array("esds"),
|
|
1367
|
+
new Uint8Array([0]),
|
|
1368
|
+
new Uint8Array([0, 0, 0]),
|
|
1369
|
+
new Uint8Array([3]),
|
|
1370
|
+
addLeading128Size(combineUint8Arrays([
|
|
1371
|
+
numberTo16BitUIntOrInt(2),
|
|
1372
|
+
new Uint8Array([0]),
|
|
1373
|
+
new Uint8Array([4]),
|
|
1374
|
+
addLeading128Size(combineUint8Arrays([
|
|
1375
|
+
new Uint8Array([64]),
|
|
1376
|
+
new Uint8Array([21]),
|
|
1377
|
+
new Uint8Array([0, 0, 0]),
|
|
1378
|
+
numberTo32BitUIntOrInt(maxBitrate),
|
|
1379
|
+
numberTo32BitUIntOrInt(avgBitrate),
|
|
1380
|
+
new Uint8Array([5]),
|
|
1381
|
+
addLeading128Size(codecPrivate2)
|
|
1382
|
+
])),
|
|
1383
|
+
new Uint8Array([6]),
|
|
1384
|
+
addLeading128Size(new Uint8Array([2]))
|
|
1385
|
+
]))
|
|
1386
|
+
]));
|
|
1387
|
+
return addSize(combineUint8Arrays([
|
|
1388
|
+
stringsToUint8Array("mp4a"),
|
|
1389
|
+
new Uint8Array([0, 0, 0, 0, 0, 0]),
|
|
1390
|
+
numberTo16BitUIntOrInt(1),
|
|
1391
|
+
numberTo16BitUIntOrInt(0),
|
|
1392
|
+
numberTo16BitUIntOrInt(0),
|
|
1393
|
+
new Uint8Array([0, 0, 0, 0]),
|
|
1394
|
+
numberTo16BitUIntOrInt(channelCount),
|
|
1395
|
+
numberTo16BitUIntOrInt(16),
|
|
1396
|
+
numberTo16BitUIntOrInt(0),
|
|
1397
|
+
numberTo16BitUIntOrInt(0),
|
|
1398
|
+
setFixedPointSignedOrUnsigned1616Number(sampleRate),
|
|
1399
|
+
esdsAtom
|
|
1400
|
+
]));
|
|
1401
|
+
};
|
|
1402
|
+
|
|
1403
|
+
// src/create/iso-base-media/codec-specific/create-codec-specific-data.ts
|
|
1404
|
+
var createCodecSpecificData = (track) => {
|
|
1405
|
+
if (track.type === "video") {
|
|
1406
|
+
return createAvc1Data({
|
|
1407
|
+
avccBox: createAvccBox(track.codecPrivate),
|
|
1408
|
+
compressorName: "WebCodecs",
|
|
1409
|
+
depth: 24,
|
|
1410
|
+
horizontalResolution: 72,
|
|
1411
|
+
verticalResolution: 72,
|
|
1412
|
+
height: track.height,
|
|
1413
|
+
width: track.width,
|
|
1414
|
+
pasp: createPasp(1, 1),
|
|
1415
|
+
type: "avc1-data"
|
|
1416
|
+
});
|
|
1417
|
+
}
|
|
1418
|
+
if (track.type === "audio") {
|
|
1419
|
+
return createMp4a({
|
|
1420
|
+
type: "mp4a-data",
|
|
1421
|
+
avgBitrate: 128 * 1024,
|
|
1422
|
+
maxBitrate: 128 * 1024,
|
|
1423
|
+
channelCount: track.numberOfChannels,
|
|
1424
|
+
sampleRate: track.sampleRate,
|
|
1425
|
+
codecPrivate: track.codecPrivate
|
|
1426
|
+
});
|
|
1427
|
+
}
|
|
1428
|
+
throw new Error("Unsupported codec specific data " + track);
|
|
1429
|
+
};
|
|
1430
|
+
|
|
1431
|
+
// src/create/iso-base-media/create-mdia.ts
|
|
1432
|
+
var createMdia = ({
|
|
1433
|
+
mdhd,
|
|
1434
|
+
hdlr,
|
|
1435
|
+
minf
|
|
1436
|
+
}) => {
|
|
1437
|
+
return addSize(combineUint8Arrays([
|
|
1438
|
+
stringsToUint8Array("mdia"),
|
|
1439
|
+
mdhd,
|
|
1440
|
+
hdlr,
|
|
1441
|
+
minf
|
|
1442
|
+
]));
|
|
1443
|
+
};
|
|
1444
|
+
|
|
1445
|
+
// src/truthy.ts
|
|
1446
|
+
function truthy(value) {
|
|
1447
|
+
return Boolean(value);
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
// src/create/iso-base-media/create-trak.ts
|
|
1451
|
+
var createTrak = ({
|
|
1452
|
+
tkhd,
|
|
1453
|
+
mdia
|
|
1454
|
+
}) => {
|
|
1455
|
+
return addSize(combineUint8Arrays([
|
|
1456
|
+
stringsToUint8Array("trak"),
|
|
1457
|
+
tkhd,
|
|
1458
|
+
mdia
|
|
1459
|
+
].filter(truthy)));
|
|
1460
|
+
};
|
|
1461
|
+
|
|
1462
|
+
// src/create/iso-base-media/mdia/create-mdhd.ts
|
|
1463
|
+
var createMdhd = ({
|
|
1464
|
+
creationTime,
|
|
1465
|
+
modificationTime,
|
|
1466
|
+
timescale,
|
|
1467
|
+
duration: duration2
|
|
1468
|
+
}) => {
|
|
1469
|
+
return addSize(combineUint8Arrays([
|
|
1470
|
+
stringsToUint8Array("mdhd"),
|
|
1471
|
+
new Uint8Array([0]),
|
|
1472
|
+
new Uint8Array([0, 0, 0]),
|
|
1473
|
+
creationTime === null ? numberTo32BitUIntOrInt(0) : numberTo32BitUIntOrInt(fromUnixTimestamp(creationTime)),
|
|
1474
|
+
modificationTime === null ? numberTo32BitUIntOrInt(0) : numberTo32BitUIntOrInt(fromUnixTimestamp(modificationTime)),
|
|
1475
|
+
numberTo32BitUIntOrInt(timescale),
|
|
1476
|
+
numberTo32BitUIntOrInt(Math.round(duration2 / 1000 * timescale)),
|
|
1477
|
+
new Uint8Array([85, 196]),
|
|
1478
|
+
new Uint8Array([0, 0])
|
|
1479
|
+
]));
|
|
1480
|
+
};
|
|
1481
|
+
|
|
1482
|
+
// src/create/iso-base-media/trak/create-tkhd.ts
|
|
1483
|
+
var TKHD_FLAGS = {
|
|
1484
|
+
TRACK_ENABLED: 1,
|
|
1485
|
+
TRACK_IN_MOVIE: 2,
|
|
1486
|
+
TRACK_IN_PREVIEW: 4,
|
|
1487
|
+
TRACK_IN_POSTER: 8
|
|
1488
|
+
};
|
|
1489
|
+
var createTkhdForAudio = ({
|
|
1490
|
+
creationTime,
|
|
1491
|
+
modificationTime,
|
|
1492
|
+
flags,
|
|
1493
|
+
trackId,
|
|
1494
|
+
duration: duration2,
|
|
1495
|
+
volume,
|
|
1496
|
+
timescale
|
|
1497
|
+
}) => {
|
|
1498
|
+
return addSize(combineUint8Arrays([
|
|
1499
|
+
stringsToUint8Array("tkhd"),
|
|
1500
|
+
new Uint8Array([0]),
|
|
1501
|
+
new Uint8Array([0, 0, flags]),
|
|
1502
|
+
creationTime === null ? numberTo32BitUIntOrInt(0) : numberTo32BitUIntOrInt(fromUnixTimestamp(creationTime)),
|
|
1503
|
+
modificationTime === null ? numberTo32BitUIntOrInt(0) : numberTo32BitUIntOrInt(fromUnixTimestamp(modificationTime)),
|
|
1504
|
+
numberTo32BitUIntOrInt(trackId),
|
|
1505
|
+
new Uint8Array([0, 0, 0, 0]),
|
|
1506
|
+
numberTo32BitUIntOrInt(Math.round(duration2 / 1000 * timescale)),
|
|
1507
|
+
new Uint8Array([0, 0, 0, 0]),
|
|
1508
|
+
new Uint8Array([0, 0, 0, 0]),
|
|
1509
|
+
new Uint8Array([0, 0]),
|
|
1510
|
+
new Uint8Array([0, 1]),
|
|
1511
|
+
floatTo16Point16_16Bit(volume),
|
|
1512
|
+
new Uint8Array([0, 0]),
|
|
1513
|
+
serializeMatrix(IDENTITY_MATRIX),
|
|
1514
|
+
setFixedPointSignedOrUnsigned1616Number(0),
|
|
1515
|
+
setFixedPointSignedOrUnsigned1616Number(0)
|
|
1516
|
+
]));
|
|
1517
|
+
};
|
|
1518
|
+
var createTkhdForVideo = ({
|
|
1519
|
+
creationTime,
|
|
1520
|
+
modificationTime,
|
|
1521
|
+
duration: duration2,
|
|
1522
|
+
trackId,
|
|
1523
|
+
volume,
|
|
1524
|
+
matrix,
|
|
1525
|
+
width,
|
|
1526
|
+
height,
|
|
1527
|
+
flags,
|
|
1528
|
+
timescale
|
|
1529
|
+
}) => {
|
|
1530
|
+
const content = combineUint8Arrays([
|
|
1531
|
+
stringsToUint8Array("tkhd"),
|
|
1532
|
+
new Uint8Array([0]),
|
|
1533
|
+
new Uint8Array([0, 0, flags]),
|
|
1534
|
+
creationTime === null ? numberTo32BitUIntOrInt(0) : numberTo32BitUIntOrInt(fromUnixTimestamp(creationTime)),
|
|
1535
|
+
modificationTime === null ? numberTo32BitUIntOrInt(0) : numberTo32BitUIntOrInt(fromUnixTimestamp(modificationTime)),
|
|
1536
|
+
numberTo32BitUIntOrInt(trackId),
|
|
1537
|
+
new Uint8Array([0, 0, 0, 0]),
|
|
1538
|
+
numberTo32BitUIntOrInt(duration2 / 1000 * timescale),
|
|
1539
|
+
new Uint8Array([0, 0, 0, 0]),
|
|
1540
|
+
new Uint8Array([0, 0, 0, 0]),
|
|
1541
|
+
new Uint8Array([0, 0]),
|
|
1542
|
+
new Uint8Array([0, 0]),
|
|
1543
|
+
floatTo16Point16_16Bit(volume),
|
|
1544
|
+
new Uint8Array([0, 0]),
|
|
1545
|
+
serializeMatrix(matrix),
|
|
1546
|
+
setFixedPointSignedOrUnsigned1616Number(width),
|
|
1547
|
+
setFixedPointSignedOrUnsigned1616Number(height)
|
|
1548
|
+
]);
|
|
1549
|
+
return addSize(content);
|
|
1550
|
+
};
|
|
1551
|
+
|
|
1552
|
+
// src/create/iso-base-media/trak/mdia/minf/create-dinf.ts
|
|
1553
|
+
var createDinf = () => {
|
|
1554
|
+
return addSize(combineUint8Arrays([
|
|
1555
|
+
stringsToUint8Array("dinf"),
|
|
1556
|
+
addSize(combineUint8Arrays([
|
|
1557
|
+
stringsToUint8Array("dref"),
|
|
1558
|
+
new Uint8Array([0]),
|
|
1559
|
+
new Uint8Array([0, 0, 0]),
|
|
1560
|
+
new Uint8Array([0, 0, 0, 1]),
|
|
1561
|
+
addSize(combineUint8Arrays([
|
|
1562
|
+
stringsToUint8Array("url "),
|
|
1563
|
+
new Uint8Array([0]),
|
|
1564
|
+
new Uint8Array([0, 0, 1])
|
|
1565
|
+
]))
|
|
1566
|
+
]))
|
|
1567
|
+
]));
|
|
1568
|
+
};
|
|
1569
|
+
|
|
1570
|
+
// src/create/iso-base-media/trak/mdia/create-minf.ts
|
|
1571
|
+
var createMinf = ({
|
|
1572
|
+
vmhdAtom,
|
|
1573
|
+
stblAtom
|
|
1574
|
+
}) => {
|
|
1575
|
+
return addSize(combineUint8Arrays([
|
|
1576
|
+
stringsToUint8Array("minf"),
|
|
1577
|
+
vmhdAtom,
|
|
1578
|
+
createDinf(),
|
|
1579
|
+
stblAtom
|
|
1580
|
+
]));
|
|
1581
|
+
};
|
|
1582
|
+
|
|
1583
|
+
// src/create/iso-base-media/trak/mdia/minf/create-smhd.ts
|
|
1584
|
+
var createSmhd = () => {
|
|
1585
|
+
return addSize(combineUint8Arrays([
|
|
1586
|
+
stringsToUint8Array("smhd"),
|
|
1587
|
+
new Uint8Array([0]),
|
|
1588
|
+
new Uint8Array([0, 0, 0]),
|
|
1589
|
+
new Uint8Array([0, 0]),
|
|
1590
|
+
new Uint8Array([0, 0])
|
|
1591
|
+
]));
|
|
1592
|
+
};
|
|
1593
|
+
|
|
1594
|
+
// src/create/iso-base-media/trak/mdia/minf/stbl/create-ctts.ts
|
|
1595
|
+
var makeEntry = (entry) => {
|
|
1596
|
+
return combineUint8Arrays([
|
|
1597
|
+
numberTo32BitUIntOrInt(entry.sampleCount),
|
|
1598
|
+
numberTo32BitUIntOrInt(entry.sampleOffset)
|
|
1599
|
+
]);
|
|
1600
|
+
};
|
|
1601
|
+
var createCttsBox = (samplePositions) => {
|
|
1602
|
+
const offsets = samplePositions.map((s) => s.cts - s.dts);
|
|
1603
|
+
const entries = [];
|
|
1604
|
+
let lastOffset = null;
|
|
1605
|
+
for (const offset of offsets) {
|
|
1606
|
+
if (lastOffset === offset) {
|
|
1607
|
+
entries[entries.length - 1].sampleCount++;
|
|
1608
|
+
} else {
|
|
1609
|
+
entries.push({
|
|
1610
|
+
sampleCount: 1,
|
|
1611
|
+
sampleOffset: offset
|
|
1612
|
+
});
|
|
1613
|
+
}
|
|
1614
|
+
lastOffset = offset;
|
|
1615
|
+
}
|
|
1616
|
+
const needsCtts = entries.length > 0 && entries.some((e) => e.sampleOffset !== 0);
|
|
1617
|
+
if (!needsCtts) {
|
|
1618
|
+
return null;
|
|
1619
|
+
}
|
|
1620
|
+
return addSize(combineUint8Arrays([
|
|
1621
|
+
stringsToUint8Array("ctts"),
|
|
1622
|
+
new Uint8Array([0]),
|
|
1623
|
+
new Uint8Array([0, 0, 0]),
|
|
1624
|
+
numberTo32BitUIntOrInt(entries.length),
|
|
1625
|
+
...entries.map((e) => makeEntry(e))
|
|
1626
|
+
]));
|
|
1627
|
+
};
|
|
1628
|
+
|
|
1629
|
+
// src/create/iso-base-media/trak/mdia/minf/stbl/create-stco.ts
|
|
1630
|
+
var createStcoAtom = (samplePositions) => {
|
|
1631
|
+
const chunkOffsets = [];
|
|
1632
|
+
let lastChunk;
|
|
1633
|
+
for (const sample of samplePositions) {
|
|
1634
|
+
if (lastChunk !== sample.chunk) {
|
|
1635
|
+
chunkOffsets.push(sample.offset);
|
|
1636
|
+
}
|
|
1637
|
+
lastChunk = sample.chunk;
|
|
1638
|
+
}
|
|
1639
|
+
return addSize(combineUint8Arrays([
|
|
1640
|
+
stringsToUint8Array("stco"),
|
|
1641
|
+
new Uint8Array([0]),
|
|
1642
|
+
new Uint8Array([0, 0, 0]),
|
|
1643
|
+
numberTo32BitUIntOrInt(chunkOffsets.length),
|
|
1644
|
+
...chunkOffsets.map((offset) => numberTo32BitUIntOrInt(offset))
|
|
1645
|
+
]));
|
|
1646
|
+
};
|
|
1647
|
+
|
|
1648
|
+
// src/create/iso-base-media/trak/mdia/minf/stbl/create-stsc.ts
|
|
1649
|
+
var createEntry = (entry) => {
|
|
1650
|
+
return combineUint8Arrays([
|
|
1651
|
+
numberTo32BitUIntOrInt(entry.firstChunk),
|
|
1652
|
+
numberTo32BitUIntOrInt(entry.samplesPerChunk),
|
|
1653
|
+
numberTo32BitUIntOrInt(entry.sampleDescriptionIndex)
|
|
1654
|
+
]);
|
|
1655
|
+
};
|
|
1656
|
+
var createStsc = (samplePositions) => {
|
|
1657
|
+
const entries = [];
|
|
1658
|
+
const deduplicateLastEntry = () => {
|
|
1659
|
+
const lastEntry = entries[entries.length - 1];
|
|
1660
|
+
const secondToLastEntry = entries[entries.length - 2];
|
|
1661
|
+
if (lastEntry && secondToLastEntry && lastEntry.samplesPerChunk === secondToLastEntry.samplesPerChunk && lastEntry.sampleDescriptionIndex === secondToLastEntry.sampleDescriptionIndex) {
|
|
1662
|
+
const lastIndex = entries.length - 1;
|
|
1663
|
+
entries.length = lastIndex;
|
|
1664
|
+
}
|
|
1665
|
+
};
|
|
1666
|
+
let lastChunk;
|
|
1667
|
+
for (const samplePosition of samplePositions) {
|
|
1668
|
+
if (samplePosition.chunk === lastChunk) {
|
|
1669
|
+
entries[entries.length - 1].samplesPerChunk++;
|
|
1670
|
+
} else {
|
|
1671
|
+
deduplicateLastEntry();
|
|
1672
|
+
entries.push({
|
|
1673
|
+
firstChunk: samplePosition.chunk,
|
|
1674
|
+
samplesPerChunk: 1,
|
|
1675
|
+
sampleDescriptionIndex: 1
|
|
1676
|
+
});
|
|
1677
|
+
lastChunk = samplePosition.chunk;
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
deduplicateLastEntry();
|
|
1681
|
+
return addSize(combineUint8Arrays([
|
|
1682
|
+
stringsToUint8Array("stsc"),
|
|
1683
|
+
new Uint8Array([0]),
|
|
1684
|
+
new Uint8Array([0, 0, 0]),
|
|
1685
|
+
numberTo32BitUIntOrInt(entries.length),
|
|
1686
|
+
...entries.map((e) => createEntry(e))
|
|
1687
|
+
]));
|
|
1688
|
+
};
|
|
1689
|
+
|
|
1690
|
+
// src/create/iso-base-media/trak/mdia/minf/stbl/create-stss.ts
|
|
1691
|
+
var createStss = (samplePositions) => {
|
|
1692
|
+
const samples = samplePositions.map((sample, i) => [sample.isKeyframe, i]).filter((s) => s[0]).map((s) => s[1] + 1);
|
|
1693
|
+
return addSize(combineUint8Arrays([
|
|
1694
|
+
stringsToUint8Array("stss"),
|
|
1695
|
+
new Uint8Array([0]),
|
|
1696
|
+
new Uint8Array([0, 0, 0]),
|
|
1697
|
+
numberTo32BitUIntOrInt(samples.length),
|
|
1698
|
+
...samples.map((sample) => numberTo32BitUIntOrInt(sample))
|
|
1699
|
+
]));
|
|
1700
|
+
};
|
|
1701
|
+
|
|
1702
|
+
// src/create/iso-base-media/trak/mdia/minf/stbl/create-stsz.ts
|
|
1703
|
+
var createStsz = (samplePositions) => {
|
|
1704
|
+
const sampleSizes = samplePositions.map((samplePosition) => samplePosition.size);
|
|
1705
|
+
return addSize(combineUint8Arrays([
|
|
1706
|
+
stringsToUint8Array("stsz"),
|
|
1707
|
+
new Uint8Array([0]),
|
|
1708
|
+
new Uint8Array([0, 0, 0]),
|
|
1709
|
+
numberTo32BitUIntOrInt(0),
|
|
1710
|
+
numberTo32BitUIntOrInt(sampleSizes.length),
|
|
1711
|
+
...sampleSizes.map((size) => numberTo32BitUIntOrInt(size))
|
|
1712
|
+
]));
|
|
1713
|
+
};
|
|
1714
|
+
|
|
1715
|
+
// src/create/iso-base-media/trak/mdia/minf/stbl/create-stts.ts
|
|
1716
|
+
var makeEntry2 = (entry) => {
|
|
1717
|
+
return combineUint8Arrays([
|
|
1718
|
+
numberTo32BitUIntOrInt(entry.sampleCount),
|
|
1719
|
+
numberTo32BitUIntOrInt(entry.sampleOffset)
|
|
1720
|
+
]);
|
|
1721
|
+
};
|
|
1722
|
+
var createSttsAtom = (samplePositions) => {
|
|
1723
|
+
let lastDuration = null;
|
|
1724
|
+
const durations = samplePositions.map((_, i, a) => {
|
|
1725
|
+
if (a[i].duration === undefined || a[i].duration === 0) {
|
|
1726
|
+
return (a[i + 1]?.dts ?? a[i].dts) - a[i].dts;
|
|
1727
|
+
}
|
|
1728
|
+
return a[i].duration;
|
|
1729
|
+
});
|
|
1730
|
+
const entries = [];
|
|
1731
|
+
for (const duration2 of durations) {
|
|
1732
|
+
if (duration2 === lastDuration) {
|
|
1733
|
+
entries[entries.length - 1].sampleCount++;
|
|
1734
|
+
} else {
|
|
1735
|
+
entries.push({
|
|
1736
|
+
sampleCount: 1,
|
|
1737
|
+
sampleOffset: duration2
|
|
1738
|
+
});
|
|
1739
|
+
}
|
|
1740
|
+
lastDuration = duration2;
|
|
1741
|
+
}
|
|
1742
|
+
return addSize(combineUint8Arrays([
|
|
1743
|
+
stringsToUint8Array("stts"),
|
|
1744
|
+
new Uint8Array([0]),
|
|
1745
|
+
new Uint8Array([0, 0, 0]),
|
|
1746
|
+
numberTo32BitUIntOrInt(entries.length),
|
|
1747
|
+
...entries.map((e) => makeEntry2(e))
|
|
1748
|
+
]));
|
|
1749
|
+
};
|
|
1750
|
+
|
|
1751
|
+
// src/create/iso-base-media/trak/mdia/minf/stbl/stsd/create-avc1.ts
|
|
1752
|
+
var createStsdData = (codecSpecificData) => {
|
|
1753
|
+
return addSize(combineUint8Arrays([
|
|
1754
|
+
stringsToUint8Array("stsd"),
|
|
1755
|
+
new Uint8Array([0]),
|
|
1756
|
+
new Uint8Array([0, 0, 0]),
|
|
1757
|
+
new Uint8Array([0, 0, 0, 1]),
|
|
1758
|
+
codecSpecificData
|
|
1759
|
+
]));
|
|
1760
|
+
};
|
|
1761
|
+
|
|
1762
|
+
// src/create/iso-base-media/trak/mdia/minf/create-stbl.ts
|
|
1763
|
+
var createStbl = ({
|
|
1764
|
+
samplePositions,
|
|
1765
|
+
codecSpecificData,
|
|
1766
|
+
isVideo
|
|
1767
|
+
}) => {
|
|
1768
|
+
return addSize(combineUint8Arrays([
|
|
1769
|
+
stringsToUint8Array("stbl"),
|
|
1770
|
+
createStsdData(codecSpecificData),
|
|
1771
|
+
createSttsAtom(samplePositions),
|
|
1772
|
+
isVideo ? createStss(samplePositions) : null,
|
|
1773
|
+
createCttsBox(samplePositions),
|
|
1774
|
+
createStsc(samplePositions),
|
|
1775
|
+
createStsz(samplePositions),
|
|
1776
|
+
createStcoAtom(samplePositions),
|
|
1777
|
+
isVideo ? null : new Uint8Array([
|
|
1778
|
+
0,
|
|
1779
|
+
0,
|
|
1780
|
+
0,
|
|
1781
|
+
26,
|
|
1782
|
+
115,
|
|
1783
|
+
103,
|
|
1784
|
+
112,
|
|
1785
|
+
100,
|
|
1786
|
+
1,
|
|
1787
|
+
0,
|
|
1788
|
+
0,
|
|
1789
|
+
0,
|
|
1790
|
+
114,
|
|
1791
|
+
111,
|
|
1792
|
+
108,
|
|
1793
|
+
108,
|
|
1794
|
+
0,
|
|
1795
|
+
0,
|
|
1796
|
+
0,
|
|
1797
|
+
2,
|
|
1798
|
+
0,
|
|
1799
|
+
0,
|
|
1800
|
+
0,
|
|
1801
|
+
1,
|
|
1802
|
+
255,
|
|
1803
|
+
255,
|
|
1804
|
+
0,
|
|
1805
|
+
0,
|
|
1806
|
+
0,
|
|
1807
|
+
28,
|
|
1808
|
+
115,
|
|
1809
|
+
98,
|
|
1810
|
+
103,
|
|
1811
|
+
112,
|
|
1812
|
+
0,
|
|
1813
|
+
0,
|
|
1814
|
+
0,
|
|
1815
|
+
0,
|
|
1816
|
+
114,
|
|
1817
|
+
111,
|
|
1818
|
+
108,
|
|
1819
|
+
108,
|
|
1820
|
+
0,
|
|
1821
|
+
0,
|
|
1822
|
+
0,
|
|
1823
|
+
1,
|
|
1824
|
+
0,
|
|
1825
|
+
0,
|
|
1826
|
+
10,
|
|
1827
|
+
25,
|
|
1828
|
+
0,
|
|
1829
|
+
0,
|
|
1830
|
+
0,
|
|
1831
|
+
1
|
|
1832
|
+
])
|
|
1833
|
+
].filter(truthy)));
|
|
1834
|
+
};
|
|
1835
|
+
|
|
1836
|
+
// src/create/iso-base-media/trak/mdia/minf/create-vmhd.ts
|
|
1837
|
+
var createVmhd = () => {
|
|
1838
|
+
return addSize(combineUint8Arrays([
|
|
1839
|
+
stringsToUint8Array("vmhd"),
|
|
1840
|
+
new Uint8Array([0]),
|
|
1841
|
+
new Uint8Array([0, 0, 1]),
|
|
1842
|
+
new Uint8Array([0, 0]),
|
|
1843
|
+
new Uint8Array([0, 0, 0, 0, 0, 0])
|
|
1844
|
+
]));
|
|
1845
|
+
};
|
|
1846
|
+
|
|
1847
|
+
// src/create/iso-base-media/udta/meta/create-hdlr.ts
|
|
1848
|
+
var createHdlr = (type) => {
|
|
1849
|
+
return addSize(combineUint8Arrays([
|
|
1850
|
+
stringsToUint8Array("hdlr"),
|
|
1851
|
+
new Uint8Array([0]),
|
|
1852
|
+
new Uint8Array([0, 0, 0]),
|
|
1853
|
+
new Uint8Array([0, 0, 0, 0]),
|
|
1854
|
+
stringsToUint8Array(type === "mdir" ? "mdir" : type === "video" ? "vide" : "soun"),
|
|
1855
|
+
type === "mdir" ? numberTo32BitUIntOrInt(1634758764) : new Uint8Array([0, 0, 0, 0]),
|
|
1856
|
+
new Uint8Array([0, 0, 0, 0]),
|
|
1857
|
+
new Uint8Array([0, 0, 0, 0]),
|
|
1858
|
+
stringsToUint8Array(type === "mdir" ? "\0" : type === "video" ? "VideoHandler\0" : "SoundHandler\0")
|
|
1859
|
+
]));
|
|
1860
|
+
};
|
|
1861
|
+
|
|
1862
|
+
// src/create/iso-base-media/serialize-track.ts
|
|
1863
|
+
var serializeTrack = ({
|
|
1864
|
+
track,
|
|
1865
|
+
durationInUnits,
|
|
1866
|
+
samplePositions,
|
|
1867
|
+
timescale
|
|
1868
|
+
}) => {
|
|
1869
|
+
if (track.codec !== "h264" && track.codec !== "aac") {
|
|
1870
|
+
throw new Error("Currently only H.264 and AAC is supported");
|
|
1871
|
+
}
|
|
1872
|
+
return createTrak({
|
|
1873
|
+
tkhd: track.codec === "aac" ? createTkhdForAudio({
|
|
1874
|
+
creationTime: Date.now(),
|
|
1875
|
+
flags: TKHD_FLAGS.TRACK_ENABLED | TKHD_FLAGS.TRACK_IN_MOVIE,
|
|
1876
|
+
modificationTime: Date.now(),
|
|
1877
|
+
duration: durationInUnits,
|
|
1878
|
+
trackId: track.trackNumber,
|
|
1879
|
+
volume: 1,
|
|
1880
|
+
timescale
|
|
1881
|
+
}) : track.type === "video" ? createTkhdForVideo({
|
|
1882
|
+
creationTime: Date.now(),
|
|
1883
|
+
modificationTime: Date.now(),
|
|
1884
|
+
duration: durationInUnits,
|
|
1885
|
+
flags: TKHD_FLAGS.TRACK_ENABLED | TKHD_FLAGS.TRACK_IN_MOVIE,
|
|
1886
|
+
height: track.height,
|
|
1887
|
+
width: track.width,
|
|
1888
|
+
matrix: IDENTITY_MATRIX,
|
|
1889
|
+
trackId: track.trackNumber,
|
|
1890
|
+
volume: 0,
|
|
1891
|
+
timescale
|
|
1892
|
+
}) : new Uint8Array(stringsToUint8Array("wrong")),
|
|
1893
|
+
mdia: createMdia({
|
|
1894
|
+
mdhd: createMdhd({
|
|
1895
|
+
creationTime: null,
|
|
1896
|
+
modificationTime: null,
|
|
1897
|
+
duration: durationInUnits,
|
|
1898
|
+
timescale: track.timescale
|
|
1899
|
+
}),
|
|
1900
|
+
hdlr: track.type === "video" ? createHdlr("video") : createHdlr("audio"),
|
|
1901
|
+
minf: createMinf({
|
|
1902
|
+
stblAtom: createStbl({
|
|
1903
|
+
samplePositions,
|
|
1904
|
+
isVideo: track.type === "video",
|
|
1905
|
+
codecSpecificData: createCodecSpecificData(track)
|
|
1906
|
+
}),
|
|
1907
|
+
vmhdAtom: track.type === "audio" ? createSmhd() : createVmhd()
|
|
1908
|
+
})
|
|
1909
|
+
})
|
|
1910
|
+
});
|
|
1911
|
+
};
|
|
1912
|
+
|
|
1913
|
+
// src/create/iso-base-media/udta/create-meta.ts
|
|
1914
|
+
var createMeta = ({
|
|
1915
|
+
hdlr,
|
|
1916
|
+
ilst
|
|
1917
|
+
}) => {
|
|
1918
|
+
return addSize(combineUint8Arrays([
|
|
1919
|
+
stringsToUint8Array("meta"),
|
|
1920
|
+
new Uint8Array([0]),
|
|
1921
|
+
new Uint8Array([0, 0, 0]),
|
|
1922
|
+
hdlr,
|
|
1923
|
+
ilst
|
|
1924
|
+
]));
|
|
1925
|
+
};
|
|
1926
|
+
|
|
1927
|
+
// src/create/iso-base-media/mp4-header.ts
|
|
1928
|
+
var HEADER_LENGTH = 1024000;
|
|
1929
|
+
var createPaddedMoovAtom = ({
|
|
1930
|
+
durationInUnits,
|
|
1931
|
+
trackInfo,
|
|
1932
|
+
timescale
|
|
1933
|
+
}) => {
|
|
1934
|
+
return padIsoBaseMediaBytes(createMoov({
|
|
1935
|
+
mvhd: createMvhd({
|
|
1936
|
+
timescale,
|
|
1937
|
+
durationInUnits,
|
|
1938
|
+
matrix: IDENTITY_MATRIX,
|
|
1939
|
+
nextTrackId: trackInfo.map((t) => t.track.trackNumber).reduce((a, b) => Math.max(a, b), 0) + 1,
|
|
1940
|
+
rate: 1,
|
|
1941
|
+
volume: 1,
|
|
1942
|
+
creationTime: Date.now(),
|
|
1943
|
+
modificationTime: Date.now()
|
|
1944
|
+
}),
|
|
1945
|
+
traks: trackInfo.map((track) => {
|
|
1946
|
+
return serializeTrack({
|
|
1947
|
+
timescale,
|
|
1948
|
+
track: track.track,
|
|
1949
|
+
durationInUnits,
|
|
1950
|
+
samplePositions: track.samplePositions
|
|
1951
|
+
});
|
|
1952
|
+
}),
|
|
1953
|
+
udta: createUdta(createMeta({
|
|
1954
|
+
hdlr: createHdlr("mdir"),
|
|
1955
|
+
ilst: createIlst([
|
|
1956
|
+
createToo("WebCodecs"),
|
|
1957
|
+
createCmt("Made with @remotion/webcodecs")
|
|
1958
|
+
])
|
|
1959
|
+
}))
|
|
1960
|
+
}), HEADER_LENGTH);
|
|
1961
|
+
};
|
|
1962
|
+
|
|
1963
|
+
// src/create/iso-base-media/create-iso-base-media.ts
|
|
1964
|
+
var createIsoBaseMedia = async ({
|
|
1965
|
+
writer,
|
|
1966
|
+
onBytesProgress,
|
|
1967
|
+
onMillisecondsProgress,
|
|
1968
|
+
logLevel
|
|
1969
|
+
}) => {
|
|
1970
|
+
const header = createIsoBaseMediaFtyp({
|
|
1971
|
+
compatibleBrands: ["isom", "iso2", "avc1", "mp42"],
|
|
1972
|
+
majorBrand: "isom",
|
|
1973
|
+
minorBrand: 512
|
|
1974
|
+
});
|
|
1975
|
+
const w = await writer.createContent();
|
|
1976
|
+
await w.write(header);
|
|
1977
|
+
let durationInUnits = 0;
|
|
1978
|
+
const currentTracks = [];
|
|
1979
|
+
const samplePositions = [];
|
|
1980
|
+
const sampleChunkIndices = [];
|
|
1981
|
+
const moovOffset = w.getWrittenByteCount();
|
|
1982
|
+
const getPaddedMoovAtom = () => {
|
|
1983
|
+
return createPaddedMoovAtom({
|
|
1984
|
+
durationInUnits,
|
|
1985
|
+
trackInfo: currentTracks.map((track) => {
|
|
1986
|
+
return {
|
|
1987
|
+
track,
|
|
1988
|
+
durationInUnits,
|
|
1989
|
+
samplePositions: samplePositions[track.trackNumber] ?? [],
|
|
1990
|
+
timescale: track.timescale
|
|
1991
|
+
};
|
|
1992
|
+
}),
|
|
1993
|
+
timescale: 1000
|
|
1994
|
+
});
|
|
1995
|
+
};
|
|
1996
|
+
await w.write(getPaddedMoovAtom());
|
|
1997
|
+
let mdatSize = 8;
|
|
1998
|
+
const mdatSizeOffset = w.getWrittenByteCount();
|
|
1999
|
+
await w.write(combineUint8Arrays([
|
|
2000
|
+
numberTo32BitUIntOrInt(mdatSize),
|
|
2001
|
+
stringsToUint8Array("mdat")
|
|
2002
|
+
]));
|
|
2003
|
+
const updateMdatSize = async () => {
|
|
2004
|
+
await w.updateDataAt(mdatSizeOffset, numberTo32BitUIntOrInt(mdatSize));
|
|
2005
|
+
onBytesProgress(w.getWrittenByteCount());
|
|
2006
|
+
};
|
|
2007
|
+
const operationProm = { current: Promise.resolve() };
|
|
2008
|
+
const updateMoov = async () => {
|
|
2009
|
+
await w.updateDataAt(moovOffset, getPaddedMoovAtom());
|
|
2010
|
+
onBytesProgress(w.getWrittenByteCount());
|
|
2011
|
+
};
|
|
2012
|
+
const updateDuration = (newDuration) => {
|
|
2013
|
+
durationInUnits = newDuration;
|
|
2014
|
+
onMillisecondsProgress(newDuration);
|
|
2015
|
+
};
|
|
2016
|
+
const addCodecPrivateToTrack = ({
|
|
2017
|
+
trackNumber: trackNumber2,
|
|
2018
|
+
codecPrivate: codecPrivate2
|
|
2019
|
+
}) => {
|
|
2020
|
+
currentTracks.forEach((track) => {
|
|
2021
|
+
if (track.trackNumber === trackNumber2) {
|
|
2022
|
+
track.codecPrivate = codecPrivate2;
|
|
2023
|
+
}
|
|
2024
|
+
});
|
|
2025
|
+
};
|
|
2026
|
+
let lastChunkWasVideo = false;
|
|
2027
|
+
const addSample = async ({
|
|
2028
|
+
chunk,
|
|
2029
|
+
trackNumber: trackNumber2,
|
|
2030
|
+
isVideo,
|
|
2031
|
+
timescale,
|
|
2032
|
+
codecPrivate: codecPrivate2
|
|
2033
|
+
}) => {
|
|
2034
|
+
const position = w.getWrittenByteCount();
|
|
2035
|
+
await w.write(chunk.data);
|
|
2036
|
+
mdatSize += chunk.data.length;
|
|
2037
|
+
onBytesProgress(w.getWrittenByteCount());
|
|
2038
|
+
if (codecPrivate2) {
|
|
2039
|
+
addCodecPrivateToTrack({ trackNumber: trackNumber2, codecPrivate: codecPrivate2 });
|
|
2040
|
+
}
|
|
2041
|
+
const newDuration = Math.round((chunk.timestamp + (chunk.duration ?? 0)) / 1000);
|
|
2042
|
+
updateDuration(newDuration);
|
|
2043
|
+
if (!samplePositions[trackNumber2]) {
|
|
2044
|
+
samplePositions[trackNumber2] = [];
|
|
2045
|
+
}
|
|
2046
|
+
if (typeof sampleChunkIndices[trackNumber2] === "undefined") {
|
|
2047
|
+
sampleChunkIndices[trackNumber2] = 0;
|
|
2048
|
+
}
|
|
2049
|
+
if (isVideo && chunk.type === "key") {
|
|
2050
|
+
sampleChunkIndices[trackNumber2]++;
|
|
2051
|
+
} else if (!isVideo && samplePositions[trackNumber2].length % 22 === 0) {
|
|
2052
|
+
sampleChunkIndices[trackNumber2]++;
|
|
2053
|
+
} else if (lastChunkWasVideo !== isVideo) {
|
|
2054
|
+
sampleChunkIndices[trackNumber2]++;
|
|
2055
|
+
}
|
|
2056
|
+
const samplePositionToAdd = {
|
|
2057
|
+
isKeyframe: chunk.type === "key",
|
|
2058
|
+
offset: position,
|
|
2059
|
+
chunk: sampleChunkIndices[trackNumber2],
|
|
2060
|
+
cts: Math.round(chunk.cts / (1e6 / timescale)),
|
|
2061
|
+
dts: Math.round(chunk.dts / (1e6 / timescale)),
|
|
2062
|
+
duration: Math.round((chunk.duration ?? 0) / (1e6 / timescale)),
|
|
2063
|
+
size: chunk.data.length
|
|
2064
|
+
};
|
|
2065
|
+
lastChunkWasVideo = isVideo;
|
|
2066
|
+
samplePositions[trackNumber2].push(samplePositionToAdd);
|
|
2067
|
+
};
|
|
2068
|
+
const addTrack = (track) => {
|
|
2069
|
+
const trackNumber2 = currentTracks.length + 1;
|
|
2070
|
+
currentTracks.push({ ...track, trackNumber: trackNumber2 });
|
|
2071
|
+
return Promise.resolve({ trackNumber: trackNumber2 });
|
|
2072
|
+
};
|
|
2073
|
+
const waitForFinishPromises = [];
|
|
2074
|
+
return {
|
|
2075
|
+
save: async () => {
|
|
2076
|
+
const file = await w.save();
|
|
2077
|
+
return file;
|
|
2078
|
+
},
|
|
2079
|
+
remove: async () => {
|
|
2080
|
+
await w.remove();
|
|
2081
|
+
},
|
|
2082
|
+
addSample: ({ chunk, trackNumber: trackNumber2, isVideo, timescale, codecPrivate: codecPrivate2 }) => {
|
|
2083
|
+
operationProm.current = operationProm.current.then(() => {
|
|
2084
|
+
return addSample({
|
|
2085
|
+
chunk,
|
|
2086
|
+
trackNumber: trackNumber2,
|
|
2087
|
+
isVideo,
|
|
2088
|
+
timescale,
|
|
2089
|
+
codecPrivate: codecPrivate2
|
|
2090
|
+
});
|
|
2091
|
+
});
|
|
2092
|
+
return operationProm.current;
|
|
2093
|
+
},
|
|
2094
|
+
addTrack: (track) => {
|
|
2095
|
+
operationProm.current = operationProm.current.then(() => addTrack(track));
|
|
2096
|
+
return operationProm.current;
|
|
2097
|
+
},
|
|
2098
|
+
updateTrackSampleRate: ({ sampleRate, trackNumber: trackNumber2 }) => {
|
|
2099
|
+
currentTracks.forEach((track) => {
|
|
2100
|
+
if (track.trackNumber === trackNumber2) {
|
|
2101
|
+
if (track.type !== "audio") {
|
|
2102
|
+
throw new Error(`Tried to update sample rate of track ${trackNumber2}, but it's not an audio track`);
|
|
2103
|
+
}
|
|
2104
|
+
track.sampleRate = sampleRate;
|
|
2105
|
+
}
|
|
2106
|
+
});
|
|
2107
|
+
},
|
|
2108
|
+
addWaitForFinishPromise: (promise) => {
|
|
2109
|
+
waitForFinishPromises.push(promise);
|
|
2110
|
+
},
|
|
2111
|
+
async waitForFinish() {
|
|
2112
|
+
Log.verbose(logLevel, "All write operations queued. Waiting for finish...");
|
|
2113
|
+
await Promise.all(waitForFinishPromises.map((p) => p()));
|
|
2114
|
+
Log.verbose(logLevel, "Cleanup tasks executed");
|
|
2115
|
+
await operationProm.current;
|
|
2116
|
+
await updateMoov();
|
|
2117
|
+
await updateMdatSize();
|
|
2118
|
+
Log.verbose(logLevel, "All write operations done. Waiting for finish...");
|
|
2119
|
+
await w.waitForFinish();
|
|
2120
|
+
},
|
|
2121
|
+
updateDuration: (duration2) => {
|
|
2122
|
+
operationProm.current = operationProm.current.then(() => updateDuration(duration2));
|
|
2123
|
+
return operationProm.current;
|
|
2124
|
+
}
|
|
2125
|
+
};
|
|
2126
|
+
};
|
|
2127
|
+
|
|
2128
|
+
// src/create/matroska/cluster-segment.ts
|
|
1025
2129
|
var CLUSTER_MIN_VINT_WIDTH = 8;
|
|
1026
2130
|
var createClusterSegment = (timestamp) => {
|
|
1027
2131
|
return makeMatroskaBytes({
|
|
@@ -1062,32 +2166,30 @@ var makeSimpleBlock = ({
|
|
|
1062
2166
|
]);
|
|
1063
2167
|
};
|
|
1064
2168
|
|
|
1065
|
-
// src/create/
|
|
1066
|
-
var CREATE_TIME_SCALE = 1e6;
|
|
1067
|
-
|
|
1068
|
-
// src/create/cluster.ts
|
|
2169
|
+
// src/create/matroska/cluster.ts
|
|
1069
2170
|
var maxClusterTimestamp = 2 ** 15;
|
|
1070
|
-
var timestampToClusterTimestamp = (timestamp) => {
|
|
1071
|
-
return Math.round(timestamp /
|
|
2171
|
+
var timestampToClusterTimestamp = (timestamp, timescale) => {
|
|
2172
|
+
return Math.round(timestamp / timescale * 1000);
|
|
1072
2173
|
};
|
|
1073
2174
|
var canFitInCluster = ({
|
|
1074
2175
|
clusterStartTimestamp,
|
|
1075
|
-
chunk
|
|
2176
|
+
chunk,
|
|
2177
|
+
timescale
|
|
1076
2178
|
}) => {
|
|
1077
|
-
const timecodeRelativeToCluster = timestampToClusterTimestamp(chunk.timestamp) - timestampToClusterTimestamp(clusterStartTimestamp);
|
|
2179
|
+
const timecodeRelativeToCluster = timestampToClusterTimestamp(chunk.timestamp, timescale) - timestampToClusterTimestamp(clusterStartTimestamp, timescale);
|
|
1078
2180
|
if (timecodeRelativeToCluster < 0) {
|
|
1079
2181
|
throw new Error(`timecodeRelativeToCluster is negative`);
|
|
1080
2182
|
}
|
|
1081
2183
|
return timecodeRelativeToCluster <= maxClusterTimestamp;
|
|
1082
2184
|
};
|
|
1083
|
-
var makeCluster = async (w, clusterStartTimestamp) => {
|
|
1084
|
-
const cluster = createClusterSegment(timestampToClusterTimestamp(clusterStartTimestamp));
|
|
2185
|
+
var makeCluster = async (w, clusterStartTimestamp, timescale) => {
|
|
2186
|
+
const cluster = createClusterSegment(timestampToClusterTimestamp(clusterStartTimestamp, timescale));
|
|
1085
2187
|
const clusterVIntPosition = w.getWrittenByteCount() + cluster.offsets.offset + matroskaToHex(matroskaElements.Cluster).byteLength;
|
|
1086
2188
|
let clusterSize = cluster.bytes.byteLength - matroskaToHex(matroskaElements.Cluster).byteLength - CLUSTER_MIN_VINT_WIDTH;
|
|
1087
2189
|
await w.write(cluster.bytes);
|
|
1088
2190
|
const addSample = async (chunk, trackNumber2) => {
|
|
1089
|
-
const timecodeRelativeToCluster = timestampToClusterTimestamp(chunk.timestamp) - timestampToClusterTimestamp(clusterStartTimestamp);
|
|
1090
|
-
if (!canFitInCluster({ clusterStartTimestamp, chunk })) {
|
|
2191
|
+
const timecodeRelativeToCluster = timestampToClusterTimestamp(chunk.timestamp, timescale) - timestampToClusterTimestamp(clusterStartTimestamp, timescale);
|
|
2192
|
+
if (!canFitInCluster({ clusterStartTimestamp, chunk, timescale })) {
|
|
1091
2193
|
throw new Error(`timecodeRelativeToCluster is too big: ${timecodeRelativeToCluster} > ${maxClusterTimestamp}`);
|
|
1092
2194
|
}
|
|
1093
2195
|
const keyframe = chunk.type === "key";
|
|
@@ -1109,11 +2211,12 @@ var makeCluster = async (w, clusterStartTimestamp) => {
|
|
|
1109
2211
|
chunk,
|
|
1110
2212
|
newT
|
|
1111
2213
|
}) => {
|
|
1112
|
-
const newTimestamp = timestampToClusterTimestamp(newT);
|
|
1113
|
-
const oldTimestamp = timestampToClusterTimestamp(clusterStartTimestamp);
|
|
2214
|
+
const newTimestamp = timestampToClusterTimestamp(newT, timescale);
|
|
2215
|
+
const oldTimestamp = timestampToClusterTimestamp(clusterStartTimestamp, timescale);
|
|
1114
2216
|
const canFit = canFitInCluster({
|
|
1115
2217
|
chunk,
|
|
1116
|
-
clusterStartTimestamp
|
|
2218
|
+
clusterStartTimestamp,
|
|
2219
|
+
timescale
|
|
1117
2220
|
});
|
|
1118
2221
|
if (!canFit) {
|
|
1119
2222
|
return true;
|
|
@@ -1128,7 +2231,7 @@ var makeCluster = async (w, clusterStartTimestamp) => {
|
|
|
1128
2231
|
};
|
|
1129
2232
|
};
|
|
1130
2233
|
|
|
1131
|
-
// src/create/make-duration-with-padding.ts
|
|
2234
|
+
// src/create/matroska/make-duration-with-padding.ts
|
|
1132
2235
|
var makeDurationWithPadding = (newDuration) => {
|
|
1133
2236
|
return makeMatroskaBytes({
|
|
1134
2237
|
type: "Duration",
|
|
@@ -1140,7 +2243,7 @@ var makeDurationWithPadding = (newDuration) => {
|
|
|
1140
2243
|
});
|
|
1141
2244
|
};
|
|
1142
2245
|
|
|
1143
|
-
// src/create/matroska-cues.ts
|
|
2246
|
+
// src/create/matroska/matroska-cues.ts
|
|
1144
2247
|
var createMatroskaCues = (cues) => {
|
|
1145
2248
|
return makeMatroskaBytes({
|
|
1146
2249
|
type: "Cues",
|
|
@@ -1186,7 +2289,7 @@ var createMatroskaCues = (cues) => {
|
|
|
1186
2289
|
});
|
|
1187
2290
|
};
|
|
1188
2291
|
|
|
1189
|
-
// src/create/matroska-header.ts
|
|
2292
|
+
// src/create/matroska/matroska-header.ts
|
|
1190
2293
|
var makeMatroskaHeader = () => {
|
|
1191
2294
|
return makeMatroskaBytes({
|
|
1192
2295
|
type: "Header",
|
|
@@ -1249,7 +2352,7 @@ var makeMatroskaHeader = () => {
|
|
|
1249
2352
|
});
|
|
1250
2353
|
};
|
|
1251
2354
|
|
|
1252
|
-
// src/create/matroska-info.ts
|
|
2355
|
+
// src/create/matroska/matroska-info.ts
|
|
1253
2356
|
var makeMatroskaInfo = ({ timescale }) => {
|
|
1254
2357
|
return makeMatroskaBytes({
|
|
1255
2358
|
type: "Info",
|
|
@@ -1278,7 +2381,7 @@ var makeMatroskaInfo = ({ timescale }) => {
|
|
|
1278
2381
|
});
|
|
1279
2382
|
};
|
|
1280
2383
|
|
|
1281
|
-
// src/create/matroska-seek.ts
|
|
2384
|
+
// src/create/matroska/matroska-seek.ts
|
|
1282
2385
|
var createMatroskaSeekHead = (seeks) => {
|
|
1283
2386
|
return padMatroskaBytes(makeMatroskaBytes({
|
|
1284
2387
|
type: "SeekHead",
|
|
@@ -1307,7 +2410,7 @@ var createMatroskaSeekHead = (seeks) => {
|
|
|
1307
2410
|
}), 200);
|
|
1308
2411
|
};
|
|
1309
2412
|
|
|
1310
|
-
// src/create/matroska-segment.ts
|
|
2413
|
+
// src/create/matroska/matroska-segment.ts
|
|
1311
2414
|
var MATROSKA_SEGMENT_MIN_VINT_WIDTH = 8;
|
|
1312
2415
|
var createMatroskaSegment = (children) => {
|
|
1313
2416
|
return makeMatroskaBytes({
|
|
@@ -1317,11 +2420,6 @@ var createMatroskaSegment = (children) => {
|
|
|
1317
2420
|
});
|
|
1318
2421
|
};
|
|
1319
2422
|
|
|
1320
|
-
// src/truthy.ts
|
|
1321
|
-
function truthy(value) {
|
|
1322
|
-
return Boolean(value);
|
|
1323
|
-
}
|
|
1324
|
-
|
|
1325
2423
|
// src/boxes/webm/traversal.ts
|
|
1326
2424
|
var getMainSegment = (segments) => {
|
|
1327
2425
|
return segments.find((s) => s.type === "Segment");
|
|
@@ -1584,7 +2682,7 @@ var makeMatroskaColorBytes = ({
|
|
|
1584
2682
|
});
|
|
1585
2683
|
};
|
|
1586
2684
|
|
|
1587
|
-
// src/create/matroska-trackentry.ts
|
|
2685
|
+
// src/create/matroska/matroska-trackentry.ts
|
|
1588
2686
|
var makeMatroskaVideoBytes = ({
|
|
1589
2687
|
color: color2,
|
|
1590
2688
|
width,
|
|
@@ -1824,15 +2922,20 @@ var makeMatroskaVideoTrackEntryBytes = ({
|
|
|
1824
2922
|
});
|
|
1825
2923
|
};
|
|
1826
2924
|
var makeMatroskaTracks = (tracks2) => {
|
|
2925
|
+
const bytesArr = tracks2.map((t) => {
|
|
2926
|
+
const bytes = t.type === "video" ? makeMatroskaVideoTrackEntryBytes(t) : makeMatroskaAudioTrackEntryBytes(t);
|
|
2927
|
+
return bytes;
|
|
2928
|
+
});
|
|
1827
2929
|
return padMatroskaBytes(makeMatroskaBytes({
|
|
1828
2930
|
type: "Tracks",
|
|
1829
|
-
value:
|
|
2931
|
+
value: bytesArr,
|
|
1830
2932
|
minVintWidth: null
|
|
1831
2933
|
}), 500);
|
|
1832
2934
|
};
|
|
1833
2935
|
|
|
1834
|
-
// src/create/create-media.ts
|
|
1835
|
-
var
|
|
2936
|
+
// src/create/matroska/create-matroska-media.ts
|
|
2937
|
+
var timescale = 1e6;
|
|
2938
|
+
var createMatroskaMedia = async ({
|
|
1836
2939
|
writer,
|
|
1837
2940
|
onBytesProgress,
|
|
1838
2941
|
onMillisecondsProgress
|
|
@@ -1841,7 +2944,7 @@ var createMedia = async ({
|
|
|
1841
2944
|
const w = await writer.createContent();
|
|
1842
2945
|
await w.write(header.bytes);
|
|
1843
2946
|
const matroskaInfo = makeMatroskaInfo({
|
|
1844
|
-
timescale
|
|
2947
|
+
timescale
|
|
1845
2948
|
});
|
|
1846
2949
|
const currentTracks = [];
|
|
1847
2950
|
const seeks = [];
|
|
@@ -1890,7 +2993,7 @@ var createMedia = async ({
|
|
|
1890
2993
|
};
|
|
1891
2994
|
await w.write(matroskaSegment.bytes);
|
|
1892
2995
|
const clusterOffset = w.getWrittenByteCount();
|
|
1893
|
-
let currentCluster = await makeCluster(w, 0);
|
|
2996
|
+
let currentCluster = await makeCluster(w, 0, timescale);
|
|
1894
2997
|
seeks.push({
|
|
1895
2998
|
hexString: matroskaElements.Cluster,
|
|
1896
2999
|
byte: clusterOffset - seekHeadOffset
|
|
@@ -1908,7 +3011,7 @@ var createMedia = async ({
|
|
|
1908
3011
|
})) {
|
|
1909
3012
|
return { cluster: currentCluster, isNew: false, smallestProgress };
|
|
1910
3013
|
}
|
|
1911
|
-
currentCluster = await makeCluster(w, smallestProgress);
|
|
3014
|
+
currentCluster = await makeCluster(w, smallestProgress, timescale);
|
|
1912
3015
|
return { cluster: currentCluster, isNew: true, smallestProgress };
|
|
1913
3016
|
};
|
|
1914
3017
|
const updateDuration = async (newDuration) => {
|
|
@@ -1916,7 +3019,11 @@ var createMedia = async ({
|
|
|
1916
3019
|
await w.updateDataAt(durationOffset, blocks.bytes);
|
|
1917
3020
|
onBytesProgress(w.getWrittenByteCount());
|
|
1918
3021
|
};
|
|
1919
|
-
const addSample = async (
|
|
3022
|
+
const addSample = async ({
|
|
3023
|
+
chunk,
|
|
3024
|
+
trackNumber: trackNumber2,
|
|
3025
|
+
isVideo
|
|
3026
|
+
}) => {
|
|
1920
3027
|
trackNumberProgresses[trackNumber2] = chunk.timestamp;
|
|
1921
3028
|
const { cluster, isNew, smallestProgress } = await getClusterOrMakeNew({
|
|
1922
3029
|
chunk,
|
|
@@ -1928,7 +3035,7 @@ var createMedia = async ({
|
|
|
1928
3035
|
if (isNew) {
|
|
1929
3036
|
const newCluster = w.getWrittenByteCount();
|
|
1930
3037
|
cues.push({
|
|
1931
|
-
time: timestampToClusterTimestamp(smallestProgress) + timecodeRelativeToCluster,
|
|
3038
|
+
time: timestampToClusterTimestamp(smallestProgress, timescale) + timecodeRelativeToCluster,
|
|
1932
3039
|
clusterPosition: newCluster - seekHeadOffset,
|
|
1933
3040
|
trackNumber: trackNumber2
|
|
1934
3041
|
});
|
|
@@ -1944,6 +3051,16 @@ var createMedia = async ({
|
|
|
1944
3051
|
const operationProm = { current: Promise.resolve() };
|
|
1945
3052
|
const waitForFinishPromises = [];
|
|
1946
3053
|
return {
|
|
3054
|
+
updateTrackSampleRate: ({ sampleRate, trackNumber: trackNumber2 }) => {
|
|
3055
|
+
currentTracks.forEach((track) => {
|
|
3056
|
+
if (track.trackNumber === trackNumber2) {
|
|
3057
|
+
if (track.type !== "audio") {
|
|
3058
|
+
throw new Error("track is not audio");
|
|
3059
|
+
}
|
|
3060
|
+
track.sampleRate = sampleRate;
|
|
3061
|
+
}
|
|
3062
|
+
});
|
|
3063
|
+
},
|
|
1947
3064
|
save: async () => {
|
|
1948
3065
|
const file = await w.save();
|
|
1949
3066
|
return file;
|
|
@@ -1951,8 +3068,8 @@ var createMedia = async ({
|
|
|
1951
3068
|
remove: async () => {
|
|
1952
3069
|
await w.remove();
|
|
1953
3070
|
},
|
|
1954
|
-
addSample: (chunk, trackNumber2, isVideo) => {
|
|
1955
|
-
operationProm.current = operationProm.current.then(() => addSample(chunk, trackNumber2, isVideo));
|
|
3071
|
+
addSample: ({ chunk, trackNumber: trackNumber2, isVideo }) => {
|
|
3072
|
+
operationProm.current = operationProm.current.then(() => addSample({ chunk, trackNumber: trackNumber2, isVideo }));
|
|
1956
3073
|
return operationProm.current;
|
|
1957
3074
|
},
|
|
1958
3075
|
updateDuration: (duration2) => {
|
|
@@ -1961,8 +3078,7 @@ var createMedia = async ({
|
|
|
1961
3078
|
},
|
|
1962
3079
|
addTrack: (track) => {
|
|
1963
3080
|
const trackNumber2 = currentTracks.length + 1;
|
|
1964
|
-
|
|
1965
|
-
operationProm.current = operationProm.current.then(() => addTrack(bytes));
|
|
3081
|
+
operationProm.current = operationProm.current.then(() => addTrack({ ...track, trackNumber: trackNumber2 }));
|
|
1966
3082
|
trackNumbers.push(trackNumber2);
|
|
1967
3083
|
return operationProm.current.then(() => ({ trackNumber: trackNumber2 }));
|
|
1968
3084
|
},
|
|
@@ -1985,40 +3101,6 @@ var createMedia = async ({
|
|
|
1985
3101
|
};
|
|
1986
3102
|
};
|
|
1987
3103
|
|
|
1988
|
-
// src/log.ts
|
|
1989
|
-
var logLevels = ["trace", "verbose", "info", "warn", "error"];
|
|
1990
|
-
var getNumberForLogLevel = (level) => {
|
|
1991
|
-
return logLevels.indexOf(level);
|
|
1992
|
-
};
|
|
1993
|
-
var isEqualOrBelowLogLevel = (currentLevel, level) => {
|
|
1994
|
-
return getNumberForLogLevel(currentLevel) <= getNumberForLogLevel(level);
|
|
1995
|
-
};
|
|
1996
|
-
var Log = {
|
|
1997
|
-
trace: (logLevel, ...args) => {
|
|
1998
|
-
if (isEqualOrBelowLogLevel(logLevel, "trace")) {
|
|
1999
|
-
return console.log(...args);
|
|
2000
|
-
}
|
|
2001
|
-
},
|
|
2002
|
-
verbose: (logLevel, ...args) => {
|
|
2003
|
-
if (isEqualOrBelowLogLevel(logLevel, "verbose")) {
|
|
2004
|
-
return console.log(...args);
|
|
2005
|
-
}
|
|
2006
|
-
},
|
|
2007
|
-
info: (logLevel, ...args) => {
|
|
2008
|
-
if (isEqualOrBelowLogLevel(logLevel, "info")) {
|
|
2009
|
-
return console.log(...args);
|
|
2010
|
-
}
|
|
2011
|
-
},
|
|
2012
|
-
warn: (logLevel, ...args) => {
|
|
2013
|
-
if (isEqualOrBelowLogLevel(logLevel, "warn")) {
|
|
2014
|
-
return console.warn(...args);
|
|
2015
|
-
}
|
|
2016
|
-
},
|
|
2017
|
-
error: (...args) => {
|
|
2018
|
-
return console.error(...args);
|
|
2019
|
-
}
|
|
2020
|
-
};
|
|
2021
|
-
|
|
2022
3104
|
// src/boxes/iso-base-media/traversal.ts
|
|
2023
3105
|
var getMoovBox = (segments) => {
|
|
2024
3106
|
const moovBox = segments.find((s) => s.type === "moov-box");
|
|
@@ -2227,21 +3309,12 @@ var getTimescaleAndDuration = (trakBox) => {
|
|
|
2227
3309
|
}
|
|
2228
3310
|
return null;
|
|
2229
3311
|
};
|
|
2230
|
-
var
|
|
2231
|
-
const
|
|
2232
|
-
if (!moovBox) {
|
|
2233
|
-
return null;
|
|
2234
|
-
}
|
|
2235
|
-
const trackBoxes = getTraks(moovBox);
|
|
2236
|
-
const trackBox = trackBoxes.find(trakBoxContainsVideo);
|
|
2237
|
-
if (!trackBox) {
|
|
2238
|
-
return null;
|
|
2239
|
-
}
|
|
2240
|
-
const timescaleAndDuration = getTimescaleAndDuration(trackBox);
|
|
3312
|
+
var getFpsFromMp4TrakBox = (trakBox) => {
|
|
3313
|
+
const timescaleAndDuration = getTimescaleAndDuration(trakBox);
|
|
2241
3314
|
if (!timescaleAndDuration) {
|
|
2242
3315
|
return null;
|
|
2243
3316
|
}
|
|
2244
|
-
const sttsBox = getSttsBox(
|
|
3317
|
+
const sttsBox = getSttsBox(trakBox);
|
|
2245
3318
|
if (!sttsBox) {
|
|
2246
3319
|
return null;
|
|
2247
3320
|
}
|
|
@@ -2251,6 +3324,18 @@ var getFps = (segments) => {
|
|
|
2251
3324
|
durationInSamples: timescaleAndDuration.duration
|
|
2252
3325
|
});
|
|
2253
3326
|
};
|
|
3327
|
+
var getFps = (segments) => {
|
|
3328
|
+
const moovBox = getMoovBox(segments);
|
|
3329
|
+
if (!moovBox) {
|
|
3330
|
+
return null;
|
|
3331
|
+
}
|
|
3332
|
+
const trackBoxes = getTraks(moovBox);
|
|
3333
|
+
const trackBox = trackBoxes.find(trakBoxContainsVideo);
|
|
3334
|
+
if (!trackBox) {
|
|
3335
|
+
return null;
|
|
3336
|
+
}
|
|
3337
|
+
return getFpsFromMp4TrakBox(trackBox);
|
|
3338
|
+
};
|
|
2254
3339
|
var hasFps = (boxes) => {
|
|
2255
3340
|
try {
|
|
2256
3341
|
return getFps(boxes) !== null;
|
|
@@ -2300,9 +3385,9 @@ var getCodecSpecificatorFromEsdsBox = ({
|
|
|
2300
3385
|
};
|
|
2301
3386
|
}
|
|
2302
3387
|
const audioSpecificConfig = descriptor.decoderSpecificConfigs.find((d) => {
|
|
2303
|
-
return d.type === "
|
|
3388
|
+
return d.type === "mp4a-specific-config" ? d : null;
|
|
2304
3389
|
});
|
|
2305
|
-
if (!audioSpecificConfig || audioSpecificConfig.type !== "
|
|
3390
|
+
if (!audioSpecificConfig || audioSpecificConfig.type !== "mp4a-specific-config") {
|
|
2306
3391
|
throw new Error("No audio-specific-config");
|
|
2307
3392
|
}
|
|
2308
3393
|
return {
|
|
@@ -2311,6 +3396,29 @@ var getCodecSpecificatorFromEsdsBox = ({
|
|
|
2311
3396
|
description: audioSpecificConfig.asBytes
|
|
2312
3397
|
};
|
|
2313
3398
|
};
|
|
3399
|
+
var getCodecPrivateFromTrak = (trakBox) => {
|
|
3400
|
+
const stsdBox = getStsdBox(trakBox);
|
|
3401
|
+
if (!stsdBox) {
|
|
3402
|
+
return null;
|
|
3403
|
+
}
|
|
3404
|
+
const audioSample = stsdBox.samples.find((s) => s.type === "audio");
|
|
3405
|
+
if (!audioSample || audioSample.type !== "audio") {
|
|
3406
|
+
return null;
|
|
3407
|
+
}
|
|
3408
|
+
const esds = audioSample.children.find((b) => b.type === "esds-box");
|
|
3409
|
+
if (!esds || esds.type !== "esds-box") {
|
|
3410
|
+
return null;
|
|
3411
|
+
}
|
|
3412
|
+
const decoderConfigDescriptor = esds.descriptors.find((d) => d.type === "decoder-config-descriptor");
|
|
3413
|
+
if (!decoderConfigDescriptor) {
|
|
3414
|
+
return null;
|
|
3415
|
+
}
|
|
3416
|
+
const mp4a = decoderConfigDescriptor.decoderSpecificConfigs.find((d) => d.type === "mp4a-specific-config");
|
|
3417
|
+
if (!mp4a) {
|
|
3418
|
+
return null;
|
|
3419
|
+
}
|
|
3420
|
+
return mp4a.asBytes;
|
|
3421
|
+
};
|
|
2314
3422
|
var onSample = (sample, children) => {
|
|
2315
3423
|
const child = children.find((c) => c.type === "esds-box");
|
|
2316
3424
|
if (child && child.type === "esds-box") {
|
|
@@ -2655,14 +3763,7 @@ var getArrayBufferIterator = (initialData, maxBytes) => {
|
|
|
2655
3763
|
]);
|
|
2656
3764
|
return Number(bigInt);
|
|
2657
3765
|
};
|
|
2658
|
-
const getFourByteNumber = (
|
|
2659
|
-
if (littleEndian) {
|
|
2660
|
-
const one = getUint8();
|
|
2661
|
-
const two = getUint8();
|
|
2662
|
-
const three = getUint8();
|
|
2663
|
-
const four = getUint8();
|
|
2664
|
-
return four << 24 | three << 16 | two << 8 | one;
|
|
2665
|
-
}
|
|
3766
|
+
const getFourByteNumber = () => {
|
|
2666
3767
|
return getUint8() << 24 | getUint8() << 16 | getUint8() << 8 | getUint8();
|
|
2667
3768
|
};
|
|
2668
3769
|
const getPaddedFourByteNumber = () => {
|
|
@@ -3016,7 +4117,7 @@ var parseAv1PrivateData = (data, colrAtom) => {
|
|
|
3016
4117
|
const chroma_sample_position = iterator.getBits(2);
|
|
3017
4118
|
str += subsampling_x && subsampling_y ? chroma_sample_position === 1 ? "1" : "0" : "0";
|
|
3018
4119
|
str += ".";
|
|
3019
|
-
if (colrAtom) {
|
|
4120
|
+
if (colrAtom && colrAtom.colorType === "transfer-characteristics") {
|
|
3020
4121
|
str += colrAtom.primaries.toString().padStart(2, "0");
|
|
3021
4122
|
str += ".";
|
|
3022
4123
|
str += colrAtom.transfer.toString().padStart(2, "0");
|
|
@@ -3159,6 +4260,9 @@ var getIsoBmColrConfig = (trakBox) => {
|
|
|
3159
4260
|
if (!colrAtom) {
|
|
3160
4261
|
return null;
|
|
3161
4262
|
}
|
|
4263
|
+
if (colrAtom.colorType !== "transfer-characteristics") {
|
|
4264
|
+
return null;
|
|
4265
|
+
}
|
|
3162
4266
|
return {
|
|
3163
4267
|
fullRange: colrAtom.fullRangeFlag,
|
|
3164
4268
|
matrixCoefficients: colrAtom.matrixIndex === 1 ? "bt709" : colrAtom.matrixIndex === 5 ? "bt470bg" : colrAtom.matrixIndex === 6 ? "smpte170m" : null,
|
|
@@ -3217,7 +4321,7 @@ var makeBaseMediaTrack = (trakBox) => {
|
|
|
3217
4321
|
sampleRate,
|
|
3218
4322
|
description,
|
|
3219
4323
|
trakBox,
|
|
3220
|
-
codecPrivate:
|
|
4324
|
+
codecPrivate: getCodecPrivateFromTrak(trakBox),
|
|
3221
4325
|
codecWithoutConfig: getAudioCodecFromTrack(trakBox)
|
|
3222
4326
|
};
|
|
3223
4327
|
}
|
|
@@ -3270,7 +4374,8 @@ var makeBaseMediaTrack = (trakBox) => {
|
|
|
3270
4374
|
primaries: null,
|
|
3271
4375
|
transferCharacteristics: null
|
|
3272
4376
|
},
|
|
3273
|
-
codecWithoutConfig: getVideoCodecFromIsoTrak(trakBox)
|
|
4377
|
+
codecWithoutConfig: getVideoCodecFromIsoTrak(trakBox),
|
|
4378
|
+
fps: getFpsFromMp4TrakBox(trakBox)
|
|
3274
4379
|
};
|
|
3275
4380
|
return track;
|
|
3276
4381
|
};
|
|
@@ -3534,7 +4639,7 @@ var getMatroskaAudioCodecString = (track) => {
|
|
|
3534
4639
|
throw new Error(`Unknown codec: ${codec.value}`);
|
|
3535
4640
|
};
|
|
3536
4641
|
var getTrack = ({
|
|
3537
|
-
timescale,
|
|
4642
|
+
timescale: timescale2,
|
|
3538
4643
|
track
|
|
3539
4644
|
}) => {
|
|
3540
4645
|
const trackType2 = getTrackTypeSegment(track);
|
|
@@ -3577,7 +4682,7 @@ var getTrack = ({
|
|
|
3577
4682
|
numerator: 1,
|
|
3578
4683
|
denominator: 1
|
|
3579
4684
|
},
|
|
3580
|
-
timescale,
|
|
4685
|
+
timescale: timescale2,
|
|
3581
4686
|
codedHeight: height.value.value,
|
|
3582
4687
|
codedWidth: width.value.value,
|
|
3583
4688
|
displayAspectHeight: displayHeight2 ? displayHeight2.value.value : height.value.value,
|
|
@@ -3593,7 +4698,8 @@ var getTrack = ({
|
|
|
3593
4698
|
},
|
|
3594
4699
|
codecWithoutConfig: getMatroskaVideoCodecWithoutConfigString({
|
|
3595
4700
|
codecSegment: codec
|
|
3596
|
-
})
|
|
4701
|
+
}),
|
|
4702
|
+
fps: null
|
|
3597
4703
|
};
|
|
3598
4704
|
}
|
|
3599
4705
|
if (trackTypeToString(trackType2.value.value) === "audio") {
|
|
@@ -3607,7 +4713,7 @@ var getTrack = ({
|
|
|
3607
4713
|
type: "audio",
|
|
3608
4714
|
trackId,
|
|
3609
4715
|
codec: getMatroskaAudioCodecString(track),
|
|
3610
|
-
timescale,
|
|
4716
|
+
timescale: timescale2,
|
|
3611
4717
|
numberOfChannels,
|
|
3612
4718
|
sampleRate,
|
|
3613
4719
|
description: getAudioDescription(track),
|
|
@@ -3622,7 +4728,7 @@ var getTrack = ({
|
|
|
3622
4728
|
};
|
|
3623
4729
|
|
|
3624
4730
|
// src/boxes/webm/get-ready-tracks.ts
|
|
3625
|
-
var getTracksFromMatroska = (segment,
|
|
4731
|
+
var getTracksFromMatroska = (segment, timescale2) => {
|
|
3626
4732
|
const tracksSegment = getTracksSegment(segment);
|
|
3627
4733
|
if (!tracksSegment) {
|
|
3628
4734
|
throw new Error("No tracks segment");
|
|
@@ -3637,7 +4743,7 @@ var getTracksFromMatroska = (segment, timescale) => {
|
|
|
3637
4743
|
}
|
|
3638
4744
|
const track = getTrack({
|
|
3639
4745
|
track: trackEntrySegment,
|
|
3640
|
-
timescale
|
|
4746
|
+
timescale: timescale2
|
|
3641
4747
|
});
|
|
3642
4748
|
if (track) {
|
|
3643
4749
|
tracks2.push(track);
|
|
@@ -3806,7 +4912,8 @@ var getSamplePositions = ({
|
|
|
3806
4912
|
isKeyframe,
|
|
3807
4913
|
dts,
|
|
3808
4914
|
cts,
|
|
3809
|
-
duration: delta
|
|
4915
|
+
duration: delta,
|
|
4916
|
+
chunk: i
|
|
3810
4917
|
});
|
|
3811
4918
|
dts += delta;
|
|
3812
4919
|
offsetInThisChunk += size;
|
|
@@ -3859,7 +4966,8 @@ var getSamplesFromTraf = (trafSegment, moofOffset) => {
|
|
|
3859
4966
|
cts: dts,
|
|
3860
4967
|
duration: duration2,
|
|
3861
4968
|
isKeyframe: keyframe,
|
|
3862
|
-
size
|
|
4969
|
+
size,
|
|
4970
|
+
chunk: 0
|
|
3863
4971
|
};
|
|
3864
4972
|
samples.push(samplePosition);
|
|
3865
4973
|
offset += size;
|
|
@@ -4169,7 +5277,7 @@ var getAvailableInfo = (options, parseResult, state) => {
|
|
|
4169
5277
|
};
|
|
4170
5278
|
|
|
4171
5279
|
// src/boxes/iso-base-media/esds/decoder-specific-config.ts
|
|
4172
|
-
var parseDecoderSpecificConfig = (iterator) => {
|
|
5280
|
+
var parseDecoderSpecificConfig = (iterator, logLevel) => {
|
|
4173
5281
|
const layerTag = iterator.getUint8();
|
|
4174
5282
|
const layerSize = iterator.getPaddedFourByteNumber();
|
|
4175
5283
|
const start = iterator.counter.getOffset();
|
|
@@ -4193,13 +5301,15 @@ var parseDecoderSpecificConfig = (iterator) => {
|
|
|
4193
5301
|
if (read < layerSize) {
|
|
4194
5302
|
iterator.discard(layerSize - read);
|
|
4195
5303
|
}
|
|
4196
|
-
|
|
5304
|
+
if (bytes.byteLength === 2 && bytes[0] === 17 && bytes[1] === 136) {
|
|
5305
|
+
Log.warn(logLevel, "Chrome has a bug and might not be able to decode this audio. It will be fixed, see: https://issues.chromium.org/issues/360083330");
|
|
5306
|
+
}
|
|
4197
5307
|
return {
|
|
4198
|
-
type: "
|
|
5308
|
+
type: "mp4a-specific-config",
|
|
4199
5309
|
audioObjectType,
|
|
4200
5310
|
samplingFrequencyIndex,
|
|
4201
5311
|
channelConfiguration,
|
|
4202
|
-
asBytes:
|
|
5312
|
+
asBytes: bytes
|
|
4203
5313
|
};
|
|
4204
5314
|
};
|
|
4205
5315
|
|
|
@@ -4214,7 +5324,8 @@ var mapToObjectAudioIndicator = (num) => {
|
|
|
4214
5324
|
return "unknown";
|
|
4215
5325
|
};
|
|
4216
5326
|
var processDescriptor = ({
|
|
4217
|
-
iterator
|
|
5327
|
+
iterator,
|
|
5328
|
+
logLevel
|
|
4218
5329
|
}) => {
|
|
4219
5330
|
const tag = iterator.getUint8();
|
|
4220
5331
|
if (tag === 4) {
|
|
@@ -4230,8 +5341,8 @@ var processDescriptor = ({
|
|
|
4230
5341
|
const maxBitrate = iterator.getUint32();
|
|
4231
5342
|
const avgBitrate = iterator.getUint32();
|
|
4232
5343
|
const decoderSpecificConfigs = [];
|
|
4233
|
-
while (size - (iterator.counter.getOffset() - initialOffset)
|
|
4234
|
-
const decoderSpecificConfig = parseDecoderSpecificConfig(iterator);
|
|
5344
|
+
while (size - (iterator.counter.getOffset() - initialOffset) > 0) {
|
|
5345
|
+
const decoderSpecificConfig = parseDecoderSpecificConfig(iterator, logLevel);
|
|
4235
5346
|
decoderSpecificConfigs.push(decoderSpecificConfig);
|
|
4236
5347
|
}
|
|
4237
5348
|
return {
|
|
@@ -4261,12 +5372,13 @@ var processDescriptor = ({
|
|
|
4261
5372
|
descriptor: null
|
|
4262
5373
|
};
|
|
4263
5374
|
};
|
|
4264
|
-
var parseDescriptors = (iterator, maxBytes) => {
|
|
5375
|
+
var parseDescriptors = (iterator, maxBytes, logLevel) => {
|
|
4265
5376
|
const descriptors = [];
|
|
4266
5377
|
const initialOffset = iterator.counter.getOffset();
|
|
4267
5378
|
while (iterator.bytesRemaining() > 0 && iterator.counter.getOffset() - initialOffset < maxBytes) {
|
|
4268
5379
|
const { descriptor } = processDescriptor({
|
|
4269
|
-
iterator
|
|
5380
|
+
iterator,
|
|
5381
|
+
logLevel
|
|
4270
5382
|
});
|
|
4271
5383
|
if (descriptor) {
|
|
4272
5384
|
descriptors.push(descriptor);
|
|
@@ -4281,7 +5393,8 @@ var parseDescriptors = (iterator, maxBytes) => {
|
|
|
4281
5393
|
var parseEsds = ({
|
|
4282
5394
|
data,
|
|
4283
5395
|
size,
|
|
4284
|
-
fileOffset
|
|
5396
|
+
fileOffset,
|
|
5397
|
+
logLevel
|
|
4285
5398
|
}) => {
|
|
4286
5399
|
const version = data.getUint8();
|
|
4287
5400
|
data.discard(3);
|
|
@@ -4290,7 +5403,7 @@ var parseEsds = ({
|
|
|
4290
5403
|
const esId = data.getUint16();
|
|
4291
5404
|
data.discard(1);
|
|
4292
5405
|
const remaining = size - (data.counter.getOffset() - fileOffset);
|
|
4293
|
-
const descriptors = parseDescriptors(data, remaining);
|
|
5406
|
+
const descriptors = parseDescriptors(data, remaining, logLevel);
|
|
4294
5407
|
const remainingNow = size - (data.counter.getOffset() - fileOffset);
|
|
4295
5408
|
data.discard(remainingNow);
|
|
4296
5409
|
return {
|
|
@@ -4397,15 +5510,19 @@ var parseMdat = async ({
|
|
|
4397
5510
|
break;
|
|
4398
5511
|
}
|
|
4399
5512
|
const bytes = data.getSlice(samplesWithIndex.samplePosition.size);
|
|
4400
|
-
const timestamp =
|
|
4401
|
-
const duration2 =
|
|
5513
|
+
const timestamp = samplesWithIndex.samplePosition.cts * 1e6 / samplesWithIndex.track.timescale;
|
|
5514
|
+
const duration2 = samplesWithIndex.samplePosition.duration * 1e6 / samplesWithIndex.track.timescale;
|
|
5515
|
+
const cts = samplesWithIndex.samplePosition.cts * 1e6 / samplesWithIndex.track.timescale;
|
|
5516
|
+
const dts = samplesWithIndex.samplePosition.dts * 1e6 / samplesWithIndex.track.timescale;
|
|
4402
5517
|
if (samplesWithIndex.track.type === "audio") {
|
|
4403
5518
|
await options.parserState.onAudioSample(samplesWithIndex.track.trackId, {
|
|
4404
5519
|
data: bytes,
|
|
4405
5520
|
timestamp,
|
|
5521
|
+
duration: duration2,
|
|
5522
|
+
cts,
|
|
5523
|
+
dts,
|
|
4406
5524
|
trackId: samplesWithIndex.track.trackId,
|
|
4407
|
-
type: samplesWithIndex.samplePosition.isKeyframe ? "key" : "delta"
|
|
4408
|
-
duration: duration2
|
|
5525
|
+
type: samplesWithIndex.samplePosition.isKeyframe ? "key" : "delta"
|
|
4409
5526
|
});
|
|
4410
5527
|
}
|
|
4411
5528
|
if (samplesWithIndex.track.type === "video") {
|
|
@@ -4413,8 +5530,8 @@ var parseMdat = async ({
|
|
|
4413
5530
|
data: bytes,
|
|
4414
5531
|
timestamp,
|
|
4415
5532
|
duration: duration2,
|
|
4416
|
-
cts
|
|
4417
|
-
dts
|
|
5533
|
+
cts,
|
|
5534
|
+
dts,
|
|
4418
5535
|
trackId: samplesWithIndex.track.trackId,
|
|
4419
5536
|
type: samplesWithIndex.samplePosition.isKeyframe ? "key" : "delta"
|
|
4420
5537
|
});
|
|
@@ -4443,7 +5560,7 @@ var parseMdhd = ({
|
|
|
4443
5560
|
data.discard(3);
|
|
4444
5561
|
const creationTime = version === 1 ? Number(data.getUint64()) : data.getUint32();
|
|
4445
5562
|
const modificationTime = version === 1 ? Number(data.getUint64()) : data.getUint32();
|
|
4446
|
-
const
|
|
5563
|
+
const timescale2 = data.getUint32();
|
|
4447
5564
|
const duration2 = version === 1 ? data.getUint64() : data.getUint32();
|
|
4448
5565
|
const language2 = data.getUint16();
|
|
4449
5566
|
const quality = data.getUint16();
|
|
@@ -4454,7 +5571,7 @@ var parseMdhd = ({
|
|
|
4454
5571
|
return {
|
|
4455
5572
|
type: "mdhd-box",
|
|
4456
5573
|
duration: Number(duration2),
|
|
4457
|
-
timescale,
|
|
5574
|
+
timescale: timescale2,
|
|
4458
5575
|
version,
|
|
4459
5576
|
language: language2,
|
|
4460
5577
|
quality,
|
|
@@ -4469,7 +5586,8 @@ var parseMoov = async ({
|
|
|
4469
5586
|
offset,
|
|
4470
5587
|
size,
|
|
4471
5588
|
options,
|
|
4472
|
-
signal
|
|
5589
|
+
signal,
|
|
5590
|
+
logLevel
|
|
4473
5591
|
}) => {
|
|
4474
5592
|
const children = await parseBoxes({
|
|
4475
5593
|
iterator,
|
|
@@ -4478,8 +5596,8 @@ var parseMoov = async ({
|
|
|
4478
5596
|
initialBoxes: [],
|
|
4479
5597
|
options,
|
|
4480
5598
|
continueMdat: false,
|
|
4481
|
-
|
|
4482
|
-
|
|
5599
|
+
signal,
|
|
5600
|
+
logLevel
|
|
4483
5601
|
});
|
|
4484
5602
|
if (children.status === "incomplete") {
|
|
4485
5603
|
throw new Error("Incomplete boxes are not allowed");
|
|
@@ -4492,15 +5610,6 @@ var parseMoov = async ({
|
|
|
4492
5610
|
};
|
|
4493
5611
|
};
|
|
4494
5612
|
|
|
4495
|
-
// src/boxes/iso-base-media/to-date.ts
|
|
4496
|
-
var toUnixTimestamp = (value) => {
|
|
4497
|
-
if (value === 0) {
|
|
4498
|
-
return null;
|
|
4499
|
-
}
|
|
4500
|
-
const baseDate = new Date("1904-01-01T00:00:00Z");
|
|
4501
|
-
return Math.floor(value + baseDate.getTime() / 1000) * 1000;
|
|
4502
|
-
};
|
|
4503
|
-
|
|
4504
5613
|
// src/boxes/iso-base-media/mvhd.ts
|
|
4505
5614
|
var parseMvhd = ({
|
|
4506
5615
|
iterator,
|
|
@@ -4523,14 +5632,17 @@ var parseMvhd = ({
|
|
|
4523
5632
|
iterator.discard(2);
|
|
4524
5633
|
iterator.discard(4);
|
|
4525
5634
|
iterator.discard(4);
|
|
4526
|
-
const matrix = [
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
5635
|
+
const matrix = [
|
|
5636
|
+
iterator.getFixedPointSigned1616Number(),
|
|
5637
|
+
iterator.getFixedPointSigned1616Number(),
|
|
5638
|
+
iterator.getFixedPointSigned230Number(),
|
|
5639
|
+
iterator.getFixedPointSigned1616Number(),
|
|
5640
|
+
iterator.getFixedPointSigned1616Number(),
|
|
5641
|
+
iterator.getFixedPointSigned230Number(),
|
|
5642
|
+
iterator.getFixedPointSigned1616Number(),
|
|
5643
|
+
iterator.getFixedPointSigned1616Number(),
|
|
5644
|
+
iterator.getFixedPointSigned230Number()
|
|
5645
|
+
];
|
|
4534
5646
|
iterator.discard(4 * 6);
|
|
4535
5647
|
const nextTrackId = iterator.getUint32();
|
|
4536
5648
|
volumeView.destroy();
|
|
@@ -4587,9 +5699,115 @@ var parseAvcc = ({
|
|
|
4587
5699
|
};
|
|
4588
5700
|
};
|
|
4589
5701
|
|
|
5702
|
+
// src/boxes/iso-base-media/parse-icc-profile.ts
|
|
5703
|
+
var parseIccProfile = (data) => {
|
|
5704
|
+
const iterator = getArrayBufferIterator(data, Infinity);
|
|
5705
|
+
const size = iterator.getUint32();
|
|
5706
|
+
if (size !== data.length) {
|
|
5707
|
+
throw new Error("Invalid ICC profile size");
|
|
5708
|
+
}
|
|
5709
|
+
const preferredCMMType = iterator.getByteString(4);
|
|
5710
|
+
const profileVersion = iterator.getByteString(4);
|
|
5711
|
+
const profileDeviceClass = iterator.getByteString(4);
|
|
5712
|
+
const colorSpace = iterator.getByteString(4);
|
|
5713
|
+
const pcs = iterator.getByteString(4);
|
|
5714
|
+
const dateTime = iterator.getSlice(12);
|
|
5715
|
+
const signature = iterator.getByteString(4);
|
|
5716
|
+
if (signature !== "acsp") {
|
|
5717
|
+
throw new Error("Invalid ICC profile signature");
|
|
5718
|
+
}
|
|
5719
|
+
const primaryPlatform = iterator.getByteString(4);
|
|
5720
|
+
const profileFlags = iterator.getUint32();
|
|
5721
|
+
const deviceManufacturer = iterator.getByteString(4);
|
|
5722
|
+
const deviceModel = iterator.getByteString(4);
|
|
5723
|
+
const deviceAttributes = iterator.getUint64();
|
|
5724
|
+
const renderingIntent = iterator.getUint32();
|
|
5725
|
+
const pcsIlluminant1 = iterator.getUint32();
|
|
5726
|
+
const pcsIlluminant2 = iterator.getUint32();
|
|
5727
|
+
const pcsIlluminant3 = iterator.getUint32();
|
|
5728
|
+
const profileCreator = iterator.getByteString(4);
|
|
5729
|
+
const profileId = iterator.getByteString(16);
|
|
5730
|
+
iterator.discard(28);
|
|
5731
|
+
const tagCount = iterator.getUint32();
|
|
5732
|
+
const entries = [];
|
|
5733
|
+
for (let i = 0;i < tagCount; i++) {
|
|
5734
|
+
const entry = {
|
|
5735
|
+
tag: iterator.getByteString(4),
|
|
5736
|
+
offset: iterator.getUint32(),
|
|
5737
|
+
size: iterator.getUint32()
|
|
5738
|
+
};
|
|
5739
|
+
entries.push(entry);
|
|
5740
|
+
}
|
|
5741
|
+
let lastOffset = -1;
|
|
5742
|
+
let rXYZ = null;
|
|
5743
|
+
let gXYZ = null;
|
|
5744
|
+
let bXYZ = null;
|
|
5745
|
+
let whitePoint = null;
|
|
5746
|
+
for (const entry of entries) {
|
|
5747
|
+
const found = data.slice(entry.offset, entry.offset + entry.size);
|
|
5748
|
+
if (entry.tag === "rXYZ" || entry.tag === "gXYZ" || entry.tag === "bXYZ" || entry.tag === "wtpt") {
|
|
5749
|
+
const it = getArrayBufferIterator(found, Infinity);
|
|
5750
|
+
it.discard(4);
|
|
5751
|
+
const x = it.getInt32() / 65536;
|
|
5752
|
+
const y = it.getInt32() / 65536;
|
|
5753
|
+
const z = it.getInt32() / 65536;
|
|
5754
|
+
it.destroy();
|
|
5755
|
+
const point = { x, y, z };
|
|
5756
|
+
if (entry.tag === "rXYZ") {
|
|
5757
|
+
rXYZ = point;
|
|
5758
|
+
} else if (entry.tag === "gXYZ") {
|
|
5759
|
+
gXYZ = point;
|
|
5760
|
+
} else if (entry.tag === "bXYZ") {
|
|
5761
|
+
bXYZ = point;
|
|
5762
|
+
} else if (entry.tag === "wtpt") {
|
|
5763
|
+
whitePoint = point;
|
|
5764
|
+
}
|
|
5765
|
+
}
|
|
5766
|
+
if (lastOffset !== -1) {
|
|
5767
|
+
const bytesToAdvance = entry.offset - lastOffset;
|
|
5768
|
+
const bytesToGoBackwards = entry.size - bytesToAdvance;
|
|
5769
|
+
if (bytesToGoBackwards > 0) {
|
|
5770
|
+
iterator.counter.decrement(bytesToGoBackwards);
|
|
5771
|
+
}
|
|
5772
|
+
}
|
|
5773
|
+
lastOffset = entry.offset;
|
|
5774
|
+
}
|
|
5775
|
+
const profile = {
|
|
5776
|
+
size,
|
|
5777
|
+
preferredCMMType,
|
|
5778
|
+
profileVersion,
|
|
5779
|
+
profileDeviceClass,
|
|
5780
|
+
colorSpace,
|
|
5781
|
+
pcs,
|
|
5782
|
+
dateTime,
|
|
5783
|
+
signature,
|
|
5784
|
+
primaryPlatform,
|
|
5785
|
+
profileFlags,
|
|
5786
|
+
deviceManufacturer,
|
|
5787
|
+
deviceModel,
|
|
5788
|
+
deviceAttributes,
|
|
5789
|
+
renderingIntent,
|
|
5790
|
+
pcsIlluminant: [
|
|
5791
|
+
pcsIlluminant1 / 65536,
|
|
5792
|
+
pcsIlluminant2 / 65536,
|
|
5793
|
+
pcsIlluminant3 / 65536
|
|
5794
|
+
],
|
|
5795
|
+
profileCreator,
|
|
5796
|
+
profileId,
|
|
5797
|
+
entries,
|
|
5798
|
+
bXYZ,
|
|
5799
|
+
gXYZ,
|
|
5800
|
+
rXYZ,
|
|
5801
|
+
whitePoint
|
|
5802
|
+
};
|
|
5803
|
+
iterator.destroy();
|
|
5804
|
+
return profile;
|
|
5805
|
+
};
|
|
5806
|
+
|
|
4590
5807
|
// src/boxes/iso-base-media/stsd/colr.ts
|
|
4591
5808
|
var parseColorParameterBox = ({
|
|
4592
|
-
iterator
|
|
5809
|
+
iterator,
|
|
5810
|
+
size
|
|
4593
5811
|
}) => {
|
|
4594
5812
|
const byteString = iterator.getByteString(4);
|
|
4595
5813
|
if (byteString === "nclx") {
|
|
@@ -4601,6 +5819,7 @@ var parseColorParameterBox = ({
|
|
|
4601
5819
|
iterator.stopReadingBits();
|
|
4602
5820
|
return {
|
|
4603
5821
|
type: "colr-box",
|
|
5822
|
+
colorType: "transfer-characteristics",
|
|
4604
5823
|
fullRangeFlag,
|
|
4605
5824
|
matrixIndex,
|
|
4606
5825
|
primaries: primaries2,
|
|
@@ -4613,12 +5832,22 @@ var parseColorParameterBox = ({
|
|
|
4613
5832
|
const matrixIndex = iterator.getUint16();
|
|
4614
5833
|
return {
|
|
4615
5834
|
type: "colr-box",
|
|
5835
|
+
colorType: "transfer-characteristics",
|
|
4616
5836
|
fullRangeFlag: false,
|
|
4617
5837
|
matrixIndex,
|
|
4618
5838
|
primaries: primaries2,
|
|
4619
5839
|
transfer
|
|
4620
5840
|
};
|
|
4621
5841
|
}
|
|
5842
|
+
if (byteString === "prof") {
|
|
5843
|
+
const profile = iterator.getSlice(size - 12);
|
|
5844
|
+
return {
|
|
5845
|
+
type: "colr-box",
|
|
5846
|
+
colorType: "icc-profile",
|
|
5847
|
+
profile,
|
|
5848
|
+
parsed: parseIccProfile(profile)
|
|
5849
|
+
};
|
|
5850
|
+
}
|
|
4622
5851
|
throw new Error("Unexpected box type " + byteString);
|
|
4623
5852
|
};
|
|
4624
5853
|
|
|
@@ -4678,7 +5907,6 @@ var parseMebx = async ({
|
|
|
4678
5907
|
offset,
|
|
4679
5908
|
size,
|
|
4680
5909
|
options,
|
|
4681
|
-
littleEndian,
|
|
4682
5910
|
signal
|
|
4683
5911
|
}) => {
|
|
4684
5912
|
iterator.discard(6);
|
|
@@ -4690,8 +5918,8 @@ var parseMebx = async ({
|
|
|
4690
5918
|
initialBoxes: [],
|
|
4691
5919
|
options,
|
|
4692
5920
|
continueMdat: false,
|
|
4693
|
-
|
|
4694
|
-
|
|
5921
|
+
signal,
|
|
5922
|
+
logLevel: "info"
|
|
4695
5923
|
});
|
|
4696
5924
|
if (children.status === "incomplete") {
|
|
4697
5925
|
throw new Error("Incomplete boxes are not allowed");
|
|
@@ -4855,7 +6083,8 @@ var audioTags = [
|
|
|
4855
6083
|
var processSample = async ({
|
|
4856
6084
|
iterator,
|
|
4857
6085
|
options,
|
|
4858
|
-
signal
|
|
6086
|
+
signal,
|
|
6087
|
+
logLevel
|
|
4859
6088
|
}) => {
|
|
4860
6089
|
const fileOffset = iterator.counter.getOffset();
|
|
4861
6090
|
const bytesRemaining = iterator.bytesRemaining();
|
|
@@ -4899,8 +6128,8 @@ var processSample = async ({
|
|
|
4899
6128
|
initialBoxes: [],
|
|
4900
6129
|
options,
|
|
4901
6130
|
continueMdat: false,
|
|
4902
|
-
|
|
4903
|
-
|
|
6131
|
+
signal,
|
|
6132
|
+
logLevel
|
|
4904
6133
|
});
|
|
4905
6134
|
if (children.status === "incomplete") {
|
|
4906
6135
|
throw new Error("Incomplete boxes are not allowed");
|
|
@@ -4946,8 +6175,8 @@ var processSample = async ({
|
|
|
4946
6175
|
initialBoxes: [],
|
|
4947
6176
|
options,
|
|
4948
6177
|
continueMdat: false,
|
|
4949
|
-
|
|
4950
|
-
|
|
6178
|
+
signal,
|
|
6179
|
+
logLevel
|
|
4951
6180
|
});
|
|
4952
6181
|
if (children.status === "incomplete") {
|
|
4953
6182
|
throw new Error("Incomplete boxes are not allowed");
|
|
@@ -4997,8 +6226,8 @@ var processSample = async ({
|
|
|
4997
6226
|
initialBoxes: [],
|
|
4998
6227
|
options,
|
|
4999
6228
|
continueMdat: false,
|
|
5000
|
-
|
|
5001
|
-
|
|
6229
|
+
signal,
|
|
6230
|
+
logLevel
|
|
5002
6231
|
});
|
|
5003
6232
|
if (children.status === "incomplete") {
|
|
5004
6233
|
throw new Error("Incomplete boxes are not allowed");
|
|
@@ -5051,8 +6280,8 @@ var processSample = async ({
|
|
|
5051
6280
|
initialBoxes: [],
|
|
5052
6281
|
options,
|
|
5053
6282
|
continueMdat: false,
|
|
5054
|
-
|
|
5055
|
-
|
|
6283
|
+
signal,
|
|
6284
|
+
logLevel
|
|
5056
6285
|
}) : (iterator.discard(bytesRemainingInBox), { status: "done", segments: [] });
|
|
5057
6286
|
if (children.status === "incomplete") {
|
|
5058
6287
|
throw new Error("Incomplete boxes are not allowed");
|
|
@@ -5088,7 +6317,8 @@ var parseSamples = async ({
|
|
|
5088
6317
|
iterator,
|
|
5089
6318
|
maxBytes,
|
|
5090
6319
|
options,
|
|
5091
|
-
signal
|
|
6320
|
+
signal,
|
|
6321
|
+
logLevel
|
|
5092
6322
|
}) => {
|
|
5093
6323
|
const samples = [];
|
|
5094
6324
|
const initialOffset = iterator.counter.getOffset();
|
|
@@ -5096,7 +6326,8 @@ var parseSamples = async ({
|
|
|
5096
6326
|
const { sample } = await processSample({
|
|
5097
6327
|
iterator,
|
|
5098
6328
|
options,
|
|
5099
|
-
signal
|
|
6329
|
+
signal,
|
|
6330
|
+
logLevel
|
|
5100
6331
|
});
|
|
5101
6332
|
if (sample) {
|
|
5102
6333
|
samples.push(sample);
|
|
@@ -5124,7 +6355,8 @@ var parseStsd = async ({
|
|
|
5124
6355
|
iterator,
|
|
5125
6356
|
maxBytes: bytesRemainingInBox,
|
|
5126
6357
|
options,
|
|
5127
|
-
signal
|
|
6358
|
+
signal,
|
|
6359
|
+
logLevel: "info"
|
|
5128
6360
|
});
|
|
5129
6361
|
if (boxes.length !== numberOfEntries) {
|
|
5130
6362
|
throw new Error(`Expected ${numberOfEntries} sample descriptions, got ${boxes.length}`);
|
|
@@ -5394,7 +6626,8 @@ var parseTrak = async ({
|
|
|
5394
6626
|
size,
|
|
5395
6627
|
offsetAtStart,
|
|
5396
6628
|
options,
|
|
5397
|
-
signal
|
|
6629
|
+
signal,
|
|
6630
|
+
logLevel
|
|
5398
6631
|
}) => {
|
|
5399
6632
|
const children = await parseBoxes({
|
|
5400
6633
|
iterator: data,
|
|
@@ -5403,8 +6636,8 @@ var parseTrak = async ({
|
|
|
5403
6636
|
initialBoxes: [],
|
|
5404
6637
|
options,
|
|
5405
6638
|
continueMdat: false,
|
|
5406
|
-
|
|
5407
|
-
|
|
6639
|
+
signal,
|
|
6640
|
+
logLevel
|
|
5408
6641
|
});
|
|
5409
6642
|
if (children.status === "incomplete") {
|
|
5410
6643
|
throw new Error("Incomplete boxes are not allowed");
|
|
@@ -5465,8 +6698,8 @@ var getChildren = async ({
|
|
|
5465
6698
|
iterator,
|
|
5466
6699
|
bytesRemainingInBox,
|
|
5467
6700
|
options,
|
|
5468
|
-
|
|
5469
|
-
|
|
6701
|
+
signal,
|
|
6702
|
+
logLevel
|
|
5470
6703
|
}) => {
|
|
5471
6704
|
const parseChildren = boxType === "mdia" || boxType === "minf" || boxType === "stbl" || boxType === "moof" || boxType === "dims" || boxType === "wave" || boxType === "traf" || boxType === "stsb";
|
|
5472
6705
|
if (parseChildren) {
|
|
@@ -5477,8 +6710,8 @@ var getChildren = async ({
|
|
|
5477
6710
|
initialBoxes: [],
|
|
5478
6711
|
options,
|
|
5479
6712
|
continueMdat: false,
|
|
5480
|
-
|
|
5481
|
-
|
|
6713
|
+
signal,
|
|
6714
|
+
logLevel
|
|
5482
6715
|
});
|
|
5483
6716
|
if (parsed.status === "incomplete") {
|
|
5484
6717
|
throw new Error("Incomplete boxes are not allowed");
|
|
@@ -5527,12 +6760,12 @@ var processBox = async ({
|
|
|
5527
6760
|
allowIncompleteBoxes,
|
|
5528
6761
|
parsedBoxes,
|
|
5529
6762
|
options,
|
|
5530
|
-
|
|
5531
|
-
|
|
6763
|
+
signal,
|
|
6764
|
+
logLevel
|
|
5532
6765
|
}) => {
|
|
5533
6766
|
const fileOffset = iterator.counter.getOffset();
|
|
5534
6767
|
const bytesRemaining = iterator.bytesRemaining();
|
|
5535
|
-
const boxSizeRaw = iterator.getFourByteNumber(
|
|
6768
|
+
const boxSizeRaw = iterator.getFourByteNumber();
|
|
5536
6769
|
if (boxSizeRaw === 1 && iterator.bytesRemaining() < 12 || iterator.bytesRemaining() < 4) {
|
|
5537
6770
|
iterator.counter.decrement(iterator.counter.getOffset() - fileOffset);
|
|
5538
6771
|
if (allowIncompleteBoxes) {
|
|
@@ -5554,7 +6787,7 @@ var processBox = async ({
|
|
|
5554
6787
|
};
|
|
5555
6788
|
}
|
|
5556
6789
|
const boxType = iterator.getByteString(4);
|
|
5557
|
-
const boxSize = boxSizeRaw === 1 ? iterator.getEightByteNumber(
|
|
6790
|
+
const boxSize = boxSizeRaw === 1 ? iterator.getEightByteNumber() : boxSizeRaw;
|
|
5558
6791
|
if (bytesRemaining < boxSize) {
|
|
5559
6792
|
if (boxType === "mdat") {
|
|
5560
6793
|
const shouldSkip = (options.canSkipVideoData || !hasTracks(parsedBoxes)) && options.supportsContentRange;
|
|
@@ -5604,7 +6837,8 @@ var processBox = async ({
|
|
|
5604
6837
|
}
|
|
5605
6838
|
if (boxType === "colr") {
|
|
5606
6839
|
const box = parseColorParameterBox({
|
|
5607
|
-
iterator
|
|
6840
|
+
iterator,
|
|
6841
|
+
size: boxSize
|
|
5608
6842
|
});
|
|
5609
6843
|
return {
|
|
5610
6844
|
type: "complete",
|
|
@@ -5749,7 +6983,6 @@ var processBox = async ({
|
|
|
5749
6983
|
offset: fileOffset,
|
|
5750
6984
|
size: boxSize,
|
|
5751
6985
|
options,
|
|
5752
|
-
littleEndian,
|
|
5753
6986
|
signal
|
|
5754
6987
|
});
|
|
5755
6988
|
return {
|
|
@@ -5765,7 +6998,8 @@ var processBox = async ({
|
|
|
5765
6998
|
offset: fileOffset,
|
|
5766
6999
|
size: boxSize,
|
|
5767
7000
|
options,
|
|
5768
|
-
signal
|
|
7001
|
+
signal,
|
|
7002
|
+
logLevel
|
|
5769
7003
|
});
|
|
5770
7004
|
return {
|
|
5771
7005
|
type: "complete",
|
|
@@ -5780,7 +7014,8 @@ var processBox = async ({
|
|
|
5780
7014
|
size: boxSize,
|
|
5781
7015
|
offsetAtStart: fileOffset,
|
|
5782
7016
|
options,
|
|
5783
|
-
signal
|
|
7017
|
+
signal,
|
|
7018
|
+
logLevel
|
|
5784
7019
|
});
|
|
5785
7020
|
const transformedTrack = makeBaseMediaTrack(box);
|
|
5786
7021
|
if (transformedTrack) {
|
|
@@ -5880,7 +7115,8 @@ var processBox = async ({
|
|
|
5880
7115
|
const box = parseEsds({
|
|
5881
7116
|
data: iterator,
|
|
5882
7117
|
size: boxSize,
|
|
5883
|
-
fileOffset
|
|
7118
|
+
fileOffset,
|
|
7119
|
+
logLevel
|
|
5884
7120
|
});
|
|
5885
7121
|
return {
|
|
5886
7122
|
type: "complete",
|
|
@@ -5915,8 +7151,8 @@ var processBox = async ({
|
|
|
5915
7151
|
iterator,
|
|
5916
7152
|
bytesRemainingInBox,
|
|
5917
7153
|
options,
|
|
5918
|
-
|
|
5919
|
-
|
|
7154
|
+
signal,
|
|
7155
|
+
logLevel
|
|
5920
7156
|
});
|
|
5921
7157
|
return {
|
|
5922
7158
|
type: "complete",
|
|
@@ -5938,8 +7174,8 @@ var parseBoxes = async ({
|
|
|
5938
7174
|
initialBoxes,
|
|
5939
7175
|
options,
|
|
5940
7176
|
continueMdat,
|
|
5941
|
-
|
|
5942
|
-
|
|
7177
|
+
signal,
|
|
7178
|
+
logLevel
|
|
5943
7179
|
}) => {
|
|
5944
7180
|
let boxes = initialBoxes;
|
|
5945
7181
|
const initialOffset = iterator.counter.getOffset();
|
|
@@ -5957,8 +7193,8 @@ var parseBoxes = async ({
|
|
|
5957
7193
|
allowIncompleteBoxes,
|
|
5958
7194
|
parsedBoxes: initialBoxes,
|
|
5959
7195
|
options,
|
|
5960
|
-
|
|
5961
|
-
|
|
7196
|
+
signal,
|
|
7197
|
+
logLevel
|
|
5962
7198
|
});
|
|
5963
7199
|
if (result.type === "incomplete") {
|
|
5964
7200
|
if (Number.isFinite(maxBytes)) {
|
|
@@ -5975,8 +7211,8 @@ var parseBoxes = async ({
|
|
|
5975
7211
|
initialBoxes: boxes,
|
|
5976
7212
|
options,
|
|
5977
7213
|
continueMdat: false,
|
|
5978
|
-
|
|
5979
|
-
|
|
7214
|
+
signal,
|
|
7215
|
+
logLevel
|
|
5980
7216
|
});
|
|
5981
7217
|
},
|
|
5982
7218
|
skipTo: null
|
|
@@ -5994,8 +7230,8 @@ var parseBoxes = async ({
|
|
|
5994
7230
|
initialBoxes: boxes,
|
|
5995
7231
|
options,
|
|
5996
7232
|
continueMdat: result,
|
|
5997
|
-
|
|
5998
|
-
|
|
7233
|
+
signal,
|
|
7234
|
+
logLevel
|
|
5999
7235
|
}));
|
|
6000
7236
|
},
|
|
6001
7237
|
skipTo: null
|
|
@@ -6027,8 +7263,8 @@ var parseBoxes = async ({
|
|
|
6027
7263
|
initialBoxes: boxes,
|
|
6028
7264
|
options,
|
|
6029
7265
|
continueMdat: false,
|
|
6030
|
-
|
|
6031
|
-
|
|
7266
|
+
signal,
|
|
7267
|
+
logLevel
|
|
6032
7268
|
});
|
|
6033
7269
|
},
|
|
6034
7270
|
skipTo: result.skipTo
|
|
@@ -6046,8 +7282,8 @@ var parseBoxes = async ({
|
|
|
6046
7282
|
initialBoxes: boxes,
|
|
6047
7283
|
options,
|
|
6048
7284
|
continueMdat: false,
|
|
6049
|
-
|
|
6050
|
-
|
|
7285
|
+
signal,
|
|
7286
|
+
logLevel
|
|
6051
7287
|
});
|
|
6052
7288
|
},
|
|
6053
7289
|
skipTo: null
|
|
@@ -6073,8 +7309,8 @@ var parseBoxes = async ({
|
|
|
6073
7309
|
initialBoxes: boxes,
|
|
6074
7310
|
options,
|
|
6075
7311
|
continueMdat: false,
|
|
6076
|
-
|
|
6077
|
-
|
|
7312
|
+
signal,
|
|
7313
|
+
logLevel
|
|
6078
7314
|
});
|
|
6079
7315
|
},
|
|
6080
7316
|
skipTo: skipped ? mdatState.fileOffset : null
|
|
@@ -6145,11 +7381,11 @@ var getSampleFromBlock = (ebml, parserContext, offset) => {
|
|
|
6145
7381
|
const { keyframe } = parseBlockFlags(iterator, ebml.type === "SimpleBlock" ? matroskaElements.SimpleBlock : matroskaElements.Block);
|
|
6146
7382
|
const { codec, trackTimescale } = parserContext.parserState.getTrackInfoByNumber(trackNumber2);
|
|
6147
7383
|
const clusterOffset = parserContext.parserState.getTimestampOffsetForByteOffset(offset);
|
|
6148
|
-
const
|
|
7384
|
+
const timescale2 = parserContext.parserState.getTimescale();
|
|
6149
7385
|
if (clusterOffset === undefined) {
|
|
6150
7386
|
throw new Error("Could not find offset for byte offset " + offset);
|
|
6151
7387
|
}
|
|
6152
|
-
const timecodeInNanoSeconds = (timecodeRelativeToCluster + clusterOffset) *
|
|
7388
|
+
const timecodeInNanoSeconds = (timecodeRelativeToCluster + clusterOffset) * timescale2 * (trackTimescale ?? 1);
|
|
6153
7389
|
const timecodeInMicroseconds = timecodeInNanoSeconds / 1000;
|
|
6154
7390
|
if (!codec) {
|
|
6155
7391
|
throw new Error(`Could not find codec for track ${trackNumber2}`);
|
|
@@ -6158,8 +7394,8 @@ var getSampleFromBlock = (ebml, parserContext, offset) => {
|
|
|
6158
7394
|
if (codec.startsWith("V_")) {
|
|
6159
7395
|
const partialVideoSample = {
|
|
6160
7396
|
data: iterator.getSlice(remainingNow),
|
|
6161
|
-
cts:
|
|
6162
|
-
dts:
|
|
7397
|
+
cts: timecodeInMicroseconds,
|
|
7398
|
+
dts: timecodeInMicroseconds,
|
|
6163
7399
|
duration: undefined,
|
|
6164
7400
|
trackId: trackNumber2,
|
|
6165
7401
|
timestamp: timecodeInMicroseconds
|
|
@@ -6187,7 +7423,9 @@ var getSampleFromBlock = (ebml, parserContext, offset) => {
|
|
|
6187
7423
|
trackId: trackNumber2,
|
|
6188
7424
|
timestamp: timecodeInMicroseconds,
|
|
6189
7425
|
type: "key",
|
|
6190
|
-
duration: undefined
|
|
7426
|
+
duration: undefined,
|
|
7427
|
+
cts: timecodeInMicroseconds,
|
|
7428
|
+
dts: timecodeInMicroseconds
|
|
6191
7429
|
};
|
|
6192
7430
|
iterator.destroy();
|
|
6193
7431
|
return {
|
|
@@ -6603,7 +7841,8 @@ var parseWebm = (counter, parserContext) => {
|
|
|
6603
7841
|
var parseVideo = ({
|
|
6604
7842
|
iterator,
|
|
6605
7843
|
options,
|
|
6606
|
-
signal
|
|
7844
|
+
signal,
|
|
7845
|
+
logLevel
|
|
6607
7846
|
}) => {
|
|
6608
7847
|
if (iterator.bytesRemaining() === 0) {
|
|
6609
7848
|
return Promise.resolve({
|
|
@@ -6613,7 +7852,8 @@ var parseVideo = ({
|
|
|
6613
7852
|
return parseVideo({
|
|
6614
7853
|
iterator,
|
|
6615
7854
|
options,
|
|
6616
|
-
signal
|
|
7855
|
+
signal,
|
|
7856
|
+
logLevel
|
|
6617
7857
|
});
|
|
6618
7858
|
},
|
|
6619
7859
|
skipTo: null
|
|
@@ -6630,8 +7870,8 @@ var parseVideo = ({
|
|
|
6630
7870
|
initialBoxes: [],
|
|
6631
7871
|
options,
|
|
6632
7872
|
continueMdat: false,
|
|
6633
|
-
|
|
6634
|
-
|
|
7873
|
+
signal,
|
|
7874
|
+
logLevel
|
|
6635
7875
|
});
|
|
6636
7876
|
}
|
|
6637
7877
|
if (iterator.isWebm()) {
|
|
@@ -6673,15 +7913,15 @@ var makeParserState = ({
|
|
|
6673
7913
|
const queuedAudioSamples = {};
|
|
6674
7914
|
const queuedVideoSamples = {};
|
|
6675
7915
|
const declinedTrackNumbers = [];
|
|
6676
|
-
let
|
|
7916
|
+
let timescale2 = null;
|
|
6677
7917
|
const getTimescale = () => {
|
|
6678
|
-
if (
|
|
7918
|
+
if (timescale2 === null) {
|
|
6679
7919
|
return 1e6;
|
|
6680
7920
|
}
|
|
6681
|
-
return
|
|
7921
|
+
return timescale2;
|
|
6682
7922
|
};
|
|
6683
7923
|
const setTimescale = (newTimescale) => {
|
|
6684
|
-
|
|
7924
|
+
timescale2 = newTimescale;
|
|
6685
7925
|
};
|
|
6686
7926
|
const timestampMap = new Map;
|
|
6687
7927
|
const setTimestampOffset = (byteOffset, timestamp) => {
|
|
@@ -6775,6 +8015,7 @@ var parseMedia = async ({
|
|
|
6775
8015
|
onAudioTrack,
|
|
6776
8016
|
onVideoTrack,
|
|
6777
8017
|
signal,
|
|
8018
|
+
logLevel = "info",
|
|
6778
8019
|
...more
|
|
6779
8020
|
}) => {
|
|
6780
8021
|
const state = makeParserState({
|
|
@@ -6834,7 +8075,8 @@ var parseMedia = async ({
|
|
|
6834
8075
|
parseResult = await parseVideo({
|
|
6835
8076
|
iterator,
|
|
6836
8077
|
options,
|
|
6837
|
-
signal: signal ?? null
|
|
8078
|
+
signal: signal ?? null,
|
|
8079
|
+
logLevel
|
|
6838
8080
|
});
|
|
6839
8081
|
}
|
|
6840
8082
|
const availableInfo = getAvailableInfo(fields ?? {}, parseResult, state);
|
|
@@ -6879,7 +8121,8 @@ var parseMedia = async ({
|
|
|
6879
8121
|
};
|
|
6880
8122
|
// src/index.ts
|
|
6881
8123
|
var MediaParserInternals = {
|
|
6882
|
-
|
|
8124
|
+
createMatroskaMedia,
|
|
8125
|
+
createIsoBaseMedia,
|
|
6883
8126
|
Log
|
|
6884
8127
|
};
|
|
6885
8128
|
export {
|