mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Migrate back from JASSUB to JavascriptSubtitlesOctopus
JASSUB has some problems with non-Latin languages. This reverts:3560715f41
0b3d2d841f
93c4dbbe4c
478f81fecf
f0e8eb52bb
52c8cffc82
This commit is contained in:
parent
2e3a8300d1
commit
8125c68d24
5 changed files with 76 additions and 138 deletions
|
@ -217,7 +217,7 @@ export class HtmlVideoPlayer {
|
|||
*/
|
||||
#currentAssRenderer;
|
||||
/**
|
||||
* @type {null | undefined}
|
||||
* @type {number | undefined}
|
||||
*/
|
||||
#customTrackIndex;
|
||||
/**
|
||||
|
@ -983,6 +983,8 @@ export class HtmlVideoPlayer {
|
|||
seekOnPlaybackStart(this, e.target, this._currentPlayOptions.playerStartPositionTicks, () => {
|
||||
if (this.#currentAssRenderer) {
|
||||
this.#currentAssRenderer.timeOffset = (this._currentPlayOptions.transcodingOffsetTicks || 0) / 10000000 + this.#currentTrackOffset;
|
||||
this.#currentAssRenderer.resize();
|
||||
this.#currentAssRenderer.resetRenderAheadCache(false);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1169,9 +1171,9 @@ export class HtmlVideoPlayer {
|
|||
this.#currentClock = null;
|
||||
this._currentAspectRatio = null;
|
||||
|
||||
const jassub = this.#currentAssRenderer;
|
||||
if (jassub) {
|
||||
jassub.destroy();
|
||||
const octopus = this.#currentAssRenderer;
|
||||
if (octopus) {
|
||||
octopus.dispose();
|
||||
}
|
||||
this.#currentAssRenderer = null;
|
||||
}
|
||||
|
@ -1260,76 +1262,60 @@ export class HtmlVideoPlayer {
|
|||
const fallbackFontList = apiClient.getUrl('/FallbackFont/Fonts', {
|
||||
api_key: apiClient.accessToken()
|
||||
});
|
||||
// TODO: replace with `event-target-polyfill` once https://github.com/benlesh/event-target-polyfill/pull/12 or 11 is merged
|
||||
import('event-target-polyfill').then(() => {
|
||||
import('jassub').then(({ default: JASSUB }) => {
|
||||
// test SIMD support
|
||||
JASSUB._test();
|
||||
const htmlVideoPlayer = this;
|
||||
import('@jellyfin/libass-wasm').then(({ default: SubtitlesOctopus }) => {
|
||||
const options = {
|
||||
video: videoElement,
|
||||
subUrl: getTextTrackUrl(track, item),
|
||||
fonts: avaliableFonts,
|
||||
workerUrl: `${appRouter.baseUrl()}/libraries/subtitles-octopus-worker.js`,
|
||||
legacyWorkerUrl: `${appRouter.baseUrl()}/libraries/subtitles-octopus-worker-legacy.js`,
|
||||
onError() {
|
||||
// HACK: Clear JavascriptSubtitlesOctopus: it gets disposed when an error occurs
|
||||
htmlVideoPlayer.#currentAssRenderer = null;
|
||||
|
||||
const options = {
|
||||
video: videoElement,
|
||||
subUrl: getTextTrackUrl(track, item),
|
||||
fonts: avaliableFonts,
|
||||
fallbackFont: 'liberation sans',
|
||||
availableFonts: { 'liberation sans': `${appRouter.baseUrl()}/default.woff2` },
|
||||
// Disabled eslint compat, but is safe as corejs3 polyfills URL
|
||||
// eslint-disable-next-line compat/compat
|
||||
workerUrl: new URL('jassub/dist/jassub-worker.js', import.meta.url).href,
|
||||
// eslint-disable-next-line compat/compat
|
||||
wasmUrl: new URL('jassub/dist/jassub-worker.wasm', import.meta.url).href,
|
||||
// eslint-disable-next-line compat/compat
|
||||
legacyWasmUrl: new URL('jassub/dist/jassub-worker.wasm.js', import.meta.url).href,
|
||||
// eslint-disable-next-line compat/compat
|
||||
modernWasmUrl : new URL('jassub/dist/jassub-worker-modern.wasm', import.meta.url).href,
|
||||
timeOffset: (this._currentPlayOptions.transcodingOffsetTicks || 0) / 10000000,
|
||||
// new jassub options; override all, even defaults
|
||||
blendMode: 'js',
|
||||
asyncRender: true,
|
||||
offscreenRender: true,
|
||||
// RVFC is polyfilled everywhere, but webOS 2 reports polyfill API's as functional even tho they aren't
|
||||
onDemandRender: browser.web0sVersion !== 2,
|
||||
useLocalFonts: true,
|
||||
dropAllAnimations: false,
|
||||
dropAllBlur: !JASSUB._supportsSIMD,
|
||||
libassMemoryLimit: 40,
|
||||
libassGlyphLimit: 40,
|
||||
targetFps: 24,
|
||||
prescaleFactor: 0.8,
|
||||
prescaleHeightLimit: 1080,
|
||||
maxRenderHeight: 2160
|
||||
};
|
||||
// HACK: Give JavascriptSubtitlesOctopus time to dispose itself
|
||||
setTimeout(() => {
|
||||
onErrorInternal(htmlVideoPlayer, 'mediadecodeerror');
|
||||
}, 0);
|
||||
},
|
||||
timeOffset: (this._currentPlayOptions.transcodingOffsetTicks || 0) / 10000000,
|
||||
|
||||
Promise.all([
|
||||
apiClient.getNamedConfiguration('encoding'),
|
||||
// Worker in Tizen 5 doesn't resolve relative path with async request
|
||||
resolveUrl(options.workerUrl),
|
||||
resolveUrl(options.legacyWorkerUrl)
|
||||
]).then(([config, workerUrl, legacyWorkerUrl]) => {
|
||||
options.workerUrl = workerUrl;
|
||||
options.legacyWorkerUrl = legacyWorkerUrl;
|
||||
// new octopus options; override all, even defaults
|
||||
renderMode: 'wasm-blend',
|
||||
dropAllAnimations: false,
|
||||
libassMemoryLimit: 40,
|
||||
libassGlyphLimit: 40,
|
||||
targetFps: 24,
|
||||
prescaleFactor: 0.8,
|
||||
prescaleHeightLimit: 1080,
|
||||
maxRenderHeight: 2160,
|
||||
resizeVariation: 0.2,
|
||||
renderAhead: 90
|
||||
};
|
||||
|
||||
const cleanup = () => {
|
||||
this.#currentAssRenderer.destroy();
|
||||
this.#currentAssRenderer = null;
|
||||
onErrorInternal(this, 'mediadecodeerror');
|
||||
};
|
||||
Promise.all([
|
||||
apiClient.getNamedConfiguration('encoding'),
|
||||
// Worker in Tizen 5 doesn't resolve relative path with async request
|
||||
resolveUrl(options.workerUrl),
|
||||
resolveUrl(options.legacyWorkerUrl)
|
||||
]).then(([config, workerUrl, legacyWorkerUrl]) => {
|
||||
options.workerUrl = workerUrl;
|
||||
options.legacyWorkerUrl = legacyWorkerUrl;
|
||||
|
||||
if (config.EnableFallbackFont) {
|
||||
apiClient.getJSON(fallbackFontList).then((fontFiles = []) => {
|
||||
fontFiles.forEach(font => {
|
||||
const fontUrl = apiClient.getUrl(`/FallbackFont/Fonts/${font.Name}`, {
|
||||
api_key: apiClient.accessToken()
|
||||
});
|
||||
avaliableFonts.push(fontUrl);
|
||||
if (config.EnableFallbackFont) {
|
||||
apiClient.getJSON(fallbackFontList).then((fontFiles = []) => {
|
||||
fontFiles.forEach(font => {
|
||||
const fontUrl = apiClient.getUrl(`/FallbackFont/Fonts/${font.Name}`, {
|
||||
api_key: apiClient.accessToken()
|
||||
});
|
||||
this.#currentAssRenderer = new JASSUB(options);
|
||||
this.#currentAssRenderer.addEventListener('error', cleanup, { once: true });
|
||||
avaliableFonts.push(fontUrl);
|
||||
});
|
||||
} else {
|
||||
this.#currentAssRenderer = new JASSUB(options);
|
||||
this.#currentAssRenderer.addEventListener('error', cleanup, { once: true });
|
||||
}
|
||||
});
|
||||
this.#currentAssRenderer = new SubtitlesOctopus(options);
|
||||
});
|
||||
} else {
|
||||
this.#currentAssRenderer = new SubtitlesOctopus(options);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue