@ahmedrowaihi/mediabunny 1.65.2-beta.699 → 1.65.2-beta.700
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 +80 -41
- package/dist/bundles/mediabunny.min.cjs +34 -34
- package/dist/bundles/mediabunny.min.mjs +34 -34
- package/dist/bundles/mediabunny.mjs +80 -41
- package/dist/bundles/mediabunny.node.cjs +80 -41
- package/dist/modules/src/mpeg-ts/mpeg-ts-demuxer.d.ts +2 -0
- package/dist/modules/src/mpeg-ts/mpeg-ts-demuxer.d.ts.map +1 -1
- package/dist/modules/src/mpeg-ts/mpeg-ts-demuxer.js +18 -3
- package/dist/modules/src/mpeg-ts/mpeg-ts-misc.d.ts +2 -0
- package/dist/modules/src/mpeg-ts/mpeg-ts-misc.d.ts.map +1 -1
- package/dist/modules/src/mpeg-ts/mpeg-ts-misc.js +2 -0
- package/dist/modules/src/mpeg-ts/mpeg-ts-muxer.d.ts +12 -2
- package/dist/modules/src/mpeg-ts/mpeg-ts-muxer.d.ts.map +1 -1
- package/dist/modules/src/mpeg-ts/mpeg-ts-muxer.js +73 -45
- package/dist/modules/src/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/mpeg-ts/mpeg-ts-demuxer.ts +20 -2
- package/src/mpeg-ts/mpeg-ts-misc.ts +2 -0
- package/src/mpeg-ts/mpeg-ts-muxer.ts +81 -40
|
@@ -18270,6 +18270,7 @@ var Mediabunny = (() => {
|
|
|
18270
18270
|
var TS_PACKET_SIZE = 188;
|
|
18271
18271
|
var PAT_PID = 0;
|
|
18272
18272
|
var REGISTRATION_DESCRIPTOR_TAG = 5;
|
|
18273
|
+
var LANGUAGE_DESCRIPTOR_TAG = 10;
|
|
18273
18274
|
var fourCc = (code) => [...code].map((character) => character.charCodeAt(0));
|
|
18274
18275
|
var buildPrivateDataIndicatorDescriptor = (code) => new Uint8Array([15, 4, ...fourCc(code)]);
|
|
18275
18276
|
var buildAudioSetupDescriptor = (audioType, setupData) => {
|
|
@@ -18457,11 +18458,21 @@ var Mediabunny = (() => {
|
|
|
18457
18458
|
let hasEac3Descriptor = false;
|
|
18458
18459
|
let hasDtsDescriptor = false;
|
|
18459
18460
|
let hasCueiDescriptor = false;
|
|
18461
|
+
let languageCode = UNDETERMINED_LANGUAGE;
|
|
18460
18462
|
while (bitstream.pos < esInfoEndPos) {
|
|
18461
18463
|
const descriptorTag = bitstream.readBits(8);
|
|
18462
18464
|
const descriptorLength = bitstream.readBits(8);
|
|
18463
18465
|
const descriptorEndPos = bitstream.pos + 8 * descriptorLength;
|
|
18464
|
-
if (descriptorTag ===
|
|
18466
|
+
if (descriptorTag === LANGUAGE_DESCRIPTOR_TAG && descriptorLength >= 4) {
|
|
18467
|
+
const characters = [
|
|
18468
|
+
bitstream.readBits(8),
|
|
18469
|
+
bitstream.readBits(8),
|
|
18470
|
+
bitstream.readBits(8)
|
|
18471
|
+
];
|
|
18472
|
+
if (characters.every((code) => code >= 97 && code <= 122)) {
|
|
18473
|
+
languageCode = String.fromCharCode(...characters);
|
|
18474
|
+
}
|
|
18475
|
+
} else if (descriptorTag === 106) {
|
|
18465
18476
|
hasAc3Descriptor = true;
|
|
18466
18477
|
} else if (descriptorTag === 122 || descriptorTag === 204) {
|
|
18467
18478
|
hasEac3Descriptor = true;
|
|
@@ -18589,6 +18600,7 @@ var Mediabunny = (() => {
|
|
|
18589
18600
|
initialized: false,
|
|
18590
18601
|
firstSection: null,
|
|
18591
18602
|
canBeTrustedWithKeyPackets: false,
|
|
18603
|
+
languageCode,
|
|
18592
18604
|
info,
|
|
18593
18605
|
referencePesPackets: []
|
|
18594
18606
|
});
|
|
@@ -19148,7 +19160,7 @@ var Mediabunny = (() => {
|
|
|
19148
19160
|
return null;
|
|
19149
19161
|
}
|
|
19150
19162
|
getLanguageCode() {
|
|
19151
|
-
return
|
|
19163
|
+
return this.elementaryStream.languageCode;
|
|
19152
19164
|
}
|
|
19153
19165
|
getDisposition() {
|
|
19154
19166
|
return {
|
|
@@ -45848,8 +45860,6 @@ ${cue.notes ?? ""}`;
|
|
|
45848
45860
|
this.packetBuffer = new Uint8Array(TS_PACKET_SIZE);
|
|
45849
45861
|
this.packetView = toDataView(this.packetBuffer);
|
|
45850
45862
|
this.allTracksKnown = promiseWithResolvers();
|
|
45851
|
-
this.videoTrackIndex = 0;
|
|
45852
|
-
this.audioTrackIndex = 0;
|
|
45853
45863
|
this.adaptationFieldBuffer = new Uint8Array(184);
|
|
45854
45864
|
this.pcrPid = null;
|
|
45855
45865
|
this.payloadBuffer = new Uint8Array(184);
|
|
@@ -45860,6 +45870,31 @@ ${cue.notes ?? ""}`;
|
|
|
45860
45870
|
this.tableRepeatInterval = format._options.tableRepeatInterval ?? 0.1;
|
|
45861
45871
|
this.privateStreams = format._options.privateStreams ?? [];
|
|
45862
45872
|
}
|
|
45873
|
+
/**
|
|
45874
|
+
* PIDs and stream ids follow the order tracks were added to the output, not the order their first
|
|
45875
|
+
* packets arrive - two runs of the same job interleave differently, and that used to renumber the
|
|
45876
|
+
* streams. The index is of this track among the output's tracks of its own kind.
|
|
45877
|
+
*/
|
|
45878
|
+
trackIndexOf(track) {
|
|
45879
|
+
return this.output.tracks.filter((x) => x.type === track.type).indexOf(track);
|
|
45880
|
+
}
|
|
45881
|
+
pidOf(track) {
|
|
45882
|
+
return FIRST_TRACK_PID + this.output.tracks.indexOf(track);
|
|
45883
|
+
}
|
|
45884
|
+
/**
|
|
45885
|
+
* Keeps `trackDatas` in the output's own track order. The PMT lists streams in this order and the
|
|
45886
|
+
* tables are written from it, so appending on arrival left the same job writing different bytes.
|
|
45887
|
+
*/
|
|
45888
|
+
addTrackData(trackData) {
|
|
45889
|
+
const index = this.trackDatas.findIndex(
|
|
45890
|
+
(existing) => this.output.tracks.indexOf(existing.track) > this.output.tracks.indexOf(trackData.track)
|
|
45891
|
+
);
|
|
45892
|
+
if (index === -1) {
|
|
45893
|
+
this.trackDatas.push(trackData);
|
|
45894
|
+
} else {
|
|
45895
|
+
this.trackDatas.splice(index, 0, trackData);
|
|
45896
|
+
}
|
|
45897
|
+
}
|
|
45863
45898
|
get maxInterleaveDelta() {
|
|
45864
45899
|
return this.format._options.maxInterleaveDelta ?? DEFAULT_MAX_INTERLEAVE_DELTA;
|
|
45865
45900
|
}
|
|
@@ -45888,8 +45923,8 @@ ${cue.notes ?? ""}`;
|
|
|
45888
45923
|
);
|
|
45889
45924
|
}
|
|
45890
45925
|
const streamType = codec === "avc" ? encryption ? 219 /* SAMPLE_AES_AVC */ : 27 /* AVC */ : codec === "mpeg2" ? 2 /* MPEG2_VIDEO */ : 36 /* HEVC */;
|
|
45891
|
-
const pid =
|
|
45892
|
-
const streamId = VIDEO_STREAM_ID_BASE + this.
|
|
45926
|
+
const pid = this.pidOf(track);
|
|
45927
|
+
const streamId = VIDEO_STREAM_ID_BASE + this.trackIndexOf(track);
|
|
45893
45928
|
const newTrackData = {
|
|
45894
45929
|
track,
|
|
45895
45930
|
pid,
|
|
@@ -45908,7 +45943,7 @@ ${cue.notes ?? ""}`;
|
|
|
45908
45943
|
firstPacketWritten: false,
|
|
45909
45944
|
closed: false
|
|
45910
45945
|
};
|
|
45911
|
-
this.
|
|
45946
|
+
this.addTrackData(newTrackData);
|
|
45912
45947
|
if (this.allTracksAreKnown()) {
|
|
45913
45948
|
this.allTracksKnown.resolve();
|
|
45914
45949
|
}
|
|
@@ -45937,7 +45972,7 @@ ${cue.notes ?? ""}`;
|
|
|
45937
45972
|
case "aac":
|
|
45938
45973
|
{
|
|
45939
45974
|
streamType = audioEncryption ? 207 /* SAMPLE_AES_AAC */ : 15 /* AAC */;
|
|
45940
|
-
streamId = AUDIO_STREAM_ID_BASE + this.
|
|
45975
|
+
streamId = AUDIO_STREAM_ID_BASE + this.trackIndexOf(track);
|
|
45941
45976
|
}
|
|
45942
45977
|
;
|
|
45943
45978
|
break;
|
|
@@ -45947,7 +45982,7 @@ ${cue.notes ?? ""}`;
|
|
|
45947
45982
|
case "mp2":
|
|
45948
45983
|
{
|
|
45949
45984
|
streamType = 3 /* MP3_MPEG1 */;
|
|
45950
|
-
streamId = AUDIO_STREAM_ID_BASE + this.
|
|
45985
|
+
streamId = AUDIO_STREAM_ID_BASE + this.trackIndexOf(track);
|
|
45951
45986
|
}
|
|
45952
45987
|
;
|
|
45953
45988
|
break;
|
|
@@ -45973,7 +46008,7 @@ ${cue.notes ?? ""}`;
|
|
|
45973
46008
|
;
|
|
45974
46009
|
break;
|
|
45975
46010
|
}
|
|
45976
|
-
const pid =
|
|
46011
|
+
const pid = this.pidOf(track);
|
|
45977
46012
|
const newTrackData = {
|
|
45978
46013
|
track,
|
|
45979
46014
|
pid,
|
|
@@ -45997,7 +46032,7 @@ ${cue.notes ?? ""}`;
|
|
|
45997
46032
|
"SAMPLE-AES needs this AAC track's AudioSpecificConfig for the PMT audio setup descriptor, but its decoder config states none."
|
|
45998
46033
|
);
|
|
45999
46034
|
}
|
|
46000
|
-
this.
|
|
46035
|
+
this.addTrackData(newTrackData);
|
|
46001
46036
|
if (this.allTracksAreKnown()) {
|
|
46002
46037
|
this.allTracksKnown.resolve();
|
|
46003
46038
|
}
|
|
@@ -46611,20 +46646,39 @@ ${cue.notes ?? ""}`;
|
|
|
46611
46646
|
buf[offset + 4] = base90kHz % 2 << 7 | 126;
|
|
46612
46647
|
buf[offset + 5] = 0;
|
|
46613
46648
|
};
|
|
46649
|
+
var languageDescriptor = (languageCode) => new Uint8Array([
|
|
46650
|
+
LANGUAGE_DESCRIPTOR_TAG,
|
|
46651
|
+
4,
|
|
46652
|
+
languageCode.charCodeAt(0),
|
|
46653
|
+
languageCode.charCodeAt(1),
|
|
46654
|
+
languageCode.charCodeAt(2),
|
|
46655
|
+
0
|
|
46656
|
+
// audio_type: undefined, which is what a track that only states a language means
|
|
46657
|
+
]);
|
|
46658
|
+
var esDescriptorsOf = (trackData) => {
|
|
46659
|
+
const descriptors = sampleAesDescriptorsFor(trackData);
|
|
46660
|
+
if (descriptors.length === 0) {
|
|
46661
|
+
if (trackData.streamType === 129 /* AC3_SYSTEM_A */) {
|
|
46662
|
+
descriptors.push(AC3_REGISTRATION_DESCRIPTOR);
|
|
46663
|
+
} else if (trackData.streamType === 135 /* EAC3_SYSTEM_A */) {
|
|
46664
|
+
descriptors.push(EAC3_REGISTRATION_DESCRIPTOR);
|
|
46665
|
+
}
|
|
46666
|
+
}
|
|
46667
|
+
const languageCode = trackData.track.metadata.languageCode;
|
|
46668
|
+
if (languageCode !== void 0 && languageCode !== UNDETERMINED_LANGUAGE) {
|
|
46669
|
+
descriptors.push(languageDescriptor(languageCode));
|
|
46670
|
+
}
|
|
46671
|
+
return descriptors;
|
|
46672
|
+
};
|
|
46614
46673
|
var descriptorBytesOf = (stream) => stream.descriptors.reduce((sum, descriptor) => sum + descriptor.byteLength, 0);
|
|
46615
46674
|
var buildPmt = (trackDatas, scte35Pid, privateStreams) => {
|
|
46616
|
-
const
|
|
46675
|
+
const esDescriptors = /* @__PURE__ */ new Map();
|
|
46617
46676
|
let totalEsBytes = 0;
|
|
46618
46677
|
for (const trackData of trackDatas) {
|
|
46619
46678
|
totalEsBytes += 5;
|
|
46620
|
-
const descriptors =
|
|
46621
|
-
|
|
46679
|
+
const descriptors = esDescriptorsOf(trackData);
|
|
46680
|
+
esDescriptors.set(trackData, descriptors);
|
|
46622
46681
|
totalEsBytes += descriptors.reduce((sum, descriptor) => sum + descriptor.length, 0);
|
|
46623
|
-
if (trackData.streamType === 129 /* AC3_SYSTEM_A */) {
|
|
46624
|
-
totalEsBytes += AC3_REGISTRATION_DESCRIPTOR.length;
|
|
46625
|
-
} else if (trackData.streamType === 135 /* EAC3_SYSTEM_A */) {
|
|
46626
|
-
totalEsBytes += EAC3_REGISTRATION_DESCRIPTOR.length;
|
|
46627
|
-
}
|
|
46628
46682
|
}
|
|
46629
46683
|
for (const stream of privateStreams) {
|
|
46630
46684
|
totalEsBytes += 5 + descriptorBytesOf(stream);
|
|
@@ -46649,28 +46703,13 @@ ${cue.notes ?? ""}`;
|
|
|
46649
46703
|
section[offset++] = trackData.streamType;
|
|
46650
46704
|
view2.setUint16(offset, 57344 | trackData.pid & 8191, false);
|
|
46651
46705
|
offset += 2;
|
|
46652
|
-
const descriptors =
|
|
46653
|
-
|
|
46654
|
-
|
|
46655
|
-
|
|
46656
|
-
|
|
46657
|
-
|
|
46658
|
-
|
|
46659
|
-
offset += descriptor.length;
|
|
46660
|
-
}
|
|
46661
|
-
} else if (trackData.streamType === 129 /* AC3_SYSTEM_A */) {
|
|
46662
|
-
view2.setUint16(offset, 61440 | AC3_REGISTRATION_DESCRIPTOR.length, false);
|
|
46663
|
-
offset += 2;
|
|
46664
|
-
section.set(AC3_REGISTRATION_DESCRIPTOR, offset);
|
|
46665
|
-
offset += AC3_REGISTRATION_DESCRIPTOR.length;
|
|
46666
|
-
} else if (trackData.streamType === 135 /* EAC3_SYSTEM_A */) {
|
|
46667
|
-
view2.setUint16(offset, 61440 | EAC3_REGISTRATION_DESCRIPTOR.length, false);
|
|
46668
|
-
offset += 2;
|
|
46669
|
-
section.set(EAC3_REGISTRATION_DESCRIPTOR, offset);
|
|
46670
|
-
offset += EAC3_REGISTRATION_DESCRIPTOR.length;
|
|
46671
|
-
} else {
|
|
46672
|
-
view2.setUint16(offset, 61440, false);
|
|
46673
|
-
offset += 2;
|
|
46706
|
+
const descriptors = esDescriptors.get(trackData);
|
|
46707
|
+
const length = descriptors.reduce((sum, descriptor) => sum + descriptor.length, 0);
|
|
46708
|
+
view2.setUint16(offset, 61440 | length, false);
|
|
46709
|
+
offset += 2;
|
|
46710
|
+
for (const descriptor of descriptors) {
|
|
46711
|
+
section.set(descriptor, offset);
|
|
46712
|
+
offset += descriptor.length;
|
|
46674
46713
|
}
|
|
46675
46714
|
}
|
|
46676
46715
|
for (const stream of privateStreams) {
|