Jump to content

Playing plaintext subtitles through Subtitles Octopus


Recommended Posts

Posted

I mentioned this somewhere else I think, then did it and never really had the time to post about it since, but here it is now.

I find the contrast solutions (such as the drop shadow) for how non-canvas subtitles are displayed in the htmlvideoplayer to be inadequate; there are always backgrounds, sooner or later, against which the subtitles contrast poorly and are difficult to read. I thought it would be ideal if you could funnel plaintext subtitles through octopus (which is already used for rendering .ass subtitles) so they can be rendered with a nice proper outline. I don't mind the additional performance cost on mine (or my friends') client devices.

Upon investigation, I found out that if you change the extension of Emby's subtitle delivery endpoint to .ass, Emby will send them to you in .ass format, even if they are originally plaintext subtitles. Awesome!

The easiest spot I found for patching this into the client was in modules/common/playback/playbackmanager.js in the getTextTracks function:

    .filter(function(s) {
            return "External" === s.DeliveryMethod || "Hls" === s.DeliveryMethod
    }), tracks = [], i = 0, length = textStreams.length; i < length; i++) {
        var textStream = textStreams[i],
        textStreamUrl = void 0,
        ...

    Becomes:

    ...
    .filter(function(s) {
        return "External" === s.DeliveryMethod || "Hls" === s.DeliveryMethod
    }), tracks = [], i = 0, length = textStreams.length; i < length; i++) {
        var textStream = textStreams[i];
    
        if (textStream.DeliveryMethod === "Hls" && textStream.Codec === "subrip") {
            textStream.DeliveryMethod = "External";
            textStream.Codec = "ass";
            textStream.DeliveryUrl = `/Videos/${mediaSource.ItemId}/${mediaSource.Id}/Subtitles/${textStream.Index}/0/Stream.ass`;
        }
    
        var textStreamUrl = void 0,
        ...

Essentially we're just overriding the delivery method for these subtitles to use the endpoint with the .ass termination. Works like a charm (so far).

Now, as a feature request for future versions, I'd love to have a toggle in the subtitle settings to make the client use this method instead of the default one. It would also be great if some of the subtitle settings could be passed to the endpoint below so they are incorporated in the resulting .ass file: The text color, default subtitle position and size.

  • Thanks 1
Posted

HI, thanks for sharing.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...