Don't re-encode subtitle: ass/ssa -> ass.
This fix Issue #630 : "ASS encoder supports only one ASS rectangle field".
This commit is contained in:
parent
d0485685de
commit
41f7e2ab19
|
@ -536,7 +536,11 @@ namespace MediaBrowser.Api.Playback
|
||||||
|
|
||||||
Directory.CreateDirectory(parentPath);
|
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);
|
Task.WaitAll(task);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,10 +41,11 @@ namespace MediaBrowser.Controller.MediaInfo
|
||||||
/// <param name="inputFiles">The input files.</param>
|
/// <param name="inputFiles">The input files.</param>
|
||||||
/// <param name="type">The type.</param>
|
/// <param name="type">The type.</param>
|
||||||
/// <param name="subtitleStreamIndex">Index of the subtitle stream.</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="outputPath">The output path.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task.</returns>
|
/// <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>
|
/// <summary>
|
||||||
/// Converts the text subtitle to ass.
|
/// Converts the text subtitle to ass.
|
||||||
|
|
|
@ -601,11 +601,12 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
|
||||||
/// <param name="inputFiles">The input files.</param>
|
/// <param name="inputFiles">The input files.</param>
|
||||||
/// <param name="type">The type.</param>
|
/// <param name="type">The type.</param>
|
||||||
/// <param name="subtitleStreamIndex">Index of the subtitle stream.</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="outputPath">The output path.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
/// <exception cref="System.ArgumentException">Must use inputPath list overload</exception>
|
/// <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);
|
var semaphore = GetLock(outputPath);
|
||||||
|
|
||||||
|
@ -615,7 +616,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
|
||||||
{
|
{
|
||||||
if (!File.Exists(outputPath))
|
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
|
finally
|
||||||
|
@ -629,6 +630,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="inputPath">The input path.</param>
|
/// <param name="inputPath">The input path.</param>
|
||||||
/// <param name="subtitleStreamIndex">Index of the subtitle stream.</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="outputPath">The output path.</param>
|
||||||
/// <param name="cancellationToken">The cancellation token.</param>
|
/// <param name="cancellationToken">The cancellation token.</param>
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
|
@ -638,7 +640,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
|
||||||
/// or
|
/// or
|
||||||
/// cancellationToken</exception>
|
/// cancellationToken</exception>
|
||||||
/// <exception cref="System.ApplicationException"></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))
|
if (string.IsNullOrEmpty(inputPath))
|
||||||
{
|
{
|
||||||
|
@ -650,6 +652,12 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
|
||||||
throw new ArgumentNullException("outputPath");
|
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
|
var process = new Process
|
||||||
{
|
{
|
||||||
|
@ -662,7 +670,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
|
||||||
RedirectStandardError = true,
|
RedirectStandardError = true,
|
||||||
|
|
||||||
FileName = FFMpegPath,
|
FileName = FFMpegPath,
|
||||||
Arguments = string.Format("-i {0} -map 0:{1} -an -vn -c:s ass \"{2}\"", inputPath, subtitleStreamIndex, outputPath),
|
Arguments = processArgs,
|
||||||
WindowStyle = ProcessWindowStyle.Hidden,
|
WindowStyle = ProcessWindowStyle.Hidden,
|
||||||
ErrorDialog = false
|
ErrorDialog = false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user