From 56574b35162453f2be1c7cdbc42464e81690cead Mon Sep 17 00:00:00 2001 From: Ian Walton Date: Sat, 10 Apr 2021 11:32:47 -0400 Subject: [PATCH] On branch master Send framerate to mpv player. --- src/plugins/mpvAudioPlayer/plugin.js | 2 +- src/plugins/mpvVideoPlayer/plugin.js | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/plugins/mpvAudioPlayer/plugin.js b/src/plugins/mpvAudioPlayer/plugin.js index def917e080..27da7313a3 100644 --- a/src/plugins/mpvAudioPlayer/plugin.js +++ b/src/plugins/mpvAudioPlayer/plugin.js @@ -113,7 +113,7 @@ class HtmlAudioPlayer { self.api.player.load(val, { startMilliseconds: ms, autoplay: true }, - {type: 'music', headers: {'User-Agent': 'JellyfinMediaPlayer'}, frameRate: 0, media: {}}, + {type: 'music', headers: {'User-Agent': 'JellyfinMediaPlayer'}, media: {}}, '#1', '', resolve); diff --git a/src/plugins/mpvVideoPlayer/plugin.js b/src/plugins/mpvVideoPlayer/plugin.js index 0980cab3e2..7abb66537e 100644 --- a/src/plugins/mpvVideoPlayer/plugin.js +++ b/src/plugins/mpvVideoPlayer/plugin.js @@ -189,6 +189,16 @@ async function getApi() { return '#' + this.#subtitleTrackIndexToSetOnPlaying; } + tryGetFramerate(options) { + if (options.mediaSource && options.mediaSource.MediaStreams) { + for (let stream of options.mediaSource.MediaStreams) { + if (stream.Type == "Video") { + return stream.RealFrameRate || stream.AverageFrameRate || null; + } + } + } + } + /** * @private */ @@ -204,10 +214,16 @@ async function getApi() { this.#subtitleTrackIndexToSetOnPlaying = options.mediaSource.DefaultSubtitleStreamIndex == null ? -1 : options.mediaSource.DefaultSubtitleStreamIndex; this.#audioTrackIndexToSetOnPlaying = options.playMethod === 'Transcode' ? null : options.mediaSource.DefaultAudioStreamIndex; + const streamdata = {type: 'video', headers: {'User-Agent': 'JellyfinMediaPlayer'}, media: {}}; + const fps = this.tryGetFramerate(options); + if (fps) { + streamdata.frameRate = fps; + } + const player = this.#api.player; player.load(val, { startMilliseconds: ms, autoplay: true }, - {type: 'video', headers: {'User-Agent': 'JellyfinMediaPlayer'}, frameRate: 0, media: {}}, + streamdata, (this.#audioTrackIndexToSetOnPlaying != null) ? '#' + this.#audioTrackIndexToSetOnPlaying : '#1', this.getSubtitleParam(),