Skip to content
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

[iOS] Fix #1256 #1311

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

[iOS] Fix #1256 #1311

wants to merge 2 commits into from

Conversation

Gondnat
Copy link

@Gondnat Gondnat commented Nov 11, 2024

This PR is used to fix "Can't select subtitles, it jumps back to none #1256"

There are two parts to fix it:

  1. The SubtitleProfile in request should be as below, the old profile will get broken DeliveryUrl for external subtitles.
{Format: "vtt", Method: "External"}

The broken URL lost the extension name ".vtt" after Stream.

Borken URL

"DeliveryUrl": "/Videos/7c4730fd-90f1-e75e-656c-fe7da8fb22aa/7c4730fd90f1e75e656cfe7da8fb22aa/Subtitles/0/0/Stream?api_key=953dccded7e2455ba0088f62cf322dfc",

Normal URL

"DeliveryUrl": "/Videos/7c4730fd-90f1-e75e-656c-fe7da8fb22aa/7c4730fd90f1e75e656cfe7da8fb22aa/Subtitles/0/0/Stream.vtt?api_key=953dccded7e2455ba0088f62cf322dfc",
  1. To make embedded subtitles work well, they should reduce as same as embedded audio in function adjustAudioForExternalSubtitles

@LePips
Copy link
Member

LePips commented Nov 21, 2024

Apologies for the long wait, I know this is a somewhat simple fix but so was #1219 and that didn't entirely fix the issue. There are a few edge cases for me to consider, mainly with transcoded streams + external subtitles, that I remember being wacky that may contribute to this issue that I will need to test with.

@JPKribs JPKribs added the bug Something isn't working label Nov 24, 2024
@JPKribs
Copy link
Member

JPKribs commented Dec 19, 2024

Hey all! I just had a chance to test this and unfortunately this does not appear to fully resolve the issue. On DirectPlay, external subtitles work correctly. When transcoding, this the issue is still persistent for external subtitles.

@JPKribs
Copy link
Member

JPKribs commented Dec 20, 2024

I've been screwing around with this for a bit. Does Jellyfin/Swiftfin downsample audio? I think our Transcode Subtitle Index is getting thrown off because the audio index is unreliable. It looks like the Audio selection also gets screwed up by being transcoded but it seems to be more likely to get screwed up with multiple audio/subtitle sources.

From testing, this PR seems to work very consistently with non-transcoded content. IMO, maybe we pas in the StreamType as a parameter then have this run for DirectPlay. Figuring out transcoded should still be part of the solution but this would be my take on this:

func adjustExternalSubtitleIndexes(streamType: StreamType, audioStreamCount: Int) -> [MediaStream] {
    guard allSatisfy({ $0.type == .subtitle }) else { return self }
    
    let embeddedSubtitleCount = filter { !($0.isExternal ?? false) }.count
    let externalSubtitleCount = filter { $0.isExternal ?? false }.count
    
    var mediaStreams = self
    
    switch streamType {
    case .direct:
        for (index, mediaStream) in mediaStreams.enumerated() {
            var updatedStream = mediaStream
            if updatedStream.isExternal ?? false {
                updatedStream.index = (updatedStream.index ?? 0) + 1 + embeddedSubtitleCount + audioStreamCount
            } else {
                updatedStream.index = (updatedStream.index ?? 0) + externalSubtitleCount
            }
            mediaStreams[index] = updatedStream
        }
    case .hls:
            *Whatever we need to do to get this to work for HLS?*
    case .transcode:
            *Whatever we need to do to get this to work for transcodes?*
    }
    return mediaStreams
}

As an FYI, for testing you can force transcoding by going to Settings > Playback Quality and either set Device Profile to Most Compatible if your content isn't already H.264 & AAC or you can lower the Maximum Bitrate to something under the bitrate of the original file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants