dasha 4.5.1 → 4.5.2
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/index.d.mts +1 -0
- package/dist/index.mjs +11 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AudioCodec as AudioCodec$1, DurationMetadataRequestOptions, EncodedPacket, FilePathSource, HLS, HLS_FORMATS, Input as Input$1, InputAudioTrack as InputAudioTrack$1, InputFormat, InputOptions, InputTrack as InputTrack$2, InputTrackQuery, InputTrackQuery as InputTrackQuery$1, InputVideoTrack as InputVideoTrack$1, MP3, MP4, MaybePromise, MaybePromise as MaybePromise$1, MediaCodec as MediaCodec$1, MetadataTags, PacketRetrievalOptions, PathedSource, Source, SourceRef, SubtitleCodec as SubtitleCodec$1, TrackDisposition, TransformationMatrix, UrlSource, VideoCodec as VideoCodec$1, asc, desc, prefer } from "mediabunny";
|
|
2
|
+
import { Temporal } from "temporal-polyfill";
|
|
2
3
|
//#region src/mediabunny.d.ts
|
|
3
4
|
type Segment$1 = {
|
|
4
5
|
timestamp: number;
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ADTS, ALL_FORMATS as ALL_FORMATS$1, CustomPathedSource, FilePathSource, HLS, HLS as HLS$1, HLS_FORMATS, Input as Input$1, InputFormat, InputTrack, InputVideoTrack, MATROSKA, MP3, MP3 as MP3$1, MP4, MP4 as MP4$1, QTFF, SourceRef, UrlSource, WEBM, asc, desc, prefer } from "mediabunny";
|
|
2
2
|
import { DOMParser } from "@xmldom/xmldom";
|
|
3
|
-
import { Temporal } from "temporal-polyfill";
|
|
4
3
|
import { readFile } from "node:fs/promises";
|
|
4
|
+
import { Temporal } from "temporal-polyfill";
|
|
5
5
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
7
|
//#region src/util.ts
|
|
@@ -514,6 +514,13 @@ const parseDashRange = (range) => {
|
|
|
514
514
|
const [startRange, end] = range.split("-").map(Number);
|
|
515
515
|
return [startRange, end - startRange + 1];
|
|
516
516
|
};
|
|
517
|
+
const OVERPRECISE_SECONDS_PATTERN = /(\d+)\.(\d{10,})S/;
|
|
518
|
+
const normalizeDashDuration = (duration) => duration.replace(OVERPRECISE_SECONDS_PATTERN, (_, seconds, fraction) => {
|
|
519
|
+
const nanos = Math.round(Number(`0.${fraction}`) * 1e9);
|
|
520
|
+
if (nanos >= 1e9) return `${Number(seconds) + 1}.000000000S`;
|
|
521
|
+
return `${seconds}.${String(nanos).padStart(9, "0")}S`;
|
|
522
|
+
});
|
|
523
|
+
const parseDashDuration = (duration) => Temporal.Duration.from(normalizeDashDuration(duration));
|
|
517
524
|
//#endregion
|
|
518
525
|
//#region src/hls/hls-subtitles.ts
|
|
519
526
|
const TAG_STREAM_INF = "#EXT-X-STREAM-INF:";
|
|
@@ -2244,7 +2251,7 @@ const processDashContent = (mpdContent) => {
|
|
|
2244
2251
|
const missingNamespaceDefinitions = missingNamespaceKeys.map((key) => `xmlns:${key}="${DASH_NAMESPACE_MAP.get(key)}"`);
|
|
2245
2252
|
return replaceFirst(mpdContent, "<MPD ", `<MPD ${missingNamespaceDefinitions.join(" ")} `);
|
|
2246
2253
|
};
|
|
2247
|
-
const getDashRefreshIntervalMs = (timeShiftBufferDepth) =>
|
|
2254
|
+
const getDashRefreshIntervalMs = (timeShiftBufferDepth) => parseDashDuration(timeShiftBufferDepth).total("milliseconds") / 2;
|
|
2248
2255
|
const getDisposition = (track) => ({
|
|
2249
2256
|
...DEFAULT_TRACK_DISPOSITION,
|
|
2250
2257
|
commentary: track.role === ROLE_TYPE.Commentary,
|
|
@@ -2522,7 +2529,7 @@ const applyFixedDurationTemplate = (params) => {
|
|
|
2522
2529
|
const offsetMs = Number(presentationTimeOffset) / 1e3;
|
|
2523
2530
|
availableTime.setUTCMilliseconds(availableTime.getUTCMilliseconds() + offsetMs);
|
|
2524
2531
|
const elapsedSeconds = (now - availableTime.getTime()) / 1e3;
|
|
2525
|
-
const updateWindowSeconds =
|
|
2532
|
+
const updateWindowSeconds = parseDashDuration(timeShiftBufferDepth).total("seconds");
|
|
2526
2533
|
startNumber += (elapsedSeconds - updateWindowSeconds) * timescale / duration;
|
|
2527
2534
|
totalNumber = updateWindowSeconds * timescale / duration;
|
|
2528
2535
|
}
|
|
@@ -2739,7 +2746,7 @@ var DashDemuxer = class {
|
|
|
2739
2746
|
return manifest;
|
|
2740
2747
|
}
|
|
2741
2748
|
appendPeriodTracks(tracks, manifest, period) {
|
|
2742
|
-
const periodDurationSeconds =
|
|
2749
|
+
const periodDurationSeconds = parseDashDuration(period.getAttribute("duration") || manifest.mediaPresentationDuration || "PT0S").total("seconds");
|
|
2743
2750
|
const periodBaseUrl = extendDashBaseUrl(period, this.baseUrl);
|
|
2744
2751
|
for (const adaptationSet of getDirectDashChildren(period, "AdaptationSet")) this.appendAdaptationSetTracks({
|
|
2745
2752
|
tracks,
|