Skip to content

Commit

Permalink
Merge pull request jellyfin#12627 from oxixes/burn-subtitle-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
crobibero authored Sep 11, 2024
2 parents 81aca67 + dd462f8 commit e6ceab4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
- [TheMelmacian](https://github.com/TheMelmacian)
- [ItsAllAboutTheCode](https://github.com/ItsAllAboutTheCode)
- [pret0rian8](https://github.com/pret0rian)
- [jaina heartles](https://github.com/heartles)
- [oxixes](https://github.com/oxixes)

# Emby Contributors

Expand Down
10 changes: 6 additions & 4 deletions MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1652,13 +1652,15 @@ public string GetTextSubtitlesFilter(EncodingJobInfo state, bool enableAlpha, bo
setPtsParam);
}

var mediaPath = state.MediaPath ?? string.Empty;
var subtitlePath = _subtitleEncoder.GetSubtitleFilePath(
state.SubtitleStream,
state.MediaSource,
CancellationToken.None).GetAwaiter().GetResult();

return string.Format(
CultureInfo.InvariantCulture,
"subtitles=f='{0}':si={1}{2}{3}{4}{5}",
_mediaEncoder.EscapeSubtitleFilterPath(mediaPath),
state.InternalSubtitleStreamOffset.ToString(CultureInfo.InvariantCulture),
"subtitles=f='{0}'{1}{2}{3}{4}",
_mediaEncoder.EscapeSubtitleFilterPath(subtitlePath),
alphaParam,
sub2videoParam,
fontParam,
Expand Down
9 changes: 9 additions & 0 deletions MediaBrowser.Controller/MediaEncoding/ISubtitleEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,14 @@ Task<Stream> GetSubtitles(
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>System.String.</returns>
Task<string> GetSubtitleFileCharacterSet(MediaStream subtitleStream, string language, MediaSourceInfo mediaSource, CancellationToken cancellationToken);

/// <summary>
/// Gets the path to a subtitle file.
/// </summary>
/// <param name="subtitleStream">The subtitle stream.</param>
/// <param name="mediaSource">The media source.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>System.String.</returns>
Task<string> GetSubtitleFilePath(MediaStream subtitleStream, MediaSourceInfo mediaSource, CancellationToken cancellationToken);
}
}
7 changes: 7 additions & 0 deletions MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,13 @@ private async Task<Stream> GetStream(string path, MediaProtocol protocol, Cancel
}
}

public async Task<string> GetSubtitleFilePath(MediaStream subtitleStream, MediaSourceInfo mediaSource, CancellationToken cancellationToken)
{
var info = await GetReadableFile(mediaSource, subtitleStream, cancellationToken)
.ConfigureAwait(false);
return info.Path;
}

/// <inheritdoc />
public void Dispose()
{
Expand Down

0 comments on commit e6ceab4

Please sign in to comment.