aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-08-24 17:07:04 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-08-24 17:07:04 -0400
commitd92936187d2e0a4391dbca6ea182bdb180c3dece (patch)
tree44c526ad8b88edc6729ec06636d9373381c25f90
parent58a38d0d1ddb89439b763e7bc50e8b84105f68fe (diff)
Extract subs to srt instead of ass
-rw-r--r--MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs32
1 files changed, 18 insertions, 14 deletions
diff --git a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs
index 1e839c5a3..df22b5e1f 100644
--- a/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs
+++ b/MediaBrowser.MediaEncoding/Subtitles/SubtitleEncoder.cs
@@ -194,15 +194,17 @@ namespace MediaBrowser.MediaEncoding.Subtitles
MediaStream subtitleStream,
CancellationToken cancellationToken)
{
+ const string extractedFormat = "srt";
+
if (!subtitleStream.IsExternal)
{
// Extract
- var outputPath = GetSubtitleCachePath(mediaPath, subtitleStream.Index, ".ass");
+ var outputPath = GetSubtitleCachePath(mediaPath, subtitleStream.Index, "." + extractedFormat);
await ExtractTextSubtitle(inputFiles, protocol, subtitleStream.Index, false, outputPath, cancellationToken)
.ConfigureAwait(false);
- return new Tuple<string, string>(outputPath, "ass");
+ return new Tuple<string, string>(outputPath, extractedFormat);
}
var currentFormat = (Path.GetExtension(subtitleStream.Path) ?? subtitleStream.Codec)
@@ -211,12 +213,12 @@ namespace MediaBrowser.MediaEncoding.Subtitles
if (GetReader(currentFormat, false) == null)
{
// Convert
- var outputPath = GetSubtitleCachePath(mediaPath, subtitleStream.Index, ".ass");
+ var outputPath = GetSubtitleCachePath(mediaPath, subtitleStream.Index, "." + extractedFormat);
- await ConvertTextSubtitleToAss(subtitleStream.Path, outputPath, subtitleStream.Language, cancellationToken)
+ await ConvertTextSubtitleToSrt(subtitleStream.Path, outputPath, subtitleStream.Language, cancellationToken)
.ConfigureAwait(false);
- return new Tuple<string, string>(outputPath, "ass");
+ return new Tuple<string, string>(outputPath, extractedFormat);
}
return new Tuple<string, string>(subtitleStream.Path, currentFormat);
@@ -303,14 +305,14 @@ namespace MediaBrowser.MediaEncoding.Subtitles
}
/// <summary>
- /// Converts the text subtitle to ass.
+ /// Converts the text subtitle to SRT.
/// </summary>
/// <param name="inputPath">The input path.</param>
/// <param name="outputPath">The output path.</param>
/// <param name="language">The language.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
- public async Task ConvertTextSubtitleToAss(string inputPath, string outputPath, string language,
+ public async Task ConvertTextSubtitleToSrt(string inputPath, string outputPath, string language,
CancellationToken cancellationToken)
{
var semaphore = GetLock(outputPath);
@@ -321,7 +323,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
{
if (!File.Exists(outputPath))
{
- await ConvertTextSubtitleToAssInternal(inputPath, outputPath, language).ConfigureAwait(false);
+ await ConvertTextSubtitleToSrtInternal(inputPath, outputPath, language).ConfigureAwait(false);
}
}
finally
@@ -331,17 +333,19 @@ namespace MediaBrowser.MediaEncoding.Subtitles
}
/// <summary>
- /// Converts the text subtitle to ass.
+ /// Converts the text subtitle to SRT internal.
/// </summary>
/// <param name="inputPath">The input path.</param>
/// <param name="outputPath">The output path.</param>
/// <param name="language">The language.</param>
/// <returns>Task.</returns>
- /// <exception cref="System.ArgumentNullException">inputPath
+ /// <exception cref="System.ArgumentNullException">
+ /// inputPath
/// or
- /// outputPath</exception>
+ /// outputPath
+ /// </exception>
/// <exception cref="System.ApplicationException"></exception>
- private async Task ConvertTextSubtitleToAssInternal(string inputPath, string outputPath, string language)
+ private async Task ConvertTextSubtitleToSrtInternal(string inputPath, string outputPath, string language)
{
if (string.IsNullOrEmpty(inputPath))
{
@@ -375,7 +379,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
CreateNoWindow = true,
UseShellExecute = false,
FileName = _mediaEncoder.EncoderPath,
- Arguments = string.Format("{0} -i \"{1}\" -c:s ass \"{2}\"", encodingParam, inputPath, outputPath),
+ Arguments = string.Format("{0} -i \"{1}\" -c:s srt \"{2}\"", encodingParam, inputPath, outputPath),
WindowStyle = ProcessWindowStyle.Hidden,
ErrorDialog = false
@@ -529,7 +533,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
- var processArgs = string.Format("-i {0} -map 0:{1} -an -vn -c:s ass \"{2}\"", inputPath,
+ var processArgs = string.Format("-i {0} -map 0:{1} -an -vn -c:s srt \"{2}\"", inputPath,
subtitleStreamIndex, outputPath);
if (copySubtitleStream)