|
|
@ -183,7 +183,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return File.OpenRead(path);
|
|
|
|
return _fileSystem.OpenRead(path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Encoding GetEncoding(string charset)
|
|
|
|
private Encoding GetEncoding(string charset)
|
|
|
@ -346,7 +346,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!File.Exists(outputPath))
|
|
|
|
if (!_fileSystem.FileExists(outputPath))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await ConvertTextSubtitleToSrtInternal(inputPath, inputProtocol, outputPath, cancellationToken).ConfigureAwait(false);
|
|
|
|
await ConvertTextSubtitleToSrtInternal(inputPath, inputProtocol, outputPath, cancellationToken).ConfigureAwait(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -383,7 +383,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|
|
|
throw new ArgumentNullException("outputPath");
|
|
|
|
throw new ArgumentNullException("outputPath");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
|
|
|
|
_fileSystem.CreateDirectory(Path.GetDirectoryName(outputPath));
|
|
|
|
|
|
|
|
|
|
|
|
var encodingParam = await GetSubtitleFileCharacterSet(inputPath, inputProtocol, cancellationToken).ConfigureAwait(false);
|
|
|
|
var encodingParam = await GetSubtitleFileCharacterSet(inputPath, inputProtocol, cancellationToken).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
|
@ -413,7 +413,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|
|
|
_logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
|
|
|
|
_logger.Debug("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
|
|
|
|
|
|
|
|
|
|
|
|
var logFilePath = Path.Combine(_appPaths.LogDirectoryPath, "ffmpeg-sub-convert-" + Guid.NewGuid() + ".txt");
|
|
|
|
var logFilePath = Path.Combine(_appPaths.LogDirectoryPath, "ffmpeg-sub-convert-" + Guid.NewGuid() + ".txt");
|
|
|
|
Directory.CreateDirectory(Path.GetDirectoryName(logFilePath));
|
|
|
|
_fileSystem.CreateDirectory(Path.GetDirectoryName(logFilePath));
|
|
|
|
|
|
|
|
|
|
|
|
var logFileStream = _fileSystem.GetFileStream(logFilePath, FileMode.Create, FileAccess.Write, FileShare.Read,
|
|
|
|
var logFileStream = _fileSystem.GetFileStream(logFilePath, FileMode.Create, FileAccess.Write, FileShare.Read,
|
|
|
|
true);
|
|
|
|
true);
|
|
|
@ -466,7 +466,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|
|
|
{
|
|
|
|
{
|
|
|
|
failed = true;
|
|
|
|
failed = true;
|
|
|
|
|
|
|
|
|
|
|
|
if (File.Exists(outputPath))
|
|
|
|
if (_fileSystem.FileExists(outputPath))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -479,7 +479,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!File.Exists(outputPath))
|
|
|
|
else if (!_fileSystem.FileExists(outputPath))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
failed = true;
|
|
|
|
failed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -515,7 +515,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!File.Exists(outputPath))
|
|
|
|
if (!_fileSystem.FileExists(outputPath))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
await ExtractTextSubtitleInternal(_mediaEncoder.GetInputArgument(inputFiles, protocol), subtitleStreamIndex,
|
|
|
|
await ExtractTextSubtitleInternal(_mediaEncoder.GetInputArgument(inputFiles, protocol), subtitleStreamIndex,
|
|
|
|
outputCodec, outputPath, cancellationToken).ConfigureAwait(false);
|
|
|
|
outputCodec, outputPath, cancellationToken).ConfigureAwait(false);
|
|
|
@ -540,7 +540,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|
|
|
throw new ArgumentNullException("outputPath");
|
|
|
|
throw new ArgumentNullException("outputPath");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
|
|
|
|
_fileSystem.CreateDirectory(Path.GetDirectoryName(outputPath));
|
|
|
|
|
|
|
|
|
|
|
|
var processArgs = string.Format("-i {0} -map 0:{1} -an -vn -c:s {2} \"{3}\"", inputPath,
|
|
|
|
var processArgs = string.Format("-i {0} -map 0:{1} -an -vn -c:s {2} \"{3}\"", inputPath,
|
|
|
|
subtitleStreamIndex, outputCodec, outputPath);
|
|
|
|
subtitleStreamIndex, outputCodec, outputPath);
|
|
|
@ -566,7 +566,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|
|
|
_logger.Info("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
|
|
|
|
_logger.Info("{0} {1}", process.StartInfo.FileName, process.StartInfo.Arguments);
|
|
|
|
|
|
|
|
|
|
|
|
var logFilePath = Path.Combine(_appPaths.LogDirectoryPath, "ffmpeg-sub-extract-" + Guid.NewGuid() + ".txt");
|
|
|
|
var logFilePath = Path.Combine(_appPaths.LogDirectoryPath, "ffmpeg-sub-extract-" + Guid.NewGuid() + ".txt");
|
|
|
|
Directory.CreateDirectory(Path.GetDirectoryName(logFilePath));
|
|
|
|
_fileSystem.CreateDirectory(Path.GetDirectoryName(logFilePath));
|
|
|
|
|
|
|
|
|
|
|
|
var logFileStream = _fileSystem.GetFileStream(logFilePath, FileMode.Create, FileAccess.Write, FileShare.Read,
|
|
|
|
var logFileStream = _fileSystem.GetFileStream(logFilePath, FileMode.Create, FileAccess.Write, FileShare.Read,
|
|
|
|
true);
|
|
|
|
true);
|
|
|
@ -635,7 +635,7 @@ namespace MediaBrowser.MediaEncoding.Subtitles
|
|
|
|
_logger.ErrorException("Error deleting extracted subtitle {0}", ex, outputPath);
|
|
|
|
_logger.ErrorException("Error deleting extracted subtitle {0}", ex, outputPath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!File.Exists(outputPath))
|
|
|
|
else if (!_fileSystem.FileExists(outputPath))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
failed = true;
|
|
|
|
failed = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|