diff --git a/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs b/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs index e54bc0b4ad..6d19c32759 100644 --- a/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs +++ b/MediaBrowser.Server.Mono/Native/BaseMonoApp.cs @@ -9,6 +9,8 @@ using System.Collections.Generic; using System.Reflection; using System.Text.RegularExpressions; using MediaBrowser.Controller.Power; +using MediaBrowser.Server.Startup.Common.FFMpeg; +using OperatingSystem = MediaBrowser.Server.Startup.Common.OperatingSystem; namespace MediaBrowser.Server.Mono.Native { @@ -209,6 +211,99 @@ namespace MediaBrowser.Server.Mono.Native { return new NullPowerManagement(); } + + public FFMpegInstallInfo GetFfmpegInstallInfo() + { + return GetInfo(Environment); + } + + public static FFMpegInstallInfo GetInfo(NativeEnvironment environment) + { + var info = new FFMpegInstallInfo(); + + // Windows builds: http://ffmpeg.zeranoe.com/builds/ + // Linux builds: http://johnvansickle.com/ffmpeg/ + // OS X builds: http://ffmpegmac.net/ + // OS X x64: http://www.evermeet.cx/ffmpeg/ + + switch (environment.OperatingSystem) + { + case OperatingSystem.Bsd: + break; + case OperatingSystem.Linux: + + info.ArchiveType = "7z"; + info.Version = "20160215"; + break; + case OperatingSystem.Osx: + + info.ArchiveType = "7z"; + + switch (environment.SystemArchitecture) + { + case Architecture.X86_X64: + info.Version = "20160124"; + break; + case Architecture.X86: + info.Version = "20150110"; + break; + } + break; + } + + info.DownloadUrls = GetDownloadUrls(environment); + + return info; + } + + private static string[] GetDownloadUrls(NativeEnvironment environment) + { + switch (environment.OperatingSystem) + { + case OperatingSystem.Osx: + + switch (environment.SystemArchitecture) + { + case Architecture.X86_X64: + return new[] + { + "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/osx/ffmpeg-x64-2.8.5.7z" + }; + case Architecture.X86: + return new[] + { + "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/osx/ffmpeg-x86-2.5.3.7z" + }; + } + break; + + case OperatingSystem.Linux: + + switch (environment.SystemArchitecture) + { + case Architecture.X86_X64: + return new[] + { + "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-git-20160215-64bit-static.7z" + }; + case Architecture.X86: + return new[] + { + "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-git-20160215-32bit-static.7z" + }; + case Architecture.Arm: + return new[] + { + "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-arm.7z" + }; + } + break; + } + + // No version available + return new string[] { }; + } + } public class NullPowerManagement : IPowerManagement diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index b5988b18a7..93dbe2945c 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -618,7 +618,7 @@ namespace MediaBrowser.Server.Startup.Common /// Task. private async Task RegisterMediaEncoder(IProgress progress) { - var info = await new FFMpegDownloader(Logger, ApplicationPaths, HttpClient, ZipClient, FileSystemManager, NativeApp.Environment, NativeApp.GetType().Assembly) + var info = await new FFMpegLoader(Logger, ApplicationPaths, HttpClient, ZipClient, FileSystemManager, NativeApp.Environment, NativeApp.GetType().Assembly, NativeApp.GetFfmpegInstallInfo()) .GetFFMpegInfo(NativeApp.Environment, _startupOptions, progress).ConfigureAwait(false); var mediaEncoder = new MediaEncoder(LogManager.GetLogger("MediaEncoder"), diff --git a/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloadInfo.cs b/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloadInfo.cs deleted file mode 100644 index 4979ff82bd..0000000000 --- a/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloadInfo.cs +++ /dev/null @@ -1,136 +0,0 @@ - -namespace MediaBrowser.Server.Startup.Common.FFMpeg -{ - public class FFMpegDownloadInfo - { - public string Version { get; set; } - public string FFMpegFilename { get; set; } - public string FFProbeFilename { get; set; } - public string ArchiveType { get; set; } - public string[] DownloadUrls { get; set; } - public bool IsEmbedded { get; set; } - - public FFMpegDownloadInfo() - { - DownloadUrls = new string[] { }; - Version = "Path"; - FFMpegFilename = "ffmpeg"; - FFProbeFilename = "ffprobe"; - } - - public static FFMpegDownloadInfo GetInfo(NativeEnvironment environment) - { - var info = new FFMpegDownloadInfo(); - - // Windows builds: http://ffmpeg.zeranoe.com/builds/ - // Linux builds: http://johnvansickle.com/ffmpeg/ - // OS X builds: http://ffmpegmac.net/ - // OS X x64: http://www.evermeet.cx/ffmpeg/ - - switch (environment.OperatingSystem) - { - case OperatingSystem.Bsd: - break; - case OperatingSystem.Linux: - - info.ArchiveType = "7z"; - info.Version = "20160215"; - break; - case OperatingSystem.Osx: - - info.ArchiveType = "7z"; - - switch (environment.SystemArchitecture) - { - case Architecture.X86_X64: - info.Version = "20160124"; - break; - case Architecture.X86: - info.Version = "20150110"; - break; - } - break; - - case OperatingSystem.Windows: - - info.FFMpegFilename = "ffmpeg.exe"; - info.FFProbeFilename = "ffprobe.exe"; - info.Version = "20160401"; - info.ArchiveType = "7z"; - info.IsEmbedded = true; - - switch (environment.SystemArchitecture) - { - case Architecture.X86_X64: - break; - case Architecture.X86: - break; - } - break; - } - - info.DownloadUrls = GetDownloadUrls(environment); - - return info; - } - - private static string[] GetDownloadUrls(NativeEnvironment environment) - { - switch (environment.OperatingSystem) - { - case OperatingSystem.Windows: - - switch (environment.SystemArchitecture) - { - case Architecture.X86_X64: - return new string[] { "MediaBrowser.ServerApplication.ffmpeg.ffmpegx64.7z" }; - case Architecture.X86: - return new string[] { "MediaBrowser.ServerApplication.ffmpeg.ffmpegx86.7z" }; - } - break; - - case OperatingSystem.Osx: - - switch (environment.SystemArchitecture) - { - case Architecture.X86_X64: - return new[] - { - "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/osx/ffmpeg-x64-2.8.5.7z" - }; - case Architecture.X86: - return new[] - { - "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/osx/ffmpeg-x86-2.5.3.7z" - }; - } - break; - - case OperatingSystem.Linux: - - switch (environment.SystemArchitecture) - { - case Architecture.X86_X64: - return new[] - { - "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-git-20160215-64bit-static.7z" - }; - case Architecture.X86: - return new[] - { - "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-git-20160215-32bit-static.7z" - }; - case Architecture.Arm: - return new[] - { - "https://github.com/MediaBrowser/Emby.Resources/raw/master/ffmpeg/linux/ffmpeg-arm.7z" - }; - } - break; - } - - // No version available - return new string[] { }; - } - } -} \ No newline at end of file diff --git a/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegInstallInfo.cs b/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegInstallInfo.cs new file mode 100644 index 0000000000..1ce1b55c24 --- /dev/null +++ b/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegInstallInfo.cs @@ -0,0 +1,21 @@ + +namespace MediaBrowser.Server.Startup.Common.FFMpeg +{ + public class FFMpegInstallInfo + { + public string Version { get; set; } + public string FFMpegFilename { get; set; } + public string FFProbeFilename { get; set; } + public string ArchiveType { get; set; } + public string[] DownloadUrls { get; set; } + public bool IsEmbedded { get; set; } + + public FFMpegInstallInfo() + { + DownloadUrls = new string[] { }; + Version = "Path"; + FFMpegFilename = "ffmpeg"; + FFProbeFilename = "ffprobe"; + } + } +} \ No newline at end of file diff --git a/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloader.cs b/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegLoader.cs similarity index 94% rename from MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloader.cs rename to MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegLoader.cs index c538b81a4f..fd005de866 100644 --- a/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegDownloader.cs +++ b/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegLoader.cs @@ -16,7 +16,7 @@ using CommonIO; namespace MediaBrowser.Server.Startup.Common.FFMpeg { - public class FFMpegDownloader + public class FFMpegLoader { private readonly IHttpClient _httpClient; private readonly IApplicationPaths _appPaths; @@ -24,14 +24,15 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg private readonly IZipClient _zipClient; private readonly IFileSystem _fileSystem; private readonly NativeEnvironment _environment; - private Assembly _ownerAssembly; + private readonly Assembly _ownerAssembly; + private readonly FFMpegInstallInfo _ffmpegInstallInfo; private readonly string[] _fontUrls = { "https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/ARIALUNI.7z" }; - public FFMpegDownloader(ILogger logger, IApplicationPaths appPaths, IHttpClient httpClient, IZipClient zipClient, IFileSystem fileSystem, NativeEnvironment environment, Assembly ownerAssembly) + public FFMpegLoader(ILogger logger, IApplicationPaths appPaths, IHttpClient httpClient, IZipClient zipClient, IFileSystem fileSystem, NativeEnvironment environment, Assembly ownerAssembly, FFMpegInstallInfo ffmpegInstallInfo) { _logger = logger; _appPaths = appPaths; @@ -40,6 +41,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg _fileSystem = fileSystem; _environment = environment; _ownerAssembly = ownerAssembly; + _ffmpegInstallInfo = ffmpegInstallInfo; } public async Task GetFFMpegInfo(NativeEnvironment environment, StartupOptions options, IProgress progress) @@ -57,7 +59,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg }; } - var downloadInfo = FFMpegDownloadInfo.GetInfo(environment); + var downloadInfo = _ffmpegInstallInfo; var version = downloadInfo.Version; @@ -181,7 +183,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg return null; } - private async void DownloadFFMpegInBackground(FFMpegDownloadInfo downloadinfo, string directory) + private async void DownloadFFMpegInBackground(FFMpegInstallInfo downloadinfo, string directory) { try { @@ -193,7 +195,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg } } - private async Task DownloadFFMpeg(FFMpegDownloadInfo downloadinfo, string directory, IProgress progress) + private async Task DownloadFFMpeg(FFMpegInstallInfo downloadinfo, string directory, IProgress progress) { if (downloadinfo.IsEmbedded) { @@ -241,7 +243,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg throw new ApplicationException("Unable to download required components. Please try again later."); } - private void ExtractFFMpeg(FFMpegDownloadInfo downloadinfo, string tempFile, string targetFolder) + private void ExtractFFMpeg(FFMpegInstallInfo downloadinfo, string tempFile, string targetFolder) { _logger.Info("Extracting ffmpeg from {0}", tempFile); @@ -287,7 +289,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg } } - private void ExtractArchive(FFMpegDownloadInfo downloadinfo, string archivePath, string targetPath) + private void ExtractArchive(FFMpegInstallInfo downloadinfo, string archivePath, string targetPath) { _logger.Info("Extracting {0} to {1}", archivePath, targetPath); diff --git a/MediaBrowser.Server.Startup.Common/INativeApp.cs b/MediaBrowser.Server.Startup.Common/INativeApp.cs index 9df670bdae..121d4192ed 100644 --- a/MediaBrowser.Server.Startup.Common/INativeApp.cs +++ b/MediaBrowser.Server.Startup.Common/INativeApp.cs @@ -3,6 +3,7 @@ using MediaBrowser.Model.Logging; using System.Collections.Generic; using System.Reflection; using MediaBrowser.Controller.Power; +using MediaBrowser.Server.Startup.Common.FFMpeg; namespace MediaBrowser.Server.Startup.Common { @@ -97,5 +98,7 @@ namespace MediaBrowser.Server.Startup.Common /// /// IPowerManagement. IPowerManagement GetPowerManagement(); + + FFMpegInstallInfo GetFfmpegInstallInfo(); } } diff --git a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj index 80ce88fa33..19ce9ed9e3 100644 --- a/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj +++ b/MediaBrowser.Server.Startup.Common/MediaBrowser.Server.Startup.Common.csproj @@ -65,8 +65,8 @@ - - + + diff --git a/MediaBrowser.ServerApplication/Native/WindowsApp.cs b/MediaBrowser.ServerApplication/Native/WindowsApp.cs index 164037dc54..056258f962 100644 --- a/MediaBrowser.ServerApplication/Native/WindowsApp.cs +++ b/MediaBrowser.ServerApplication/Native/WindowsApp.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Reflection; using CommonIO; using MediaBrowser.Controller.Power; +using MediaBrowser.Server.Startup.Common.FFMpeg; namespace MediaBrowser.ServerApplication.Native { @@ -30,7 +31,7 @@ namespace MediaBrowser.ServerApplication.Native } list.Add(GetType().Assembly); - + return list; } @@ -124,5 +125,32 @@ namespace MediaBrowser.ServerApplication.Native { return new WindowsPowerManagement(_logger); } + + public FFMpegInstallInfo GetFfmpegInstallInfo() + { + var info = new FFMpegInstallInfo(); + + info.FFMpegFilename = "ffmpeg.exe"; + info.FFProbeFilename = "ffprobe.exe"; + info.Version = "20160401"; + info.ArchiveType = "7z"; + info.IsEmbedded = true; + info.DownloadUrls = GetDownloadUrls(); + + return info; + } + + private string[] GetDownloadUrls() + { + switch (Environment.SystemArchitecture) + { + case Architecture.X86_X64: + return new[] { "MediaBrowser.ServerApplication.ffmpeg.ffmpegx64.7z" }; + case Architecture.X86: + return new[] { "MediaBrowser.ServerApplication.ffmpeg.ffmpegx86.7z" }; + } + + return new string[] { }; + } } }