From 2f6781a7c2e3d2418a377a99a82c525e5129c8cd Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Tue, 21 Jan 2025 13:22:13 +0300 Subject: [PATCH 1/2] Use average framerate as sampling rate (target FPS) for SubtitlesOctopus --- src/plugins/htmlVideoPlayer/plugin.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/plugins/htmlVideoPlayer/plugin.js b/src/plugins/htmlVideoPlayer/plugin.js index 4bc0d60a377..25932661b11 100644 --- a/src/plugins/htmlVideoPlayer/plugin.js +++ b/src/plugins/htmlVideoPlayer/plugin.js @@ -119,6 +119,12 @@ function requireHlsPlayer(callback) { }); } +function getMediaStreamVideoTracks(mediaSource) { + return mediaSource.MediaStreams.filter(function (s) { + return s.Type === 'Video'; + }); +} + function getMediaStreamAudioTracks(mediaSource) { return mediaSource.MediaStreams.filter(function (s) { return s.Type === 'Audio'; @@ -1274,6 +1280,9 @@ export class HtmlVideoPlayer { }); const htmlVideoPlayer = this; import('@jellyfin/libass-wasm').then(({ default: SubtitlesOctopus }) => { + const mediaSource = this._currentPlayOptions.mediaSource; + const videoStream = getMediaStreamVideoTracks(mediaSource)[0]; + const options = { video: videoElement, subUrl: getTextTrackUrl(track, item), @@ -1296,7 +1305,7 @@ export class HtmlVideoPlayer { dropAllAnimations: false, libassMemoryLimit: 40, libassGlyphLimit: 40, - targetFps: 24, + targetFps: videoStream?.AverageFrameRate || videoStream?.RealFrameRate || 24, prescaleFactor: 0.8, prescaleHeightLimit: 1080, maxRenderHeight: 2160, From 36aa4dcd88d8f631f93fbfff1f498b819a04c45f Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo <56478732+dmitrylyzo@users.noreply.github.com> Date: Tue, 21 Jan 2025 22:43:37 +0300 Subject: [PATCH 2/2] Use reference framerate as sampling rate (target FPS) for SubtitlesOctopus --- src/plugins/htmlVideoPlayer/plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/htmlVideoPlayer/plugin.js b/src/plugins/htmlVideoPlayer/plugin.js index 25932661b11..47cc00156f5 100644 --- a/src/plugins/htmlVideoPlayer/plugin.js +++ b/src/plugins/htmlVideoPlayer/plugin.js @@ -1305,7 +1305,7 @@ export class HtmlVideoPlayer { dropAllAnimations: false, libassMemoryLimit: 40, libassGlyphLimit: 40, - targetFps: videoStream?.AverageFrameRate || videoStream?.RealFrameRate || 24, + targetFps: videoStream?.ReferenceFrameRate || videoStream?.RealFrameRate || 24, prescaleFactor: 0.8, prescaleHeightLimit: 1080, maxRenderHeight: 2160,