aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs')
-rw-r--r--MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs16
1 files changed, 12 insertions, 4 deletions
diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs
index 6284e0fd9..b76b52941 100644
--- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs
+++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs
@@ -731,6 +731,14 @@ namespace MediaBrowser.MediaEncoding.Subtitles
{
var charset = CharsetDetector.DetectFromStream(stream).Detected?.EncodingName;
+ // UTF16 is automatically converted to UTF8 by FFmpeg, do not specify a character encoding
+ if ((path.EndsWith(".ass") || path.EndsWith(".ssa"))
+ && (string.Equals(charset, "utf-16le", StringComparison.OrdinalIgnoreCase)
+ || string.Equals(charset, "utf-16be", StringComparison.OrdinalIgnoreCase)))
+ {
+ charset = "";
+ }
+
_logger.LogDebug("charset {0} detected for {Path}", charset ?? "null", path);
return charset;
@@ -753,10 +761,10 @@ namespace MediaBrowser.MediaEncoding.Subtitles
return _httpClient.Get(opts);
- case MediaProtocol.File:
- return Task.FromResult<Stream>(File.OpenRead(path));
- default:
- throw new ArgumentOutOfRangeException(nameof(protocol));
+ case MediaProtocol.File:
+ return Task.FromResult<Stream>(File.OpenRead(path));
+ default:
+ throw new ArgumentOutOfRangeException(nameof(protocol));
}
}
}