@ahmedrowaihi/mediabunny 1.65.2-beta.700 → 1.65.2-beta.703
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/bundles/mediabunny.cjs +54 -7
- package/dist/bundles/mediabunny.min.cjs +37 -37
- package/dist/bundles/mediabunny.min.mjs +37 -37
- package/dist/bundles/mediabunny.mjs +54 -7
- package/dist/bundles/mediabunny.node.cjs +54 -7
- package/dist/mediabunny.d.ts +16 -0
- package/dist/modules/src/closed-captions.d.ts.map +1 -1
- package/dist/modules/src/closed-captions.js +2 -3
- package/dist/modules/src/hdr-metadata.d.ts.map +1 -1
- package/dist/modules/src/hdr-metadata.js +24 -1
- package/dist/modules/src/isobmff/isobmff-muxer.d.ts.map +1 -1
- package/dist/modules/src/isobmff/isobmff-muxer.js +11 -1
- package/dist/modules/src/media-source.d.ts.map +1 -1
- package/dist/modules/src/media-source.js +27 -1
- package/dist/modules/src/sample.d.ts +16 -0
- package/dist/modules/src/sample.d.ts.map +1 -1
- package/dist/modules/src/sample.js +18 -0
- package/dist/modules/src/sei.js +8 -0
- package/dist/modules/src/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/closed-captions.ts +8 -3
- package/src/hdr-metadata.ts +35 -0
- package/src/isobmff/isobmff-muxer.ts +14 -1
- package/src/media-source.ts +35 -2
- package/src/sample.ts +34 -0
- package/src/sei.ts +9 -0
|
@@ -7603,6 +7603,7 @@ var Mediabunny = (() => {
|
|
|
7603
7603
|
};
|
|
7604
7604
|
|
|
7605
7605
|
// src/sei.ts
|
|
7606
|
+
var USER_DATA_REGISTERED_ITU_T_T35 = 4;
|
|
7606
7607
|
var SEI_FRAMINGS = {
|
|
7607
7608
|
avc: {
|
|
7608
7609
|
// forbidden_zero_bit = 0, nal_ref_idc = 0 (an SEI is never a reference picture), nal_unit_type = 6.
|
|
@@ -7811,6 +7812,7 @@ var Mediabunny = (() => {
|
|
|
7811
7812
|
};
|
|
7812
7813
|
var buildMdcvBox = (metadata) => isobmffBox("mdcv", buildMasteringDisplayPayload(metadata));
|
|
7813
7814
|
var buildClliBox = (contentLight) => isobmffBox("clli", buildContentLightPayload(contentLight));
|
|
7815
|
+
var buildHdr10PlusSeiNalUnit = (payload, codec) => buildSeiNalUnit([{ payloadType: USER_DATA_REGISTERED_ITU_T_T35, payload }], codec);
|
|
7814
7816
|
|
|
7815
7817
|
// src/isobmff/isobmff-demuxer.ts
|
|
7816
7818
|
var AVC_INTRA_FOURCCS = /* @__PURE__ */ new Set([
|
|
@@ -27687,7 +27689,6 @@ var Mediabunny = (() => {
|
|
|
27687
27689
|
|
|
27688
27690
|
// src/closed-captions.ts
|
|
27689
27691
|
var CLOSED_CAPTION_CHANNELS = ["CC1", "CC2", "CC3", "CC4"];
|
|
27690
|
-
var USER_DATA_REGISTERED_ITU_T_T35 = 4;
|
|
27691
27692
|
var ATSC_CC_DATA_HEADER = [181, 0, 49, 71, 65, 57, 52, 3];
|
|
27692
27693
|
var MAX_CLOSED_CAPTION_BYTE_PAIRS = 31;
|
|
27693
27694
|
var buildClosedCaptionSeiMessage = (bytePairs) => {
|
|
@@ -28162,7 +28163,11 @@ var Mediabunny = (() => {
|
|
|
28162
28163
|
if (init?.dolbyVisionRpu != null && !(init.dolbyVisionRpu instanceof Uint8Array)) {
|
|
28163
28164
|
throw new TypeError("init.dolbyVisionRpu, when provided, must be a Uint8Array or null.");
|
|
28164
28165
|
}
|
|
28166
|
+
if (init?.hdr10Plus != null && !(init.hdr10Plus instanceof Uint8Array)) {
|
|
28167
|
+
throw new TypeError("init.hdr10Plus, when provided, must be a Uint8Array or null.");
|
|
28168
|
+
}
|
|
28165
28169
|
this.dolbyVisionRpu = init?.dolbyVisionRpu ?? null;
|
|
28170
|
+
this.hdr10Plus = init?.hdr10Plus ?? null;
|
|
28166
28171
|
this.pixelAspectRatio = simplifyRational({
|
|
28167
28172
|
num: this.squarePixelWidth * this.codedHeight,
|
|
28168
28173
|
den: this.squarePixelHeight * this.codedWidth
|
|
@@ -28214,7 +28219,8 @@ var Mediabunny = (() => {
|
|
|
28214
28219
|
flip: this.flip,
|
|
28215
28220
|
encodeOptions: this.encodeOptions,
|
|
28216
28221
|
closedCaptions: this.closedCaptions,
|
|
28217
|
-
dolbyVisionRpu: this.dolbyVisionRpu
|
|
28222
|
+
dolbyVisionRpu: this.dolbyVisionRpu,
|
|
28223
|
+
hdr10Plus: this.hdr10Plus
|
|
28218
28224
|
});
|
|
28219
28225
|
} else if (isVideoFrame(this._data)) {
|
|
28220
28226
|
return new _VideoSample(this._data.clone(), {
|
|
@@ -28224,7 +28230,8 @@ var Mediabunny = (() => {
|
|
|
28224
28230
|
flip: this.flip,
|
|
28225
28231
|
encodeOptions: this.encodeOptions,
|
|
28226
28232
|
closedCaptions: this.closedCaptions,
|
|
28227
|
-
dolbyVisionRpu: this.dolbyVisionRpu
|
|
28233
|
+
dolbyVisionRpu: this.dolbyVisionRpu,
|
|
28234
|
+
hdr10Plus: this.hdr10Plus
|
|
28228
28235
|
});
|
|
28229
28236
|
} else if (this._data instanceof Uint8Array) {
|
|
28230
28237
|
assert(this._layout);
|
|
@@ -28244,6 +28251,7 @@ var Mediabunny = (() => {
|
|
|
28244
28251
|
encodeOptions: this.encodeOptions,
|
|
28245
28252
|
closedCaptions: this.closedCaptions,
|
|
28246
28253
|
dolbyVisionRpu: this.dolbyVisionRpu,
|
|
28254
|
+
hdr10Plus: this.hdr10Plus,
|
|
28247
28255
|
// It's already been copied, if we copy it again we make the clone unnecessarily expensive
|
|
28248
28256
|
_doNotCopy: true
|
|
28249
28257
|
});
|
|
@@ -28262,7 +28270,8 @@ var Mediabunny = (() => {
|
|
|
28262
28270
|
displayHeight: this.displayHeight,
|
|
28263
28271
|
encodeOptions: this.encodeOptions,
|
|
28264
28272
|
closedCaptions: this.closedCaptions,
|
|
28265
|
-
dolbyVisionRpu: this.dolbyVisionRpu
|
|
28273
|
+
dolbyVisionRpu: this.dolbyVisionRpu,
|
|
28274
|
+
hdr10Plus: this.hdr10Plus
|
|
28266
28275
|
});
|
|
28267
28276
|
}
|
|
28268
28277
|
}
|
|
@@ -28879,6 +28888,7 @@ var Mediabunny = (() => {
|
|
|
28879
28888
|
if (result !== null) {
|
|
28880
28889
|
result.setClosedCaptions(this.closedCaptions);
|
|
28881
28890
|
result.setDolbyVisionRpu(this.dolbyVisionRpu);
|
|
28891
|
+
result.setHdr10Plus(this.hdr10Plus);
|
|
28882
28892
|
return dropColorSpace(result);
|
|
28883
28893
|
}
|
|
28884
28894
|
}
|
|
@@ -28899,7 +28909,8 @@ var Mediabunny = (() => {
|
|
|
28899
28909
|
flip: false,
|
|
28900
28910
|
// A geometric transform does not change what is in the picture
|
|
28901
28911
|
closedCaptions: this.closedCaptions,
|
|
28902
|
-
dolbyVisionRpu: this.dolbyVisionRpu
|
|
28912
|
+
dolbyVisionRpu: this.dolbyVisionRpu,
|
|
28913
|
+
hdr10Plus: this.hdr10Plus
|
|
28903
28914
|
}));
|
|
28904
28915
|
}
|
|
28905
28916
|
/** Sets the rotation metadata of this video sample. */
|
|
@@ -28944,6 +28955,13 @@ var Mediabunny = (() => {
|
|
|
28944
28955
|
}
|
|
28945
28956
|
this.dolbyVisionRpu = newRpu;
|
|
28946
28957
|
}
|
|
28958
|
+
/** Sets the HDR10+ T.35 payload this frame carries. */
|
|
28959
|
+
setHdr10Plus(newPayload) {
|
|
28960
|
+
if (newPayload !== null && !(newPayload instanceof Uint8Array)) {
|
|
28961
|
+
throw new TypeError("newPayload must be a Uint8Array or null.");
|
|
28962
|
+
}
|
|
28963
|
+
this.hdr10Plus = newPayload;
|
|
28964
|
+
}
|
|
28947
28965
|
/** Sets the closed-caption byte pairs this frame carries. */
|
|
28948
28966
|
setClosedCaptions(newClosedCaptions) {
|
|
28949
28967
|
if (newClosedCaptions !== null) {
|
|
@@ -35573,6 +35591,7 @@ var Mediabunny = (() => {
|
|
|
35573
35591
|
this.pendingFrameSideData = /* @__PURE__ */ new Map();
|
|
35574
35592
|
this.carriesDeclaredCaptions = false;
|
|
35575
35593
|
this.warnedAboutUncarriableRpus = false;
|
|
35594
|
+
this.warnedAboutUncarriableHdr10Plus = false;
|
|
35576
35595
|
this.captionProbeDone = false;
|
|
35577
35596
|
this.warnedAboutUncarriableCaptions = false;
|
|
35578
35597
|
}
|
|
@@ -35776,6 +35795,7 @@ var Mediabunny = (() => {
|
|
|
35776
35795
|
for (const sampleToEncode of samplesToEncode) {
|
|
35777
35796
|
this.rememberCaptionsFor(sampleToEncode);
|
|
35778
35797
|
this.rememberRpuFor(sampleToEncode);
|
|
35798
|
+
this.rememberHdr10PlusFor(sampleToEncode);
|
|
35779
35799
|
if (!this.encoderInitialized) {
|
|
35780
35800
|
if (!this.ensureEncoderPromise) {
|
|
35781
35801
|
this.ensureEncoder(sampleToEncode);
|
|
@@ -36285,6 +36305,21 @@ var Mediabunny = (() => {
|
|
|
36285
36305
|
}
|
|
36286
36306
|
this.remember(videoSample.microsecondTimestamp, { dolbyVisionRpu: videoSample.dolbyVisionRpu });
|
|
36287
36307
|
}
|
|
36308
|
+
rememberHdr10PlusFor(videoSample) {
|
|
36309
|
+
if (!videoSample.hdr10Plus) {
|
|
36310
|
+
return;
|
|
36311
|
+
}
|
|
36312
|
+
if (this.encodingConfig.codec !== "hevc") {
|
|
36313
|
+
if (!this.warnedAboutUncarriableHdr10Plus) {
|
|
36314
|
+
this.warnedAboutUncarriableHdr10Plus = true;
|
|
36315
|
+
Logging._warn(
|
|
36316
|
+
`Dropping the HDR10+ metadata stated by the samples: it is written as an SEI in an HEVC bitstream, and this track encodes '${this.encodingConfig.codec}'.`
|
|
36317
|
+
);
|
|
36318
|
+
}
|
|
36319
|
+
return;
|
|
36320
|
+
}
|
|
36321
|
+
this.remember(videoSample.microsecondTimestamp, { hdr10Plus: videoSample.hdr10Plus });
|
|
36322
|
+
}
|
|
36288
36323
|
rememberCaptionsFor(videoSample) {
|
|
36289
36324
|
if (!videoSample.closedCaptions) {
|
|
36290
36325
|
return;
|
|
@@ -36319,7 +36354,7 @@ var Mediabunny = (() => {
|
|
|
36319
36354
|
this.carriesDeclaredCaptions = carriesClosedCaptions(packet.data, this.lastDecoderConfig, codec);
|
|
36320
36355
|
}
|
|
36321
36356
|
}
|
|
36322
|
-
if (bytePairs || sideData?.dolbyVisionRpu) {
|
|
36357
|
+
if (bytePairs || sideData?.dolbyVisionRpu || sideData?.hdr10Plus) {
|
|
36323
36358
|
const codec = this.encodingConfig.codec;
|
|
36324
36359
|
assert(codec === "avc" || codec === "hevc");
|
|
36325
36360
|
if (bytePairs) {
|
|
@@ -36335,6 +36370,14 @@ var Mediabunny = (() => {
|
|
|
36335
36370
|
sideData.dolbyVisionRpu
|
|
36336
36371
|
);
|
|
36337
36372
|
}
|
|
36373
|
+
if (sideData?.hdr10Plus) {
|
|
36374
|
+
assert(this.lastDecoderConfig);
|
|
36375
|
+
assert(codec === "hevc");
|
|
36376
|
+
const seiNalUnit = buildHdr10PlusSeiNalUnit(sideData.hdr10Plus, codec);
|
|
36377
|
+
if (seiNalUnit) {
|
|
36378
|
+
packet = withNalUnitSpliced(packet, this.lastDecoderConfig, codec, seiNalUnit);
|
|
36379
|
+
}
|
|
36380
|
+
}
|
|
36338
36381
|
}
|
|
36339
36382
|
maybeEnsureIsKeyPacket(this.source._connectedTrack, packet);
|
|
36340
36383
|
this.encodingConfig.onEncodedPacket?.(packet, meta);
|
|
@@ -43317,7 +43360,11 @@ var Mediabunny = (() => {
|
|
|
43317
43360
|
assert(trackData.lastSample);
|
|
43318
43361
|
const timescaleUnits = intoTimescale(sample.decodeTimestamp, trackData.timescale, false);
|
|
43319
43362
|
const delta = Math.round(timescaleUnits - trackData.lastTimescaleUnits);
|
|
43320
|
-
|
|
43363
|
+
if (!(delta >= 0)) {
|
|
43364
|
+
throw new Error(
|
|
43365
|
+
`Decode timestamps must not go backwards, but a packet presenting at ${sample.timestamp}s states a decode timestamp of ${sample.decodeTimestamp}s, which is before the previous packet's ${trackData.lastTimescaleUnits / trackData.timescale}s. Packets that state a decode timestamp must be added in decode order.`
|
|
43366
|
+
);
|
|
43367
|
+
}
|
|
43321
43368
|
trackData.lastTimescaleUnits += delta;
|
|
43322
43369
|
trackData.lastSample.timescaleUnitsToNextSample = delta;
|
|
43323
43370
|
if (!this.isFragmented) {
|