-
-
Notifications
You must be signed in to change notification settings - Fork 141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Select appropriate default subtitles based on user preferences #566
Conversation
I might be testing this wrong. I set my user settings to "Always" and "Spanish". When I play a movie on Roku, I don't get any subtitles. However, if I press "down", I do see that it has highlighted / selected "Spanish" as the subtitle of choice. It's just not actually showing them. |
Hmm, you seem to be testing it appropriately. Does that subtitle track work without this patch, if you select it manually after starting the movie (from the "down" menu)? Just trying to eliminate "easy" reasons for the issue. 😄 I just retested a bunch of movies with English subtitles (as that is what I have the most of) and it appears to work fine for both "Always" and "OnlyForced". I did test a couple with Spanish subtitles, and they seemed to work as well, though I have many fewer of those to test. One thing to note is that the subtitle being selected in the "Down" menu means that the corresponding track index had to have passed to the server in the "ItemPostPlaybackInfo" call, as the index in the displayed subtitle list is computed from the track index supplied to the server. As such, we at least believe we have sent the correct index to the server. One unrelated thought/question regarding this change that just came to mind: Would it be better to enforce the user's preferred language when selecting these subtitles (i.e. only allow displaying subtitles in the user's preferred language)? Right now we just find the "best" (based on the sorting and mode preferences) subtitle option regardless of language. I'm thinking so, but before I change anything... Thanks for looking at this, BTW. |
I still think it might be on my end. I tried the web client and it also doesn't "Always Play" what I have selected in settings. I'm connecting to a beta 10.8 server. So either I'm doing something wrong or it's a server bug. |
3bc3422
to
423ee54
Compare
That sounds possible based on the differences between our experiences. I'm still running 10.7.7, in case that is pertinent. Note on the most recent push: |
423ee54
to
6a89b72
Compare
Note on the most recent push: @jimdogx Were your subtitles text-based when you were testing this change? If so, would you mind retesting (when you have time, ofc)? I managed to reproduce an issue with text-based subtitles on my end, which should be resolved in this latest change. |
Greetings!! If I read the comments correctly, this commit will allow the Roku client to correctly show forced subtitle tracks for things like foreign language parts of films automatically if the server is set to do so? This would be very exciting if that's the case! |
@lakerssuperman That's the goal. It should support the other settings as well, but forced subtitles was the main driving force behind my wanting to implement it. |
That's awesome! Thank you!!! |
I did a pile of (very overdue - sorry) testing today and it all appeared to work as described. There are another couple of tests I want to do, which I'll try and complete early this week. But this is looking great. Thanks. |
source/utils/Subtitles.brs
Outdated
else | ||
' If this is a text-based subtitle, set relevant settings for roku captions | ||
video.globalCaptionMode = "On" | ||
video.subtitleTrack = selectedSubtitle.TrackName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
video.subtitleTrack = selectedSubtitle.TrackName | |
video.subtitleTrack = selectedSubtitle.Track.TrackName |
I think the TrackName property is within a Track
property on the subtitle
So done some more testing specifically on the issue @jimdogx had mentioned previously, and I observer the same behaviour. It seems that the PR is setting the correct mode of subtitles (whether to display or not) based on the preferences, but it's always the default (or first) subtitle track that is used, at least with text subtitles. What I'm seeing is that However, when the video starts playing, the So I think when you're setting I can provide a sample mkv file with a pile of SRT subtitle tracks if that's of any use. In my case, Eng is the 1st subtitle track, and that all works fine. But when I set my user preference to use |
75a1854
to
14451f0
Compare
@neilsb Thanks for catching that issue, I had not noticed that behavior, as I only have English text-based subtitles. I believe I have resolved the issue in the latest patch (in addition to rebasing on tips of master), at least based on |
@cthelight Something odd is certainly going on. The change you've made does indeed now set the correct subtitle track URL in the property, but it's still the 1st subtitle track that plays. If you then choose a different track then go back to the one that should have been played, then the same URL is set back into that property and then correct subtitle track is used. Very odd. If you want to test it, here is the sample video I was using (~30 Mb). I set my preferred language as "Italian", but English was displayed (even though the URL for the Italian was being set correctly). If, during playback, I switch to "Hungarian" then back to "Italian" then the same URL is set again, but the correct track is then used. |
On other players (web/andriod app) the user perferences for subtitle behavior are taken into account, and used to make an assumption about subtitle behavior. This patch ports most of that logic here. "Smart" selection is not yet fully-featured, as it requires additional knowledge about audio language preferences. Rather it uses the fallback mechanism, which emulates the "Default" subtitle option. The logic for the different options was based on the main jellyfin repo (specifically sha 49d5fdb33fc9792147c1df03e1d1b051e6b7ec79 in file Emby.Server.Implementations/Library/MediaStreamSelector.cs) Additionally, this implementation specifically prefers text-based subtitles (assuming they match the user's preference) as they are the only ones natively supported by Roku. Also, the subtitle changing mechanism is reworked slightly to make use of the new implementation herein
Currently, when populating subtitleTracks, we assume that the ordering and list of populated subtitle tracks will not change when Roku moves the list into availableSubtitleTracks. This causes an issue with some videos as it is not always consistent. This patch modifies the logic to no-longer inject assumed final indices into our list of text-based subtitles, but instead search through the availableSubtitleTracks array and locate the actual subtitle that refers to the same URL as in our list. In this way we are guaranteed to always tell Roku to play the subtitle we want, no matter how re- ordered the options get. NOTE: The URL gets mildly mangled in the process of copying from subtitleTracks to availableSubtitleTracks, so we need so search via substring, rather than doing a full string comparison.
14451f0
to
7ee5411
Compare
@neilsb That mkv was very helpful in figuring this out (hopefully correctly this time 🙂). The issue I was having, it turns out, is that when Roku moves the subtitle listing from Additionally, I noticed another issue with the mkv you attached (which I could even reproduce on the current release). The problem is that when Roku copies the subtitle tracks, it ignores ones it cannot play (at least that is my assumption as to why). This results in the To ensure my new logic works, even in this case, in my 2nd patch, I updated the logic to now actually locate the correct subtitle in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, and seems to work in all the scenario's I've tested with. Thanks!
Changes
Logic for selecting a default subtitle track when starting playback is now added. This logic is based off of the existing logic in the base Jellyfin repo, with 2 minor modifications:
Rationale
Generally I use "OnlyForced" subtitle mode for my playback, since it is mildly annoying to watch a movie with some foreign language parts that don't get subtitles (Ex Elysium, which is partially in Spanish). This works well on other clients, but based on the source here, we are currently assuming no-subtitles is the correct default option, which does not match other clients (web, android app, etc).
This patchset attempts to rectify this issue by porting over the as much of the logic from the other clients as possible.
Additionally, the reason text-based subtitles are explicitly preferred here, when that is not necessarily the behavior elsewhere, is that watching a 4k rip with forced subtitles is not very doable when the server is attempting to transcode the whole thing. 😄