From 3e8610464106337dc3d32b015371c639994e9e57 Mon Sep 17 00:00:00 2001 From: LukePulverenti Luke Pulverenti luke pulverenti Date: Sat, 18 Aug 2012 16:47:10 -0400 Subject: [PATCH] Moved ffmpeg to the controller project and added ffprobe --- MediaBrowser.Api/ApiService.cs | 56 ------------ .../HttpHandlers/BaseMediaHandler.cs | 4 +- MediaBrowser.Api/MediaBrowser.Api.csproj | 6 -- .../Configuration/ServerApplicationPaths.cs | 90 +++++++++++++++++++ .../FFMpeg}/ffmpeg.exe.REMOVED.git-id | 0 .../FFMpeg/ffprobe.exe.REMOVED.git-id | 1 + .../FFMpeg}/readme.txt | 0 .../MediaBrowser.Controller.csproj | 7 ++ 8 files changed, 100 insertions(+), 64 deletions(-) rename {MediaBrowser.Api/ffmpeg => MediaBrowser.Controller/FFMpeg}/ffmpeg.exe.REMOVED.git-id (100%) create mode 100644 MediaBrowser.Controller/FFMpeg/ffprobe.exe.REMOVED.git-id rename {MediaBrowser.Api/ffmpeg => MediaBrowser.Controller/FFMpeg}/readme.txt (100%) diff --git a/MediaBrowser.Api/ApiService.cs b/MediaBrowser.Api/ApiService.cs index 891b72834..6da5071df 100644 --- a/MediaBrowser.Api/ApiService.cs +++ b/MediaBrowser.Api/ApiService.cs @@ -197,61 +197,5 @@ namespace MediaBrowser.Api return null; } - - private static string _FFMpegDirectory = null; - /// - /// Gets the folder path to ffmpeg - /// - public static string FFMpegDirectory - { - get - { - if (_FFMpegDirectory == null) - { - _FFMpegDirectory = System.IO.Path.Combine(Kernel.Instance.ApplicationPaths.ProgramDataPath, "ffmpeg"); - - if (!Directory.Exists(_FFMpegDirectory)) - { - Directory.CreateDirectory(_FFMpegDirectory); - } - } - - return _FFMpegDirectory; - } - } - - private static string _FFMpegPath = null; - /// - /// Gets the path to ffmpeg.exe - /// - public static string FFMpegPath - { - get - { - 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 ffprobe - using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MediaBrowser.Api.FFMpeg." + filename)) - { - using (FileStream fileStream = new FileStream(_FFMpegPath, FileMode.Create)) - { - stream.CopyTo(fileStream); - } - } - } - - return _FFMpegPath; - } - } } } diff --git a/MediaBrowser.Api/HttpHandlers/BaseMediaHandler.cs b/MediaBrowser.Api/HttpHandlers/BaseMediaHandler.cs index 334dc12b1..ffdbab65e 100644 --- a/MediaBrowser.Api/HttpHandlers/BaseMediaHandler.cs +++ b/MediaBrowser.Api/HttpHandlers/BaseMediaHandler.cs @@ -164,8 +164,8 @@ namespace MediaBrowser.Api.HttpHandlers startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardError = true; - startInfo.FileName = ApiService.FFMpegPath; - startInfo.WorkingDirectory = ApiService.FFMpegDirectory; + startInfo.FileName = Kernel.Instance.ApplicationPaths.FFMpegPath; + startInfo.WorkingDirectory = Kernel.Instance.ApplicationPaths.FFMpegDirectory; startInfo.Arguments = GetCommandLineArguments(); Logger.LogInfo(startInfo.FileName + " " + startInfo.Arguments); diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csproj index bc4a6ce75..67c785627 100644 --- a/MediaBrowser.Api/MediaBrowser.Api.csproj +++ b/MediaBrowser.Api/MediaBrowser.Api.csproj @@ -86,12 +86,6 @@ MediaBrowser.Model - - - - - - diff --git a/MediaBrowser.Controller/Configuration/ServerApplicationPaths.cs b/MediaBrowser.Controller/Configuration/ServerApplicationPaths.cs index bd33b1984..e008f7b17 100644 --- a/MediaBrowser.Controller/Configuration/ServerApplicationPaths.cs +++ b/MediaBrowser.Controller/Configuration/ServerApplicationPaths.cs @@ -1,4 +1,5 @@ using System.IO; +using System.Reflection; using MediaBrowser.Common.Configuration; namespace MediaBrowser.Controller.Configuration @@ -150,5 +151,94 @@ namespace MediaBrowser.Controller.Configuration } } + private string _FFMpegDirectory = null; + /// + /// Gets the folder path to ffmpeg + /// + public string FFMpegDirectory + { + get + { + if (_FFMpegDirectory == null) + { + _FFMpegDirectory = Path.Combine(Kernel.Instance.ApplicationPaths.ProgramDataPath, "FFMpeg"); + + if (!Directory.Exists(_FFMpegDirectory)) + { + Directory.CreateDirectory(_FFMpegDirectory); + } + } + + return _FFMpegDirectory; + } + } + + private string _FFMpegPath = null; + /// + /// Gets the path to ffmpeg.exe + /// + public string FFMpegPath + { + get + { + 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); + } + } + } + + return _FFMpegPath; + } + } + + private string _FFProbePath = null; + /// + /// Gets the path to ffprobe.exe + /// + public string FFProbePath + { + get + { + 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); + } + } + } + + return _FFProbePath; + } + } } } diff --git a/MediaBrowser.Api/ffmpeg/ffmpeg.exe.REMOVED.git-id b/MediaBrowser.Controller/FFMpeg/ffmpeg.exe.REMOVED.git-id similarity index 100% rename from MediaBrowser.Api/ffmpeg/ffmpeg.exe.REMOVED.git-id rename to MediaBrowser.Controller/FFMpeg/ffmpeg.exe.REMOVED.git-id diff --git a/MediaBrowser.Controller/FFMpeg/ffprobe.exe.REMOVED.git-id b/MediaBrowser.Controller/FFMpeg/ffprobe.exe.REMOVED.git-id new file mode 100644 index 000000000..4ad2356c9 --- /dev/null +++ b/MediaBrowser.Controller/FFMpeg/ffprobe.exe.REMOVED.git-id @@ -0,0 +1 @@ +a304265e8410291c1f696e74a4f9b84970bb5753 \ No newline at end of file diff --git a/MediaBrowser.Api/ffmpeg/readme.txt b/MediaBrowser.Controller/FFMpeg/readme.txt similarity index 100% rename from MediaBrowser.Api/ffmpeg/readme.txt rename to MediaBrowser.Controller/FFMpeg/readme.txt diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 3000fd7a0..580b4d7b5 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -79,6 +79,13 @@ + + + + + + +