|
|
|
@ -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,11 +148,14 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|
|
|
|
|
|
|
|
|
var valueToSave = FFMpegPath;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(valueToSave))
|
|
|
|
|
{
|
|
|
|
|
// if using system variable, don't save this.
|
|
|
|
|
if (string.Equals(valueToSave, "ffmpeg", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
if (IsSystemInstalledPath(valueToSave))
|
|
|
|
|
{
|
|
|
|
|
valueToSave = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.Equals(valueToSave, appPath, StringComparison.Ordinal))
|
|
|
|
|
{
|
|
|
|
@ -128,7 +164,22 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task UpdateEncoderPath(string path)
|
|
|
|
|
public async Task UpdateEncoderPath(string path, string pathType)
|
|
|
|
|
{
|
|
|
|
|
if (_hasExternalEncoder)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Tuple<string, string> newPaths;
|
|
|
|
|
|
|
|
|
|
if (string.Equals(pathType, "system", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
path = "ffmpeg";
|
|
|
|
|
|
|
|
|
|
newPaths = TestForInstalledVersions();
|
|
|
|
|
}
|
|
|
|
|
else if (string.Equals(pathType, "custom", StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(path))
|
|
|
|
|
{
|
|
|
|
@ -139,8 +190,13 @@ namespace MediaBrowser.MediaEncoding.Encoder
|
|
|
|
|
{
|
|
|
|
|
throw new ResourceNotFoundException();
|
|
|
|
|
}
|
|
|
|
|
newPaths = GetEncoderPaths(path);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException("Unexpected pathType value");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var newPaths = GetEncoderPaths(path);
|
|
|
|
|
if (string.IsNullOrWhiteSpace(newPaths.Item1))
|
|
|
|
|
{
|
|
|
|
|
throw new ResourceNotFoundException("ffmpeg not found");
|
|
|
|
|