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: Moved ffmpeg to the controller project and added ffprobe --- .../Configuration/ServerApplicationPaths.cs | 90 ++++++++++++++++++++++ 1 file changed, 90 insertions(+) (limited to 'MediaBrowser.Controller/Configuration/ServerApplicationPaths.cs') 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; + } + } } } -- cgit v1.2.3