aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegLoader.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegLoader.cs')
-rw-r--r--MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegLoader.cs44
1 files changed, 6 insertions, 38 deletions
diff --git a/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegLoader.cs b/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegLoader.cs
index ee284fdc5..a4c50d0d8 100644
--- a/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegLoader.cs
+++ b/MediaBrowser.Server.Startup.Common/FFMpeg/FFMpegLoader.cs
@@ -24,7 +24,6 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
private readonly IZipClient _zipClient;
private readonly IFileSystem _fileSystem;
private readonly NativeEnvironment _environment;
- private readonly Assembly _ownerAssembly;
private readonly FFMpegInstallInfo _ffmpegInstallInfo;
private readonly string[] _fontUrls =
@@ -32,7 +31,7 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
"https://github.com/MediaBrowser/MediaBrowser.Resources/raw/master/ffmpeg/ARIALUNI.7z"
};
- public FFMpegLoader(ILogger logger, IApplicationPaths appPaths, IHttpClient httpClient, IZipClient zipClient, IFileSystem fileSystem, NativeEnvironment environment, Assembly ownerAssembly, FFMpegInstallInfo ffmpegInstallInfo)
+ public FFMpegLoader(ILogger logger, IApplicationPaths appPaths, IHttpClient httpClient, IZipClient zipClient, IFileSystem fileSystem, NativeEnvironment environment, FFMpegInstallInfo ffmpegInstallInfo)
{
_logger = logger;
_appPaths = appPaths;
@@ -40,7 +39,6 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
_zipClient = zipClient;
_fileSystem = fileSystem;
_environment = environment;
- _ownerAssembly = ownerAssembly;
_ffmpegInstallInfo = ffmpegInstallInfo;
}
@@ -55,13 +53,17 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
{
ProbePath = customffProbePath,
EncoderPath = customffMpegPath,
- Version = "custom"
+ Version = "external"
};
}
var downloadInfo = _ffmpegInstallInfo;
var version = downloadInfo.Version;
+ if (string.Equals(version, "0", StringComparison.OrdinalIgnoreCase))
+ {
+ return new FFMpegInfo();
+ }
if (string.Equals(version, "path", StringComparison.OrdinalIgnoreCase))
{
@@ -99,14 +101,8 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
}
else
{
- // Older version found.
- // Start with that. Download new version in the background.
- var newPath = versionedDirectoryPath;
- Task.Run(() => DownloadFFMpegInBackground(downloadInfo, newPath));
-
info = existingVersion;
versionedDirectoryPath = Path.GetDirectoryName(info.EncoderPath);
-
excludeFromDeletions.Add(versionedDirectoryPath);
}
}
@@ -183,36 +179,8 @@ namespace MediaBrowser.Server.Startup.Common.FFMpeg
return null;
}
- private async void DownloadFFMpegInBackground(FFMpegInstallInfo downloadinfo, string directory)
- {
- try
- {
- await DownloadFFMpeg(downloadinfo, directory, new Progress<double>()).ConfigureAwait(false);
- }
- catch (Exception ex)
- {
- _logger.ErrorException("Error downloading ffmpeg", ex);
- }
- }
-
private async Task DownloadFFMpeg(FFMpegInstallInfo downloadinfo, string directory, IProgress<double> progress)
{
- if (downloadinfo.IsEmbedded)
- {
- var tempFile = Path.Combine(_appPaths.TempDirectory, Guid.NewGuid().ToString());
- _fileSystem.CreateDirectory(Path.GetDirectoryName(tempFile));
-
- using (var stream = _ownerAssembly.GetManifestResourceStream(downloadinfo.DownloadUrls[0]))
- {
- using (var fs = _fileSystem.GetFileStream(tempFile, FileMode.Create, FileAccess.Write, FileShare.Read, true))
- {
- await stream.CopyToAsync(fs).ConfigureAwait(false);
- }
- }
- ExtractFFMpeg(downloadinfo, tempFile, directory);
- return;
- }
-
foreach (var url in downloadinfo.DownloadUrls)
{
progress.Report(0);