@ahmedrowaihi/mediabunny 1.65.2-beta.551 → 1.65.2-beta.554
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 +71 -4
- package/dist/bundles/mediabunny.min.cjs +36 -36
- package/dist/bundles/mediabunny.min.mjs +36 -36
- package/dist/bundles/mediabunny.mjs +71 -4
- package/dist/bundles/mediabunny.node.cjs +71 -4
- package/dist/mediabunny.d.ts +39 -0
- package/dist/modules/src/codec-data.d.ts +2 -0
- package/dist/modules/src/codec-data.d.ts.map +1 -1
- package/dist/modules/src/codec-data.js +2 -0
- package/dist/modules/src/index.d.ts +1 -0
- package/dist/modules/src/index.d.ts.map +1 -1
- package/dist/modules/src/index.js +1 -0
- package/dist/modules/src/mpeg-ts/mpeg-ts-muxer.d.ts +9 -0
- package/dist/modules/src/mpeg-ts/mpeg-ts-muxer.d.ts.map +1 -1
- package/dist/modules/src/mpeg-ts/mpeg-ts-muxer.js +55 -4
- package/dist/modules/src/mpeg-ts/scte35-output.d.ts +39 -0
- package/dist/modules/src/mpeg-ts/scte35-output.d.ts.map +1 -0
- package/dist/modules/src/mpeg-ts/scte35-output.js +52 -0
- package/dist/modules/src/output-format.d.ts +8 -0
- package/dist/modules/src/output-format.d.ts.map +1 -1
- package/dist/modules/src/output-format.js +5 -0
- package/dist/modules/src/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/codec-data.ts +3 -0
- package/src/index.ts +1 -0
- package/src/mpeg-ts/mpeg-ts-muxer.ts +66 -3
- package/src/mpeg-ts/scte35-output.ts +57 -0
- package/src/output-format.ts +16 -0
|
@@ -300,6 +300,7 @@ var Mediabunny = (() => {
|
|
|
300
300
|
WebMOutputFormat: () => WebMOutputFormat,
|
|
301
301
|
XmlNode: () => XmlNode,
|
|
302
302
|
addContentProtectionElements: () => addContentProtectionElements,
|
|
303
|
+
addScte35Section: () => addScte35Section,
|
|
303
304
|
adjustHlsVideoCodec: () => adjustHlsVideoCodec,
|
|
304
305
|
asc: () => asc,
|
|
305
306
|
buildCbcsContentProtections: () => buildCbcsContentProtections,
|
|
@@ -5265,6 +5266,7 @@ var Mediabunny = (() => {
|
|
|
5265
5266
|
var AC3_SAMPLES_PER_FRAME = 1536;
|
|
5266
5267
|
var AC3_REGISTRATION_DESCRIPTOR = new Uint8Array([5, 4, 65, 67, 45, 51]);
|
|
5267
5268
|
var EAC3_REGISTRATION_DESCRIPTOR = new Uint8Array([5, 4, 69, 65, 67, 51]);
|
|
5269
|
+
var CUEI_REGISTRATION_DESCRIPTOR = new Uint8Array([5, 4, 67, 85, 69, 73]);
|
|
5268
5270
|
var EAC3_NUMBLKS_TABLE = [1, 2, 3, 6];
|
|
5269
5271
|
var parseEac3SyncFrame = (data) => {
|
|
5270
5272
|
if (data.length < 6) {
|
|
@@ -45272,6 +45274,7 @@ ${cue.notes ?? ""}`;
|
|
|
45272
45274
|
// src/mpeg-ts/mpeg-ts-muxer.ts
|
|
45273
45275
|
var PAT_PID2 = 0;
|
|
45274
45276
|
var PMT_PID = 4096;
|
|
45277
|
+
var SCTE35_STREAM_TYPE = 134;
|
|
45275
45278
|
var FIRST_TRACK_PID = 256;
|
|
45276
45279
|
var VIDEO_STREAM_ID_BASE = 224;
|
|
45277
45280
|
var AUDIO_STREAM_ID_BASE = 192;
|
|
@@ -45284,6 +45287,11 @@ ${cue.notes ?? ""}`;
|
|
|
45284
45287
|
// offset leaking into the next shifts a programme that needed no shift at all.
|
|
45285
45288
|
this.defaultTimestampOffset = null;
|
|
45286
45289
|
this.trackDatas = [];
|
|
45290
|
+
/**
|
|
45291
|
+
* Sections handed over before the tables went out. A track's data exists only once its first packet
|
|
45292
|
+
* is added, so writing the tables early would publish a PMT that names the cue stream and no media.
|
|
45293
|
+
*/
|
|
45294
|
+
this.pendingScte35Sections = [];
|
|
45287
45295
|
this.tablesWritten = false;
|
|
45288
45296
|
this.continuityCounters = /* @__PURE__ */ new Map();
|
|
45289
45297
|
this.packetBuffer = new Uint8Array(TS_PACKET_SIZE);
|
|
@@ -45297,6 +45305,7 @@ ${cue.notes ?? ""}`;
|
|
|
45297
45305
|
this.format = format;
|
|
45298
45306
|
this.timestampOffset = format._options.timestampOffset ?? 0;
|
|
45299
45307
|
this.offsetIsStated = format._options.timestampOffset !== void 0;
|
|
45308
|
+
this.scte35Pid = format._options.scte35Pid ?? null;
|
|
45300
45309
|
}
|
|
45301
45310
|
get maxInterleaveDelta() {
|
|
45302
45311
|
return this.format._options.maxInterleaveDelta ?? DEFAULT_MAX_INTERLEAVE_DELTA;
|
|
@@ -45697,8 +45706,36 @@ ${cue.notes ?? ""}`;
|
|
|
45697
45706
|
assert(!this.tablesWritten);
|
|
45698
45707
|
this.writePsiSection(PAT_PID2, PAT_SECTION);
|
|
45699
45708
|
this.pcrPid = pcrTrackOf(this.trackDatas)?.pid ?? null;
|
|
45700
|
-
this.writePsiSection(PMT_PID, buildPmt(this.trackDatas));
|
|
45709
|
+
this.writePsiSection(PMT_PID, buildPmt(this.trackDatas, this.scte35Pid));
|
|
45701
45710
|
this.tablesWritten = true;
|
|
45711
|
+
this.flushScte35Sections();
|
|
45712
|
+
}
|
|
45713
|
+
/**
|
|
45714
|
+
* Writes a `splice_info_section` into the declared SCTE-35 PID, at the current point in the stream.
|
|
45715
|
+
*
|
|
45716
|
+
* The tables go first when they have not been written yet: a section on a PID the PMT has not named
|
|
45717
|
+
* is one a receiver has no reason to look at.
|
|
45718
|
+
*
|
|
45719
|
+
* @internal
|
|
45720
|
+
*/
|
|
45721
|
+
writeScte35Section(section) {
|
|
45722
|
+
if (this.scte35Pid === null) {
|
|
45723
|
+
throw new InvalidUsageError(
|
|
45724
|
+
"MpegTsOutputFormat was not given an scte35Pid, so there is no cue stream to write into."
|
|
45725
|
+
);
|
|
45726
|
+
}
|
|
45727
|
+
this.pendingScte35Sections.push(section);
|
|
45728
|
+
this.flushScte35Sections();
|
|
45729
|
+
}
|
|
45730
|
+
/** Writes whatever is queued, once the tables exist for it to belong to. */
|
|
45731
|
+
flushScte35Sections() {
|
|
45732
|
+
if (!this.tablesWritten || this.scte35Pid === null) {
|
|
45733
|
+
return;
|
|
45734
|
+
}
|
|
45735
|
+
for (const section of this.pendingScte35Sections) {
|
|
45736
|
+
this.writePsiSection(this.scte35Pid, section);
|
|
45737
|
+
}
|
|
45738
|
+
this.pendingScte35Sections.length = 0;
|
|
45702
45739
|
}
|
|
45703
45740
|
writePsiSection(pid, section) {
|
|
45704
45741
|
let offset = 0;
|
|
@@ -45915,7 +45952,7 @@ ${cue.notes ?? ""}`;
|
|
|
45915
45952
|
buf[offset + 4] = base90kHz % 2 << 7 | 126;
|
|
45916
45953
|
buf[offset + 5] = 0;
|
|
45917
45954
|
};
|
|
45918
|
-
var buildPmt = (trackDatas) => {
|
|
45955
|
+
var buildPmt = (trackDatas, scte35Pid) => {
|
|
45919
45956
|
const sampleAesDescriptors = /* @__PURE__ */ new Map();
|
|
45920
45957
|
let totalEsBytes = 0;
|
|
45921
45958
|
for (const trackData of trackDatas) {
|
|
@@ -45929,6 +45966,9 @@ ${cue.notes ?? ""}`;
|
|
|
45929
45966
|
totalEsBytes += EAC3_REGISTRATION_DESCRIPTOR.length;
|
|
45930
45967
|
}
|
|
45931
45968
|
}
|
|
45969
|
+
if (scte35Pid !== null) {
|
|
45970
|
+
totalEsBytes += 5 + CUEI_REGISTRATION_DESCRIPTOR.length;
|
|
45971
|
+
}
|
|
45932
45972
|
const sectionLength = 9 + totalEsBytes + 4;
|
|
45933
45973
|
const section = new Uint8Array(3 + sectionLength - 4);
|
|
45934
45974
|
const view2 = toDataView(section);
|
|
@@ -45970,6 +46010,15 @@ ${cue.notes ?? ""}`;
|
|
|
45970
46010
|
offset += 2;
|
|
45971
46011
|
}
|
|
45972
46012
|
}
|
|
46013
|
+
if (scte35Pid !== null) {
|
|
46014
|
+
section[offset++] = SCTE35_STREAM_TYPE;
|
|
46015
|
+
view2.setUint16(offset, 57344 | scte35Pid & 8191, false);
|
|
46016
|
+
offset += 2;
|
|
46017
|
+
view2.setUint16(offset, 61440 | CUEI_REGISTRATION_DESCRIPTOR.length, false);
|
|
46018
|
+
offset += 2;
|
|
46019
|
+
section.set(CUEI_REGISTRATION_DESCRIPTOR, offset);
|
|
46020
|
+
offset += CUEI_REGISTRATION_DESCRIPTOR.length;
|
|
46021
|
+
}
|
|
45973
46022
|
const crc = computeMpegTsCrc32(section);
|
|
45974
46023
|
const result = new Uint8Array(section.length + 4);
|
|
45975
46024
|
result.set(section, 0);
|
|
@@ -52979,6 +53028,9 @@ ${cue.text}
|
|
|
52979
53028
|
if (options.timestampOffset !== void 0 && (!Number.isFinite(options.timestampOffset) || options.timestampOffset < 0)) {
|
|
52980
53029
|
throw new TypeError("options.timestampOffset, when provided, must be a non-negative number.");
|
|
52981
53030
|
}
|
|
53031
|
+
if (options.scte35Pid !== void 0 && (!Number.isInteger(options.scte35Pid) || options.scte35Pid < 16 || options.scte35Pid > 8190)) {
|
|
53032
|
+
throw new TypeError("options.scte35Pid, when provided, must be an integer between 0x0010 and 0x1ffe.");
|
|
53033
|
+
}
|
|
52982
53034
|
if (options.maxInterleaveDelta !== void 0 && !(options.maxInterleaveDelta > 0)) {
|
|
52983
53035
|
throw new TypeError("options.maxInterleaveDelta, when provided, must be a positive number.");
|
|
52984
53036
|
}
|
|
@@ -65559,7 +65611,7 @@ ${baseUrl}${p.getFileName()}`;
|
|
|
65559
65611
|
var SYNC_BYTE = 71;
|
|
65560
65612
|
var SPLICE_INFO_TABLE_ID = 252;
|
|
65561
65613
|
var CUEI_FORMAT_IDENTIFIER = 1129661769;
|
|
65562
|
-
var
|
|
65614
|
+
var SCTE35_STREAM_TYPE2 = 134;
|
|
65563
65615
|
var SPLICE_INSERT = 5;
|
|
65564
65616
|
var PROGRAM_SPLICE_FLAG = 64;
|
|
65565
65617
|
var SPLICE_IMMEDIATE_FLAG = 16;
|
|
@@ -65651,7 +65703,7 @@ ${baseUrl}${p.getFileName()}`;
|
|
|
65651
65703
|
const pid = readU163(bytes2, pos + 1) & 8191;
|
|
65652
65704
|
const esInfoLength = readU163(bytes2, pos + 3) & 4095;
|
|
65653
65705
|
const descriptorsEnd = Math.min(pos + 5 + esInfoLength, sectionEnd);
|
|
65654
|
-
if (streamType ===
|
|
65706
|
+
if (streamType === SCTE35_STREAM_TYPE2) {
|
|
65655
65707
|
for (let d = pos + 5; d + 2 <= descriptorsEnd; ) {
|
|
65656
65708
|
const tag = bytes2[d];
|
|
65657
65709
|
const length = bytes2[d + 1];
|
|
@@ -65931,6 +65983,21 @@ ${baseUrl}${p.getFileName()}`;
|
|
|
65931
65983
|
return out;
|
|
65932
65984
|
};
|
|
65933
65985
|
|
|
65986
|
+
// src/mpeg-ts/scte35-output.ts
|
|
65987
|
+
var addScte35Section = (output, section) => {
|
|
65988
|
+
if (!(section instanceof Uint8Array)) {
|
|
65989
|
+
throw new TypeError("section must be a Uint8Array.");
|
|
65990
|
+
}
|
|
65991
|
+
if (section.length < 3) {
|
|
65992
|
+
throw new InvalidUsageError("A splice_info_section is at least three bytes.");
|
|
65993
|
+
}
|
|
65994
|
+
const muxer = output._muxer;
|
|
65995
|
+
if (!(muxer instanceof MpegTsMuxer)) {
|
|
65996
|
+
throw new InvalidUsageError("SCTE-35 sections can only be written to an MpegTsOutputFormat output.");
|
|
65997
|
+
}
|
|
65998
|
+
muxer.writeScte35Section(section);
|
|
65999
|
+
};
|
|
66000
|
+
|
|
65934
66001
|
// src/segment-index.ts
|
|
65935
66002
|
var segmentIndexOf = async (input, options) => {
|
|
65936
66003
|
if (!Number.isFinite(options.targetDuration) || options.targetDuration <= 0) {
|