diff --git a/MediaBrowser.Api/ConfigurationService.cs b/MediaBrowser.Api/ConfigurationService.cs
index 9c8120de7d..2e5c252d63 100644
--- a/MediaBrowser.Api/ConfigurationService.cs
+++ b/MediaBrowser.Api/ConfigurationService.cs
@@ -79,6 +79,8 @@ namespace MediaBrowser.Api
{
[ApiMember(Name = "Path", Description = "Path", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
public string Path { get; set; }
+ [ApiMember(Name = "PathType", Description = "PathType", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
+ public string PathType { get; set; }
}
public class ConfigurationService : BaseApiService
@@ -110,7 +112,7 @@ namespace MediaBrowser.Api
public void Post(UpdateMediaEncoderPath request)
{
- var task = _mediaEncoder.UpdateEncoderPath(request.Path);
+ var task = _mediaEncoder.UpdateEncoderPath(request.Path, request.PathType);
Task.WaitAll(task);
}
diff --git a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs
index 77ba1685f5..12c893b0fc 100644
--- a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs
+++ b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs
@@ -13,6 +13,8 @@ namespace MediaBrowser.Controller.MediaEncoding
///
public interface IMediaEncoder : ITranscoderSupport
{
+ string EncoderLocationType { get; }
+
///
/// Gets the encoder path.
///
@@ -60,12 +62,12 @@ namespace MediaBrowser.Controller.MediaEncoding
/// The maximum width.
/// The cancellation token.
/// Task.
- Task ExtractVideoImagesOnInterval(string[] inputFiles,
- MediaProtocol protocol,
- Video3DFormat? threedFormat,
- TimeSpan interval,
- string targetDirectory,
- string filenamePrefix,
+ Task ExtractVideoImagesOnInterval(string[] inputFiles,
+ MediaProtocol protocol,
+ Video3DFormat? threedFormat,
+ TimeSpan interval,
+ string targetDirectory,
+ string filenamePrefix,
int? maxWidth,
CancellationToken cancellationToken);
@@ -131,6 +133,6 @@ namespace MediaBrowser.Controller.MediaEncoding
void Init();
- Task UpdateEncoderPath(string path);
+ Task UpdateEncoderPath(string path, string pathType);
}
}
diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
index 11291a05a5..5b9a2a6820 100644
--- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
+++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs
@@ -99,6 +99,39 @@ namespace MediaBrowser.MediaEncoding.Encoder
_hasExternalEncoder = hasExternalEncoder;
}
+ public string EncoderLocationType
+ {
+ get
+ {
+ if (_hasExternalEncoder)
+ {
+ return "External";
+ }
+
+ if (string.IsNullOrWhiteSpace(FFMpegPath))
+ {
+ return null;
+ }
+
+ if (IsSystemInstalledPath(FFMpegPath))
+ {
+ return "System";
+ }
+
+ return "Custom";
+ }
+ }
+
+ private bool IsSystemInstalledPath(string path)
+ {
+ if (path.IndexOf("/", StringComparison.Ordinal) == -1 && path.IndexOf("\\", StringComparison.Ordinal) == -1)
+ {
+ return true;
+ }
+
+ return false;
+ }
+
public void Init()
{
ConfigureEncoderPaths();
@@ -115,10 +148,13 @@ namespace MediaBrowser.MediaEncoding.Encoder
var valueToSave = FFMpegPath;
- // if using system variable, don't save this.
- if (string.Equals(valueToSave, "ffmpeg", StringComparison.OrdinalIgnoreCase))
+ if (!string.IsNullOrWhiteSpace(valueToSave))
{
- valueToSave = null;
+ // if using system variable, don't save this.
+ if (IsSystemInstalledPath(valueToSave))
+ {
+ valueToSave = null;
+ }
}
if (!string.Equals(valueToSave, appPath, StringComparison.Ordinal))
@@ -128,19 +164,39 @@ namespace MediaBrowser.MediaEncoding.Encoder
}
}
- public async Task UpdateEncoderPath(string path)
+ public async Task UpdateEncoderPath(string path, string pathType)
{
- if (string.IsNullOrWhiteSpace(path))
+ if (_hasExternalEncoder)
{
- throw new ArgumentNullException("path");
+ return;
}
- if (!File.Exists(path) && !Directory.Exists(path))
+ Tuple newPaths;
+
+ if (string.Equals(pathType, "system", StringComparison.OrdinalIgnoreCase))
+ {
+ path = "ffmpeg";
+
+ newPaths = TestForInstalledVersions();
+ }
+ else if (string.Equals(pathType, "custom", StringComparison.OrdinalIgnoreCase))
+ {
+ if (string.IsNullOrWhiteSpace(path))
+ {
+ throw new ArgumentNullException("path");
+ }
+
+ if (!File.Exists(path) && !Directory.Exists(path))
+ {
+ throw new ResourceNotFoundException();
+ }
+ newPaths = GetEncoderPaths(path);
+ }
+ else
{
- throw new ResourceNotFoundException();
+ throw new ArgumentException("Unexpected pathType value");
}
- var newPaths = GetEncoderPaths(path);
if (string.IsNullOrWhiteSpace(newPaths.Item1))
{
throw new ResourceNotFoundException("ffmpeg not found");
@@ -252,7 +308,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
}
}
- private Tuple GetPathsFromDirectory(string path)
+ private Tuple GetPathsFromDirectory(string path)
{
// Since we can't predict the file extension, first try directly within the folder
// If that doesn't pan out, then do a recursive search
diff --git a/MediaBrowser.Model/System/SystemInfo.cs b/MediaBrowser.Model/System/SystemInfo.cs
index 868d9dc282..3d1de5b379 100644
--- a/MediaBrowser.Model/System/SystemInfo.cs
+++ b/MediaBrowser.Model/System/SystemInfo.cs
@@ -152,7 +152,7 @@ namespace MediaBrowser.Model.System
/// true if [supports automatic run at startup]; otherwise, false.
public bool SupportsAutoRunAtStartup { get; set; }
- public bool HasExternalEncoder { get; set; }
+ public string EncoderLocationType { get; set; }
public Architecture SystemArchitecture { get; set; }
diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
index ec1ccbff57..1d7b65e5f1 100644
--- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
+++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs
@@ -658,13 +658,13 @@ namespace MediaBrowser.Server.Startup.Common
encoderPath = info.EncoderPath;
probePath = info.ProbePath;
- _hasExternalEncoder = string.Equals(info.Version, "external", StringComparison.OrdinalIgnoreCase);
+ var hasExternalEncoder = string.Equals(info.Version, "external", StringComparison.OrdinalIgnoreCase);
var mediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"),
JsonSerializer,
encoderPath,
probePath,
- _hasExternalEncoder,
+ hasExternalEncoder,
ServerConfigurationManager,
FileSystemManager,
LiveTvManager,
@@ -1100,7 +1100,6 @@ namespace MediaBrowser.Server.Startup.Common
}
}
- private bool _hasExternalEncoder;
///
/// Gets the system status.
///
@@ -1141,7 +1140,7 @@ namespace MediaBrowser.Server.Startup.Common
ServerName = FriendlyName,
LocalAddress = localAddress,
SupportsLibraryMonitor = SupportsLibraryMonitor,
- HasExternalEncoder = _hasExternalEncoder,
+ EncoderLocationType = MediaEncoder.EncoderLocationType,
SystemArchitecture = NativeApp.Environment.SystemArchitecture
};
}