From 6a502be3ca93092120e59512d483a55e190b2d5f Mon Sep 17 00:00:00 2001 From: altqx Date: Sat, 1 Aug 2026 19:26:15 +0700 Subject: [PATCH] fix hls offset and update libbitsub to v1.11.0 --- package-lock.json | 28 +++++++++++++++++--- package.json | 2 +- src/components/playback/playbackmanager.js | 30 +++------------------- src/plugins/htmlVideoPlayer/plugin.js | 7 +++++ 4 files changed, 35 insertions(+), 32 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3a3355fb8d..c9d1bf038e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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": { diff --git a/package.json b/package.json index 0f49a24a4d..9ffc012168 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/components/playback/playbackmanager.js b/src/components/playback/playbackmanager.js index c715f4da21..4acf6b7a63 100644 --- a/src/components/playback/playbackmanager.js +++ b/src/components/playback/playbackmanager.js @@ -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 { diff --git a/src/plugins/htmlVideoPlayer/plugin.js b/src/plugins/htmlVideoPlayer/plugin.js index 8ecaafad3d..9b4db45281 100644 --- a/src/plugins/htmlVideoPlayer/plugin.js +++ b/src/plugins/htmlVideoPlayer/plugin.js @@ -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());