fix hls offset and update libbitsub to v1.11.0

This commit is contained in:
altqx
2026-08-01 19:26:15 +07:00
parent 9c3d2d9d66
commit 6a502be3ca
4 changed files with 35 additions and 32 deletions
+24 -4
View File
@@ -49,7 +49,7 @@
"jquery": "3.7.1",
"jstree": "3.3.17",
"libarchive.js": "2.0.2",
"libbitsub": "1.10.2",
"libbitsub": "1.11.0",
"lodash-es": "4.18.1",
"markdown-it": "14.2.0",
"material-design-icons-iconfont": "6.7.0",
@@ -15019,15 +15019,35 @@
}
},
"node_modules/libbitsub": {
"version": "1.10.2",
"resolved": "https://registry.npmjs.org/libbitsub/-/libbitsub-1.10.2.tgz",
"integrity": "sha512-cXD1ueeeXqJIaNvYRrkNZOZ0A5FMMv9+8Yp/lHJZXPvkim5h0yvF2G27lYr0vGN9HwZCaJhkz6GArRerieTtuw==",
"version": "1.11.0",
"resolved": "https://registry.npmjs.org/libbitsub/-/libbitsub-1.11.0.tgz",
"integrity": "sha512-1niXMUxtvShJSv36enD6kVR2QABXtjz6vAVtqcMooU9qefZomQDXYpV0pIEQS3fXDmH4xjl+xVJdgNpk6i/oRA==",
"license": "MIT",
"dependencies": {
"@webgpu/types": "^0.1.71"
},
"engines": {
"node": ">=18"
},
"peerDependencies": {
"hls.js": ">=1.0.0",
"react": ">=18.0.0",
"shaka-player": ">=4.0.0",
"video.js": ">=7.0.0"
},
"peerDependenciesMeta": {
"hls.js": {
"optional": true
},
"react": {
"optional": true
},
"shaka-player": {
"optional": true
},
"video.js": {
"optional": true
}
}
},
"node_modules/lie": {
+1 -1
View File
@@ -117,7 +117,7 @@
"jquery": "3.7.1",
"jstree": "3.3.17",
"libarchive.js": "2.0.2",
"libbitsub": "1.10.2",
"libbitsub": "1.11.0",
"lodash-es": "4.18.1",
"markdown-it": "14.2.0",
"material-design-icons-iconfont": "6.7.0",
+3 -27
View File
@@ -644,30 +644,6 @@ function showPlaybackInfoErrorMessage(instance, errorCode) {
});
}
function isExternalGraphicalSubtitleStream(stream) {
if (!stream || stream.Type !== 'Subtitle' || stream.DeliveryMethod !== 'External') {
return false;
}
if (typeof stream.IsTextSubtitleStream === 'boolean') {
return !stream.IsTextSubtitleStream;
}
const codec = (stream.Codec || '').toLowerCase();
return codec === 'pgssub' || codec === 'dvdsub' || codec === 'vobsub';
}
function hasSelectedExternalGraphicalSubtitle(mediaSource) {
const selectedSubtitleIndices = [mediaSource.DefaultSubtitleStreamIndex, mediaSource.DefaultSecondarySubtitleStreamIndex]
.filter(index => typeof index === 'number' && index >= 0);
if (selectedSubtitleIndices.length === 0) {
return false;
}
return (mediaSource.MediaStreams || []).some(stream => selectedSubtitleIndices.includes(stream.Index) && isExternalGraphicalSubtitleStream(stream));
}
function normalizePlayOptions(playOptions) {
playOptions.fullscreen = playOptions.fullscreen !== false;
}
@@ -2899,10 +2875,10 @@ export class PlaybackManager {
contentType = 'application/x-mpegURL';
} else {
contentType = getMimeType(type.toLowerCase(), mediaSource.TranscodingContainer);
}
if (!(mediaSource.TranscodingSubProtocol === 'hls' && hasSelectedExternalGraphicalSubtitle(mediaSource))) {
transcodingOffsetTicks = startPosition || 0;
if (mediaUrl.toLowerCase().indexOf('copytimestamps=true') === -1) {
transcodingOffsetTicks = startPosition || 0;
}
}
}
} else {
+7
View File
@@ -452,6 +452,9 @@ export class HtmlVideoPlayer {
video: videoElement,
subUrl: getTextTrackUrl(track, item),
timeOffset: getSubtitleTimeOffset(this._currentPlayOptions, this.#currentTrackOffset),
streamingLoad: true,
rangeRequests: true,
prefetchWindow: { before: 1, after: 2 },
...(displaySettings ? { displaySettings } : {}),
onLoading: () => this.beginPendingSubtitleLoad(targetTextTrackIndex, loadToken),
onLoaded: () => this.endPendingSubtitleLoad(targetTextTrackIndex, loadToken),
@@ -504,6 +507,10 @@ export class HtmlVideoPlayer {
if (options.resetSubtitleOffset !== false) this.resetSubtitleOffset();
void import('libbitsub')
.then(({ warmup }) => warmup())
.catch((error) => console.warn('[libbitsub] worker prewarm failed; renderer fallback will be used', error));
const elem = await this.createMediaElement(options);
this.#applyAspectRatio(options.aspectRatio || this.getAspectRatio());