mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
#429 - Extract ffmpeg from core product
This commit is contained in:
parent
cacba5ca11
commit
a02333fb0c
@ -258,6 +258,8 @@ namespace MediaBrowser.ServerApplication
|
|||||||
ZipClient = new DotNetZipClient();
|
ZipClient = new DotNetZipClient();
|
||||||
RegisterSingleInstance(ZipClient);
|
RegisterSingleInstance(ZipClient);
|
||||||
|
|
||||||
|
var mediaEncoderTask = RegisterMediaEncoder();
|
||||||
|
|
||||||
UserDataRepository = new SqliteUserDataRepository(ApplicationPaths, JsonSerializer, LogManager);
|
UserDataRepository = new SqliteUserDataRepository(ApplicationPaths, JsonSerializer, LogManager);
|
||||||
RegisterSingleInstance(UserDataRepository);
|
RegisterSingleInstance(UserDataRepository);
|
||||||
|
|
||||||
@ -284,8 +286,6 @@ namespace MediaBrowser.ServerApplication
|
|||||||
|
|
||||||
RegisterSingleInstance<ILibrarySearchEngine>(() => new LuceneSearchEngine(ApplicationPaths, LogManager, LibraryManager));
|
RegisterSingleInstance<ILibrarySearchEngine>(() => new LuceneSearchEngine(ApplicationPaths, LogManager, LibraryManager));
|
||||||
|
|
||||||
await RegisterMediaEncoder().ConfigureAwait(false);
|
|
||||||
|
|
||||||
var clientConnectionManager = new SessionManager(UserDataRepository, ServerConfigurationManager, Logger, UserRepository);
|
var clientConnectionManager = new SessionManager(UserDataRepository, ServerConfigurationManager, Logger, UserRepository);
|
||||||
RegisterSingleInstance<ISessionManager>(clientConnectionManager);
|
RegisterSingleInstance<ISessionManager>(clientConnectionManager);
|
||||||
|
|
||||||
@ -310,7 +310,7 @@ namespace MediaBrowser.ServerApplication
|
|||||||
|
|
||||||
await ConfigureNotificationsRepository().ConfigureAwait(false);
|
await ConfigureNotificationsRepository().ConfigureAwait(false);
|
||||||
|
|
||||||
await Task.WhenAll(itemsTask, displayPreferencesTask, userdataTask).ConfigureAwait(false);
|
await Task.WhenAll(itemsTask, displayPreferencesTask, userdataTask, mediaEncoderTask).ConfigureAwait(false);
|
||||||
|
|
||||||
SetKernelProperties();
|
SetKernelProperties();
|
||||||
}
|
}
|
||||||
|
@ -29,33 +29,37 @@ namespace MediaBrowser.ServerApplication.Implementations
|
|||||||
|
|
||||||
public async Task<FFMpegInfo> GetFFMpegInfo()
|
public async Task<FFMpegInfo> GetFFMpegInfo()
|
||||||
{
|
{
|
||||||
var assembly = GetType().Assembly;
|
var version = "ffmpeg20130904";
|
||||||
|
|
||||||
var prefix = GetType().Namespace + ".";
|
var versionedDirectoryPath = Path.Combine(GetMediaToolsPath(true), version);
|
||||||
|
|
||||||
var srch = prefix + "ffmpeg";
|
var info = new FFMpegInfo
|
||||||
|
{
|
||||||
var resource = assembly.GetManifestResourceNames().First(r => r.StartsWith(srch));
|
ProbePath = Path.Combine(versionedDirectoryPath, "ffprobe.exe"),
|
||||||
|
Path = Path.Combine(versionedDirectoryPath, "ffmpeg.exe"),
|
||||||
var filename =
|
Version = version
|
||||||
resource.Substring(resource.IndexOf(prefix, StringComparison.OrdinalIgnoreCase) + prefix.Length);
|
};
|
||||||
|
|
||||||
var versionedDirectoryPath = Path.Combine(GetMediaToolsPath(true),
|
|
||||||
Path.GetFileNameWithoutExtension(filename));
|
|
||||||
|
|
||||||
if (!Directory.Exists(versionedDirectoryPath))
|
if (!Directory.Exists(versionedDirectoryPath))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(versionedDirectoryPath);
|
Directory.CreateDirectory(versionedDirectoryPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
await ExtractTools(assembly, resource, versionedDirectoryPath).ConfigureAwait(false);
|
if (!File.Exists(info.ProbePath) || !File.Exists(info.Path))
|
||||||
|
|
||||||
return new FFMpegInfo
|
|
||||||
{
|
{
|
||||||
ProbePath = Path.Combine(versionedDirectoryPath, "ffprobe.exe"),
|
ExtractTools(version, versionedDirectoryPath);
|
||||||
Path = Path.Combine(versionedDirectoryPath, "ffmpeg.exe"),
|
}
|
||||||
Version = Path.GetFileNameWithoutExtension(versionedDirectoryPath)
|
|
||||||
};
|
try
|
||||||
|
{
|
||||||
|
await DownloadFonts(versionedDirectoryPath).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.ErrorException("Error getting ffmpeg font files", ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -64,21 +68,14 @@ namespace MediaBrowser.ServerApplication.Implementations
|
|||||||
/// <param name="assembly">The assembly.</param>
|
/// <param name="assembly">The assembly.</param>
|
||||||
/// <param name="zipFileResourcePath">The zip file resource path.</param>
|
/// <param name="zipFileResourcePath">The zip file resource path.</param>
|
||||||
/// <param name="targetPath">The target path.</param>
|
/// <param name="targetPath">The target path.</param>
|
||||||
private async Task ExtractTools(Assembly assembly, string zipFileResourcePath, string targetPath)
|
private void ExtractTools(string version, string targetPath)
|
||||||
{
|
{
|
||||||
using (var resourceStream = assembly.GetManifestResourceStream(zipFileResourcePath))
|
var zipFileResourcePath = GetType().Namespace + "." + version + ".zip";
|
||||||
|
|
||||||
|
using (var resourceStream = GetType().Assembly.GetManifestResourceStream(zipFileResourcePath))
|
||||||
{
|
{
|
||||||
_zipClient.ExtractAll(resourceStream, targetPath, false);
|
_zipClient.ExtractAll(resourceStream, targetPath, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
await DownloadFonts(targetPath).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.ErrorException("Error getting ffmpeg font files", ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private const string FontUrl = "https://www.dropbox.com/s/9nb76tybcsw5xrk/ARIALUNI.zip?dl=1";
|
private const string FontUrl = "https://www.dropbox.com/s/9nb76tybcsw5xrk/ARIALUNI.zip?dl=1";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user