The Free Software Media System - Server Backend & API
update ffmpeg path customization
Luke Pulverentifb07b4640c60
diff --git a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.csindex 023af7d1ad..c00f76f22c 100644--- a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs+++ b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs@@ -19,12 +19,6 @@ namespace MediaBrowser.Controller.MediaEncoding/// <value>The encoder path.</value>string EncoderPath { get; }- /// <summary>- /// Gets the version.- /// </summary>- /// <value>The version.</value>- string Version { get; }-/// <summary>/// Supportses the decoder./// </summary>diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.csindex 61986e3bc0..fc627c232a 100644--- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs+++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs@@ -66,8 +66,6 @@ namespace MediaBrowser.MediaEncoding.Encoderpublic string FFProbePath { get; private set; }- public string Version { get; private set; }-protected readonly IServerConfigurationManager ConfigurationManager;protected readonly IFileSystem FileSystem;protected readonly ILiveTvManager LiveTvManager;@@ -81,11 +79,10 @@ namespace MediaBrowser.MediaEncoding.Encoderprivate readonly List<ProcessWrapper> _runningProcesses = new List<ProcessWrapper>();private readonly bool _hasExternalEncoder;- public MediaEncoder(ILogger logger, IJsonSerializer jsonSerializer, string ffMpegPath, string ffProbePath, string version, IServerConfigurationManager configurationManager, IFileSystem fileSystem, ILiveTvManager liveTvManager, IIsoManager isoManager, ILibraryManager libraryManager, IChannelManager channelManager, ISessionManager sessionManager, Func<ISubtitleEncoder> subtitleEncoder, Func<IMediaSourceManager> mediaSourceManager)+ public MediaEncoder(ILogger logger, IJsonSerializer jsonSerializer, string ffMpegPath, string ffProbePath, bool hasExternalEncoder, IServerConfigurationManager configurationManager, IFileSystem fileSystem, ILiveTvManager liveTvManager, IIsoManager isoManager, ILibraryManager libraryManager, IChannelManager channelManager, ISessionManager sessionManager, Func<ISubtitleEncoder> subtitleEncoder, Func<IMediaSourceManager> mediaSourceManager){_logger = logger;_jsonSerializer = jsonSerializer;- Version = version;ConfigurationManager = configurationManager;FileSystem = fileSystem;LiveTvManager = liveTvManager;@@ -98,34 +95,51 @@ namespace MediaBrowser.MediaEncoding.EncoderFFProbePath = ffProbePath;FFMpegPath = ffMpegPath;- _hasExternalEncoder = !string.IsNullOrWhiteSpace(ffMpegPath);+ _hasExternalEncoder = hasExternalEncoder;}public void Init(){ConfigureEncoderPaths();++ if (_hasExternalEncoder)+ {+ LogPaths();+ return;+ }++ // If the path was passed in, save it into config now.+ var encodingOptions = GetEncodingOptions();+ var appPath = encodingOptions.EncoderAppPath;+ if (!string.IsNullOrWhiteSpace(FFMpegPath) && !string.Equals(FFMpegPath, appPath, StringComparison.Ordinal))+ {+ encodingOptions.EncoderAppPath = FFMpegPath;+ ConfigurationManager.SaveConfiguration("encoding", encodingOptions);+ }}private void ConfigureEncoderPaths(){if (_hasExternalEncoder){- LogPaths();return;}var appPath = GetEncodingOptions().EncoderAppPath;- if (Directory.Exists(appPath))+ if (!string.IsNullOrWhiteSpace(appPath)){- SetPathsFromDirectory(appPath);- }+ if (Directory.Exists(appPath))+ {+ SetPathsFromDirectory(appPath);+ }- else if (File.Exists(appPath))- {- FFMpegPath = appPath;+ else if (File.Exists(appPath))+ {+ FFMpegPath = appPath;- SetProbePathFromEncoderPath(appPath);+ SetProbePathFromEncoderPath(appPath);+ }}LogPaths();diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.csindex c6a180db1e..1130d3a11b 100644--- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs+++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs@@ -650,13 +650,13 @@ namespace MediaBrowser.Server.Startup.Commonvar info = await new FFMpegLoader(Logger, ApplicationPaths, HttpClient, ZipClient, FileSystemManager, NativeApp.Environment, NativeApp.GetType().Assembly, NativeApp.GetFfmpegInstallInfo()).GetFFMpegInfo(NativeApp.Environment, _startupOptions, progress).ConfigureAwait(false);- _hasExternalEncoder = !string.IsNullOrWhiteSpace(info.EncoderPath);+ _hasExternalEncoder = string.Equals(info.Version, "custom", StringComparison.OrdinalIgnoreCase);var mediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"),JsonSerializer,info.EncoderPath,info.ProbePath,- info.Version,+ _hasExternalEncoder,ServerConfigurationManager,FileSystemManager,LiveTvManager,