aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-06-03 22:02:49 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-06-03 22:02:49 -0400
commit02fedead11f738c09e503c3bdc74e2dd98e21cc8 (patch)
tree5e32fb80c23fa910dbdd0cc6a8be6bf105abd631 /MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs
parent08d9004d8f361aaf13756cab70fc659e5fbb775c (diff)
re-factored some file system access
Diffstat (limited to 'MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs')
-rw-r--r--MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs39
1 files changed, 15 insertions, 24 deletions
diff --git a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs
index ce39ffc06..fbb5a2010 100644
--- a/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs
+++ b/MediaBrowser.Server.Implementations/MediaEncoder/MediaEncoder.cs
@@ -94,29 +94,20 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
}
/// <summary>
- /// The _media tools path
+ /// Gets the media tools path.
/// </summary>
- private string _mediaToolsPath;
- /// <summary>
- /// Gets the folder path to tools
- /// </summary>
- /// <value>The media tools path.</value>
- private string MediaToolsPath
+ /// <param name="create">if set to <c>true</c> [create].</param>
+ /// <returns>System.String.</returns>
+ private string GetMediaToolsPath(bool create)
{
- get
- {
- if (_mediaToolsPath == null)
- {
- _mediaToolsPath = Path.Combine(_appPaths.ProgramDataPath, "ffmpeg");
-
- if (!Directory.Exists(_mediaToolsPath))
- {
- Directory.CreateDirectory(_mediaToolsPath);
- }
- }
+ var path = Path.Combine(_appPaths.ProgramDataPath, "ffmpeg");
- return _mediaToolsPath;
+ if (create && !Directory.Exists(path))
+ {
+ Directory.CreateDirectory(path);
}
+
+ return path;
}
/// <summary>
@@ -185,7 +176,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
var filename = resource.Substring(resource.IndexOf(prefix, StringComparison.OrdinalIgnoreCase) + prefix.Length);
- var versionedDirectoryPath = Path.Combine(MediaToolsPath, Path.GetFileNameWithoutExtension(filename));
+ var versionedDirectoryPath = Path.Combine(GetMediaToolsPath(true), Path.GetFileNameWithoutExtension(filename));
if (!Directory.Exists(versionedDirectoryPath))
{
@@ -570,14 +561,14 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
}
var offsetParam = offset.Ticks > 0 ? "-ss " + offset.TotalSeconds + " " : string.Empty;
-
+
var process = new Process
{
StartInfo = new ProcessStartInfo
{
RedirectStandardOutput = false,
RedirectStandardError = true,
-
+
CreateNoWindow = true,
UseShellExecute = false,
FileName = FFMpegPath,
@@ -744,7 +735,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
RedirectStandardOutput = false,
RedirectStandardError = true,
-
+
FileName = FFMpegPath,
Arguments = string.Format("{0}-i {1} -map 0:{2} -an -vn -c:s ass \"{3}\"", offsetParam, inputPath, subtitleStreamIndex, outputPath),
WindowStyle = ProcessWindowStyle.Hidden,
@@ -759,7 +750,7 @@ namespace MediaBrowser.Server.Implementations.MediaEncoder
var logFilePath = Path.Combine(_appPaths.LogDirectoryPath, "ffmpeg-sub-extract-" + Guid.NewGuid() + ".txt");
var logFileStream = new FileStream(logFilePath, FileMode.Create, FileAccess.Write, FileShare.Read, StreamDefaults.DefaultFileStreamBufferSize, FileOptions.Asynchronous);
-
+
try
{
process.Start();