Extract ffmpeg during init
This commit is contained in:
parent
1187222842
commit
19a4dd83c2
|
@ -1,5 +1,4 @@
|
|||
using System.IO;
|
||||
using System.Reflection;
|
||||
using MediaBrowser.Common.Configuration;
|
||||
|
||||
namespace MediaBrowser.Controller.Configuration
|
||||
|
@ -227,24 +226,7 @@ namespace MediaBrowser.Controller.Configuration
|
|||
{
|
||||
if (_FFMpegPath == null)
|
||||
{
|
||||
string filename = "ffmpeg.exe";
|
||||
|
||||
_FFMpegPath = Path.Combine(FFMpegDirectory, filename);
|
||||
|
||||
// Always re-extract the first time to handle new versions
|
||||
if (File.Exists(_FFMpegPath))
|
||||
{
|
||||
File.Delete(_FFMpegPath);
|
||||
}
|
||||
|
||||
// Extract exe
|
||||
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MediaBrowser.Controller.FFMpeg." + filename))
|
||||
{
|
||||
using (FileStream fileStream = new FileStream(_FFMpegPath, FileMode.Create))
|
||||
{
|
||||
stream.CopyTo(fileStream);
|
||||
}
|
||||
}
|
||||
_FFMpegPath = Path.Combine(FFMpegDirectory, "ffmpeg.exe");
|
||||
}
|
||||
|
||||
return _FFMpegPath;
|
||||
|
@ -261,24 +243,7 @@ namespace MediaBrowser.Controller.Configuration
|
|||
{
|
||||
if (_FFProbePath == null)
|
||||
{
|
||||
string filename = "ffprobe.exe";
|
||||
|
||||
_FFProbePath = Path.Combine(FFMpegDirectory, filename);
|
||||
|
||||
/*// Always re-extract the first time to handle new versions
|
||||
if (File.Exists(_FFProbePath))
|
||||
{
|
||||
File.Delete(_FFProbePath);
|
||||
}
|
||||
|
||||
// Extract exe
|
||||
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MediaBrowser.Controller.FFMpeg." + filename))
|
||||
{
|
||||
using (FileStream fileStream = new FileStream(_FFProbePath, FileMode.Create))
|
||||
{
|
||||
stream.CopyTo(fileStream);
|
||||
}
|
||||
}*/
|
||||
_FFProbePath = Path.Combine(FFMpegDirectory, "ffprobe.exe");
|
||||
}
|
||||
|
||||
return _FFProbePath;
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using System.ComponentModel.Composition;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -73,7 +74,10 @@ namespace MediaBrowser.Controller
|
|||
progress.Report(new TaskProgress() { Description = "Loading Users", PercentComplete = 15 });
|
||||
ReloadUsers();
|
||||
|
||||
progress.Report(new TaskProgress() { Description = "Loading Media Library", PercentComplete = 20 });
|
||||
progress.Report(new TaskProgress() { Description = "Extracting FFMpeg", PercentComplete = 20 });
|
||||
await ExtractFFMpeg();
|
||||
|
||||
progress.Report(new TaskProgress() { Description = "Loading Media Library", PercentComplete = 25 });
|
||||
await ReloadRoot();
|
||||
|
||||
progress.Report(new TaskProgress() { Description = "Loading Complete", PercentComplete = 100 });
|
||||
|
@ -252,8 +256,12 @@ namespace MediaBrowser.Controller
|
|||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Runs all metadata providers for an entity
|
||||
/// </summary>
|
||||
internal async Task ExecuteMetadataProviders(BaseEntity item, ItemResolveEventArgs args)
|
||||
{
|
||||
// Get all supported providers
|
||||
var supportedProviders = Kernel.Instance.MetadataProviders.Where(i => i.Supports(item));
|
||||
|
||||
// Start with non-internet providers. Run them sequentially
|
||||
|
@ -273,6 +281,34 @@ namespace MediaBrowser.Controller
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Run these during Init.
|
||||
/// Can't run do this on-demand because there will be multiple workers accessing them at once and we'd have to lock them
|
||||
/// </summary>
|
||||
private async Task ExtractFFMpeg()
|
||||
{
|
||||
// FFMpeg.exe
|
||||
await ExtractFFMpeg(ApplicationPaths.FFMpegPath);
|
||||
await ExtractFFMpeg(ApplicationPaths.FFProbePath);
|
||||
}
|
||||
|
||||
private async Task ExtractFFMpeg(string exe)
|
||||
{
|
||||
if (File.Exists(exe))
|
||||
{
|
||||
File.Delete(exe);
|
||||
}
|
||||
|
||||
// Extract exe
|
||||
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MediaBrowser.Controller.FFMpeg." + Path.GetFileName(exe)))
|
||||
{
|
||||
using (FileStream fileStream = new FileStream(exe, FileMode.Create))
|
||||
{
|
||||
await stream.CopyToAsync(fileStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void DisposeComposableParts()
|
||||
{
|
||||
base.DisposeComposableParts();
|
||||
|
|
Loading…
Reference in New Issue
Block a user