From 6e9f8fb2d1a878369ee36b2e9ebfe7a54954183f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 20 Jun 2016 02:19:28 -0400 Subject: allow customization of ffmpeg path --- .../ApplicationHost.cs | 30 +++++++++++++++------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'MediaBrowser.Server.Startup.Common/ApplicationHost.cs') diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 7341f56cb..c6a180db1 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -323,6 +323,8 @@ namespace MediaBrowser.Server.Startup.Common await base.RunStartupTasks().ConfigureAwait(false); + InitMediaEncoder(); + Logger.Info("ServerId: {0}", SystemId); Logger.Info("Core startup complete"); HttpServer.GlobalResponse = null; @@ -344,6 +346,20 @@ namespace MediaBrowser.Server.Startup.Common LogManager.RemoveConsoleOutput(); } + private void InitMediaEncoder() + { + MediaEncoder.Init(); + + Task.Run(() => + { + var result = new FFmpegValidator(Logger, ApplicationPaths, FileSystemManager).Validate(MediaEncoder.EncoderPath); + + var mediaEncoder = (MediaEncoder) MediaEncoder; + mediaEncoder.SetAvailableDecoders(result.Item1); + mediaEncoder.SetAvailableEncoders(result.Item2); + }); + } + public override Task Init(IProgress progress) { HttpPort = ServerConfigurationManager.Configuration.HttpServerPortNumber; @@ -634,6 +650,8 @@ namespace MediaBrowser.Server.Startup.Common var 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); + var mediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"), JsonSerializer, info.EncoderPath, @@ -651,14 +669,6 @@ namespace MediaBrowser.Server.Startup.Common MediaEncoder = mediaEncoder; RegisterSingleInstance(MediaEncoder); - - Task.Run(() => - { - var result = new FFmpegValidator(Logger, ApplicationPaths, FileSystemManager).Validate(info); - - mediaEncoder.SetAvailableDecoders(result.Item1); - mediaEncoder.SetAvailableEncoders(result.Item2); - }); } /// @@ -1094,6 +1104,7 @@ namespace MediaBrowser.Server.Startup.Common } } + private bool _hasExternalEncoder; /// /// Gets the system status. /// @@ -1133,7 +1144,8 @@ namespace MediaBrowser.Server.Startup.Common SupportsRunningAsService = SupportsRunningAsService, ServerName = FriendlyName, LocalAddress = localAddress, - SupportsLibraryMonitor = SupportsLibraryMonitor + SupportsLibraryMonitor = SupportsLibraryMonitor, + HasExternalEncoder = _hasExternalEncoder }; } -- cgit v1.2.3 From fb07b4640c60d5135097d25d71cad4d2e4b6131f Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 20 Jun 2016 02:45:35 -0400 Subject: update ffmpeg path customization --- .../MediaEncoding/IMediaEncoder.cs | 6 ---- MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs | 40 +++++++++++++++------- .../ApplicationHost.cs | 4 +-- 3 files changed, 29 insertions(+), 21 deletions(-) (limited to 'MediaBrowser.Server.Startup.Common/ApplicationHost.cs') diff --git a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs index 023af7d1a..c00f76f22 100644 --- a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs +++ b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs @@ -19,12 +19,6 @@ namespace MediaBrowser.Controller.MediaEncoding /// The encoder path. string EncoderPath { get; } - /// - /// Gets the version. - /// - /// The version. - string Version { get; } - /// /// Supportses the decoder. /// diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index 61986e3bc..fc627c232 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -66,8 +66,6 @@ namespace MediaBrowser.MediaEncoding.Encoder public 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.Encoder private readonly List _runningProcesses = new List(); 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 subtitleEncoder, Func 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 subtitleEncoder, Func mediaSourceManager) { _logger = logger; _jsonSerializer = jsonSerializer; - Version = version; ConfigurationManager = configurationManager; FileSystem = fileSystem; LiveTvManager = liveTvManager; @@ -98,34 +95,51 @@ namespace MediaBrowser.MediaEncoding.Encoder FFProbePath = 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.cs index c6a180db1..1130d3a11 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -650,13 +650,13 @@ namespace MediaBrowser.Server.Startup.Common var 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, -- cgit v1.2.3