add ability to customize ffmpeg path
This commit is contained in:
parent
5c615fa024
commit
10cb5a8bf6
|
@ -5,6 +5,7 @@ using MediaBrowser.Model.Logging;
|
|||
using MediaBrowser.Server.Implementations;
|
||||
using MediaBrowser.ServerApplication;
|
||||
using MediaBrowser.ServerApplication.Native;
|
||||
using MediaBrowser.ServerApplication.IO;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
|
@ -41,8 +42,10 @@ namespace MediaBrowser.Server.Mono
|
|||
var applicationPath = Assembly.GetEntryAssembly ().Location;
|
||||
#endif
|
||||
|
||||
var options = new StartupOptions();
|
||||
|
||||
// Allow this to be specified on the command line.
|
||||
var customProgramDataPath = ParseProgramDataPathFromCommandLine();
|
||||
var customProgramDataPath = options.GetOption("-programdata");
|
||||
|
||||
var appPaths = CreateApplicationPaths(applicationPath, customProgramDataPath);
|
||||
|
||||
|
@ -52,7 +55,7 @@ namespace MediaBrowser.Server.Mono
|
|||
|
||||
var logger = _logger = logManager.GetLogger("Main");
|
||||
|
||||
BeginLog(logger);
|
||||
BeginLog(logger, appPaths);
|
||||
|
||||
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
||||
|
||||
|
@ -73,20 +76,6 @@ namespace MediaBrowser.Server.Mono
|
|||
_appHost.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private static string ParseProgramDataPathFromCommandLine()
|
||||
{
|
||||
var commandArgs = Environment.GetCommandLineArgs().ToList();
|
||||
|
||||
var programDataPathIndex = commandArgs.IndexOf("-programdata");
|
||||
|
||||
if (programDataPathIndex != -1)
|
||||
{
|
||||
return commandArgs.ElementAtOrDefault(programDataPathIndex + 1);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ServerApplicationPaths CreateApplicationPaths(string applicationPath, string programDataPath)
|
||||
{
|
||||
|
@ -169,14 +158,11 @@ namespace MediaBrowser.Server.Mono
|
|||
/// Begins the log.
|
||||
/// </summary>
|
||||
/// <param name="logger">The logger.</param>
|
||||
private static void BeginLog(ILogger logger)
|
||||
{
|
||||
logger.Info("Media Browser Server started");
|
||||
logger.Info("Command line: {0}", string.Join(" ", Environment.GetCommandLineArgs()));
|
||||
|
||||
logger.Info("Server: {0}", Environment.MachineName);
|
||||
logger.Info("Operating system: {0}", Environment.OSVersion.ToString());
|
||||
}
|
||||
private static void BeginLog(ILogger logger, IApplicationPaths appPaths)
|
||||
{
|
||||
logger.Info("Media Browser Server started");
|
||||
ApplicationHost.LogEnvironmentInfo(logger, appPaths);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the UnhandledException event of the CurrentDomain control.
|
||||
|
|
|
@ -219,6 +219,8 @@ namespace MediaBrowser.ServerApplication
|
|||
private ISyncRepository SyncRepository { get; set; }
|
||||
private ITVSeriesManager TVSeriesManager { get; set; }
|
||||
|
||||
private StartupOptions _startupOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ApplicationHost" /> class.
|
||||
/// </summary>
|
||||
|
@ -226,9 +228,15 @@ namespace MediaBrowser.ServerApplication
|
|||
/// <param name="logManager">The log manager.</param>
|
||||
/// <param name="supportsRunningAsService">if set to <c>true</c> [supports running as service].</param>
|
||||
/// <param name="isRunningAsService">if set to <c>true</c> [is running as service].</param>
|
||||
public ApplicationHost(ServerApplicationPaths applicationPaths, ILogManager logManager, bool supportsRunningAsService, bool isRunningAsService)
|
||||
/// <param name="options">The options.</param>
|
||||
public ApplicationHost(ServerApplicationPaths applicationPaths,
|
||||
ILogManager logManager,
|
||||
bool supportsRunningAsService,
|
||||
bool isRunningAsService,
|
||||
StartupOptions options)
|
||||
: base(applicationPaths, logManager)
|
||||
{
|
||||
_startupOptions = options;
|
||||
_isRunningAsService = isRunningAsService;
|
||||
SupportsRunningAsService = supportsRunningAsService;
|
||||
}
|
||||
|
@ -548,7 +556,7 @@ namespace MediaBrowser.ServerApplication
|
|||
/// <returns>Task.</returns>
|
||||
private async Task RegisterMediaEncoder(IProgress<double> progress)
|
||||
{
|
||||
var info = await new FFMpegDownloader(Logger, ApplicationPaths, HttpClient, ZipClient, FileSystemManager).GetFFMpegInfo(progress).ConfigureAwait(false);
|
||||
var info = await new FFMpegDownloader(Logger, ApplicationPaths, HttpClient, ZipClient, FileSystemManager).GetFFMpegInfo(_startupOptions, progress).ConfigureAwait(false);
|
||||
|
||||
MediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"), JsonSerializer, info.EncoderPath, info.ProbePath, info.Version);
|
||||
RegisterSingleInstance(MediaEncoder);
|
||||
|
|
|
@ -14,6 +14,7 @@ using System.Threading.Tasks;
|
|||
#if __MonoCS__
|
||||
using Mono.Unix.Native;
|
||||
#endif
|
||||
using MediaBrowser.ServerApplication.IO;
|
||||
|
||||
namespace MediaBrowser.ServerApplication.FFMpeg
|
||||
{
|
||||
|
@ -39,8 +40,21 @@ namespace MediaBrowser.ServerApplication.FFMpeg
|
|||
_fileSystem = fileSystem;
|
||||
}
|
||||
|
||||
public async Task<FFMpegInfo> GetFFMpegInfo(IProgress<double> progress)
|
||||
public async Task<FFMpegInfo> GetFFMpegInfo(StartupOptions options, IProgress<double> progress)
|
||||
{
|
||||
var customffMpegPath = options.GetOption("-ffmpeg");
|
||||
var customffProbePath = options.GetOption("-ffprobe");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(customffMpegPath) && !string.IsNullOrWhiteSpace(customffProbePath))
|
||||
{
|
||||
return new FFMpegInfo
|
||||
{
|
||||
ProbePath = customffProbePath,
|
||||
EncoderPath = customffMpegPath,
|
||||
Version = "custom"
|
||||
};
|
||||
}
|
||||
|
||||
var rootEncoderPath = Path.Combine(_appPaths.ProgramDataPath, "ffmpeg");
|
||||
var versionedDirectoryPath = Path.Combine(rootEncoderPath, FFMpegDownloadInfo.Version);
|
||||
|
||||
|
|
28
MediaBrowser.ServerApplication/IO/StartupOptions.cs
Normal file
28
MediaBrowser.ServerApplication/IO/StartupOptions.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace MediaBrowser.ServerApplication.IO
|
||||
{
|
||||
public class StartupOptions
|
||||
{
|
||||
private readonly List<string> _options = Environment.GetCommandLineArgs().ToList();
|
||||
|
||||
public bool ContainsOption(string option)
|
||||
{
|
||||
return _options.Contains(option, StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public string GetOption(string name)
|
||||
{
|
||||
var index = _options.IndexOf(name);
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
return _options.ElementAtOrDefault(index + 1);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
using MediaBrowser.Common.Implementations.Logging;
|
||||
using MediaBrowser.Model.Logging;
|
||||
using MediaBrowser.Server.Implementations;
|
||||
using MediaBrowser.ServerApplication.IO;
|
||||
using MediaBrowser.ServerApplication.Native;
|
||||
using MediaBrowser.ServerApplication.Splash;
|
||||
using MediaBrowser.ServerApplication.Updates;
|
||||
|
@ -32,8 +33,8 @@ namespace MediaBrowser.ServerApplication
|
|||
/// </summary>
|
||||
public static void Main()
|
||||
{
|
||||
var startFlag = Environment.GetCommandLineArgs().ElementAtOrDefault(1);
|
||||
_isRunningAsService = string.Equals(startFlag, "-service", StringComparison.OrdinalIgnoreCase);
|
||||
var options = new StartupOptions();
|
||||
_isRunningAsService = options.ContainsOption("-service");
|
||||
|
||||
var applicationPath = Process.GetCurrentProcess().MainModule.FileName;
|
||||
|
||||
|
@ -48,7 +49,7 @@ namespace MediaBrowser.ServerApplication
|
|||
BeginLog(logger, appPaths);
|
||||
|
||||
// Install directly
|
||||
if (string.Equals(startFlag, "-installservice", StringComparison.OrdinalIgnoreCase))
|
||||
if (options.ContainsOption("-installservice"))
|
||||
{
|
||||
logger.Info("Performing service installation");
|
||||
InstallService(applicationPath, logger);
|
||||
|
@ -56,7 +57,7 @@ namespace MediaBrowser.ServerApplication
|
|||
}
|
||||
|
||||
// Restart with admin rights, then install
|
||||
if (string.Equals(startFlag, "-installserviceasadmin", StringComparison.OrdinalIgnoreCase))
|
||||
if (options.ContainsOption("-installserviceasadmin"))
|
||||
{
|
||||
logger.Info("Performing service installation");
|
||||
RunServiceInstallation(applicationPath);
|
||||
|
@ -64,7 +65,7 @@ namespace MediaBrowser.ServerApplication
|
|||
}
|
||||
|
||||
// Uninstall directly
|
||||
if (string.Equals(startFlag, "-uninstallservice", StringComparison.OrdinalIgnoreCase))
|
||||
if (options.ContainsOption("-uninstallservice"))
|
||||
{
|
||||
logger.Info("Performing service uninstallation");
|
||||
UninstallService(applicationPath, logger);
|
||||
|
@ -72,7 +73,7 @@ namespace MediaBrowser.ServerApplication
|
|||
}
|
||||
|
||||
// Restart with admin rights, then uninstall
|
||||
if (string.Equals(startFlag, "-uninstallserviceasadmin", StringComparison.OrdinalIgnoreCase))
|
||||
if (options.ContainsOption("-uninstallserviceasadmin"))
|
||||
{
|
||||
logger.Info("Performing service uninstallation");
|
||||
RunServiceUninstallation(applicationPath);
|
||||
|
@ -99,7 +100,7 @@ namespace MediaBrowser.ServerApplication
|
|||
|
||||
try
|
||||
{
|
||||
RunApplication(appPaths, logManager, _isRunningAsService);
|
||||
RunApplication(appPaths, logManager, _isRunningAsService, options);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -205,9 +206,10 @@ namespace MediaBrowser.ServerApplication
|
|||
/// <param name="appPaths">The app paths.</param>
|
||||
/// <param name="logManager">The log manager.</param>
|
||||
/// <param name="runService">if set to <c>true</c> [run service].</param>
|
||||
private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, bool runService)
|
||||
/// <param name="options">The options.</param>
|
||||
private static void RunApplication(ServerApplicationPaths appPaths, ILogManager logManager, bool runService, StartupOptions options)
|
||||
{
|
||||
_appHost = new ApplicationHost(appPaths, logManager, true, runService);
|
||||
_appHost = new ApplicationHost(appPaths, logManager, true, runService, options);
|
||||
|
||||
var initProgress = new Progress<double>();
|
||||
|
||||
|
|
|
@ -105,6 +105,7 @@
|
|||
<Compile Include="FFMpeg\FFMpegInfo.cs" />
|
||||
<Compile Include="IO\FileSystemFactory.cs" />
|
||||
<Compile Include="IO\NativeFileSystem.cs" />
|
||||
<Compile Include="IO\StartupOptions.cs" />
|
||||
<Compile Include="Logging\LogForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
|
Loading…
Reference in New Issue
Block a user