diff options
6 files changed, 44 insertions, 7 deletions
diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 76cce0d66..67f06c792 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -536,7 +536,11 @@ namespace MediaBrowser.Api.Playback Directory.CreateDirectory(parentPath); - var task = MediaEncoder.ExtractTextSubtitle(inputPath, type, state.SubtitleStream.Index, path, CancellationToken.None); + // Don't re-encode ass/ssa to ass because ffmpeg ass encoder fails if there's more than one ass rectangle. Affect Anime mostly. + // See https://lists.ffmpeg.org/pipermail/ffmpeg-cvslog/2013-April/063616.html + bool isAssSubtitle = string.Equals(state.SubtitleStream.Codec, "ass", StringComparison.OrdinalIgnoreCase) || string.Equals(state.SubtitleStream.Codec, "ssa", StringComparison.OrdinalIgnoreCase); + + var task = MediaEncoder.ExtractTextSubtitle(inputPath, type, state.SubtitleStream.Index, isAssSubtitle, path, CancellationToken.None); Task.WaitAll(task); } diff --git a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs index 952592c93..506774b4a 100644 --- a/MediaBrowser.Common.Implementations/BaseApplicationHost.cs +++ b/MediaBrowser.Common.Implementations/BaseApplicationHost.cs @@ -166,6 +166,12 @@ namespace MediaBrowser.Common.Implementations protected IIsoManager IsoManager { get; private set; } /// <summary> + /// Gets the name. + /// </summary> + /// <value>The name.</value> + public abstract string Name { get; } + + /// <summary> /// Initializes a new instance of the <see cref="BaseApplicationHost{TApplicationPathsType}"/> class. /// </summary> protected BaseApplicationHost(TApplicationPathsType applicationPaths, ILogManager logManager) diff --git a/MediaBrowser.Common/IApplicationHost.cs b/MediaBrowser.Common/IApplicationHost.cs index 1c7ffe424..8cd1252c7 100644 --- a/MediaBrowser.Common/IApplicationHost.cs +++ b/MediaBrowser.Common/IApplicationHost.cs @@ -14,6 +14,12 @@ namespace MediaBrowser.Common public interface IApplicationHost { /// <summary> + /// Gets the name. + /// </summary> + /// <value>The name.</value> + string Name { get; } + + /// <summary> /// Occurs when [application updated]. /// </summary> event EventHandler<GenericEventArgs<Version>> ApplicationUpdated; diff --git a/MediaBrowser.Controller/MediaInfo/IMediaEncoder.cs b/MediaBrowser.Controller/MediaInfo/IMediaEncoder.cs index 0564c0613..86b508012 100644 --- a/MediaBrowser.Controller/MediaInfo/IMediaEncoder.cs +++ b/MediaBrowser.Controller/MediaInfo/IMediaEncoder.cs @@ -41,10 +41,11 @@ namespace MediaBrowser.Controller.MediaInfo /// <param name="inputFiles">The input files.</param> /// <param name="type">The type.</param> /// <param name="subtitleStreamIndex">Index of the subtitle stream.</param> + /// <param name="copySubtitleStream">if set to true, copy stream instead of converting.</param> /// <param name="outputPath">The output path.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task.</returns> - Task ExtractTextSubtitle(string[] inputFiles, InputType type, int subtitleStreamIndex, string outputPath, CancellationToken cancellationToken); + Task ExtractTextSubtitle(string[] inputFiles, InputType type, int subtitleStreamIndex, bool copySubtitleStream, string outputPath, CancellationToken cancellationToken); /// <summary> /// Converts the text subtitle to ass. diff --git a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs index e435b1644..fddcbe53e 100644 --- a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs +++ b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs @@ -601,11 +601,12 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder /// <param name="inputFiles">The input files.</param> /// <param name="type">The type.</param> /// <param name="subtitleStreamIndex">Index of the subtitle stream.</param> + /// <param name="copySubtitleStream">if set to true, copy stream instead of converting.</param> /// <param name="outputPath">The output path.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task.</returns> /// <exception cref="System.ArgumentException">Must use inputPath list overload</exception> - public async Task ExtractTextSubtitle(string[] inputFiles, InputType type, int subtitleStreamIndex, string outputPath, CancellationToken cancellationToken) + public async Task ExtractTextSubtitle(string[] inputFiles, InputType type, int subtitleStreamIndex, bool copySubtitleStream, string outputPath, CancellationToken cancellationToken) { var semaphore = GetLock(outputPath); @@ -615,7 +616,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder { if (!File.Exists(outputPath)) { - await ExtractTextSubtitleInternal(GetInputArgument(inputFiles, type), subtitleStreamIndex, outputPath, cancellationToken).ConfigureAwait(false); + await ExtractTextSubtitleInternal(GetInputArgument(inputFiles, type), subtitleStreamIndex, copySubtitleStream, outputPath, cancellationToken).ConfigureAwait(false); } } finally @@ -629,6 +630,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder /// </summary> /// <param name="inputPath">The input path.</param> /// <param name="subtitleStreamIndex">Index of the subtitle stream.</param> + /// <param name="copySubtitleStream">if set to true, copy stream instead of converting.</param> /// <param name="outputPath">The output path.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task.</returns> @@ -638,7 +640,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder /// or /// cancellationToken</exception> /// <exception cref="System.ApplicationException"></exception> - private async Task ExtractTextSubtitleInternal(string inputPath, int subtitleStreamIndex, string outputPath, CancellationToken cancellationToken) + private async Task ExtractTextSubtitleInternal(string inputPath, int subtitleStreamIndex, bool copySubtitleStream, string outputPath, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(inputPath)) { @@ -650,6 +652,12 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder throw new ArgumentNullException("outputPath"); } + string processArgs = string.Format("-i {0} -map 0:{1} -an -vn -c:s ass \"{2}\"", inputPath, subtitleStreamIndex, outputPath); + + if (copySubtitleStream) + { + processArgs = string.Format("-i {0} -map 0:{1} -an -vn -c:s copy \"{2}\"", inputPath, subtitleStreamIndex, outputPath); + } var process = new Process { @@ -662,7 +670,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder RedirectStandardError = true, FileName = FFMpegPath, - Arguments = string.Format("-i {0} -map 0:{1} -an -vn -c:s ass \"{2}\"", inputPath, subtitleStreamIndex, outputPath), + Arguments = processArgs, WindowStyle = ProcessWindowStyle.Hidden, ErrorDialog = false } diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index 045c9f18c..b78a0f36d 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -186,6 +186,18 @@ namespace MediaBrowser.ServerApplication } /// <summary> + /// Gets the name. + /// </summary> + /// <value>The name.</value> + public override string Name + { + get + { + return "Media Browser Server"; + } + } + + /// <summary> /// Gets a value indicating whether this instance can self restart. /// </summary> /// <value><c>true</c> if this instance can self restart; otherwise, <c>false</c>.</value> @@ -732,7 +744,7 @@ namespace MediaBrowser.ServerApplication { ServerAuthorization.AuthorizeServer( ServerConfigurationManager.Configuration.HttpServerPortNumber, - HttpServerUrlPrefixes.First(), + HttpServerUrlPrefixes.First(), ServerConfigurationManager.Configuration.LegacyWebSocketPortNumber, UdpServerEntryPoint.PortNumber, ConfigurationManager.CommonApplicationPaths.TempDirectory); |
