瀏覽代碼

Moved ffmpeg to the controller project and added ffprobe

LukePulverenti Luke Pulverenti luke pulverenti 13 年之前
父節點
當前提交
3e86104641

+ 0 - 56
MediaBrowser.Api/ApiService.cs

@@ -197,61 +197,5 @@ namespace MediaBrowser.Api
 
 
             return null;
             return null;
         }
         }
-
-        private static string _FFMpegDirectory = null;
-        /// <summary>
-        /// Gets the folder path to ffmpeg
-        /// </summary>
-        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;
-        /// <summary>
-        /// Gets the path to ffmpeg.exe
-        /// </summary>
-        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;
-            }
-        }
     }
     }
 }
 }

+ 2 - 2
MediaBrowser.Api/HttpHandlers/BaseMediaHandler.cs

@@ -164,8 +164,8 @@ namespace MediaBrowser.Api.HttpHandlers
             startInfo.RedirectStandardOutput = true;
             startInfo.RedirectStandardOutput = true;
             startInfo.RedirectStandardError = 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();
             startInfo.Arguments = GetCommandLineArguments();
 
 
             Logger.LogInfo(startInfo.FileName + " " + startInfo.Arguments);
             Logger.LogInfo(startInfo.FileName + " " + startInfo.Arguments);

+ 0 - 6
MediaBrowser.Api/MediaBrowser.Api.csproj

@@ -86,12 +86,6 @@
       <Name>MediaBrowser.Model</Name>
       <Name>MediaBrowser.Model</Name>
     </ProjectReference>
     </ProjectReference>
   </ItemGroup>
   </ItemGroup>
-  <ItemGroup>
-    <EmbeddedResource Include="FFMpeg\ffmpeg.exe" />
-  </ItemGroup>
-  <ItemGroup>
-    <Content Include="FFMpeg\readme.txt" />
-  </ItemGroup>
   <ItemGroup>
   <ItemGroup>
     <None Include="packages.config" />
     <None Include="packages.config" />
   </ItemGroup>
   </ItemGroup>

+ 90 - 0
MediaBrowser.Controller/Configuration/ServerApplicationPaths.cs

@@ -1,4 +1,5 @@
 using System.IO;
 using System.IO;
+using System.Reflection;
 using MediaBrowser.Common.Configuration;
 using MediaBrowser.Common.Configuration;
 
 
 namespace MediaBrowser.Controller.Configuration
 namespace MediaBrowser.Controller.Configuration
@@ -150,5 +151,94 @@ namespace MediaBrowser.Controller.Configuration
             }
             }
         }
         }
 
 
+        private string _FFMpegDirectory = null;
+        /// <summary>
+        /// Gets the folder path to ffmpeg
+        /// </summary>
+        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;
+        /// <summary>
+        /// Gets the path to ffmpeg.exe
+        /// </summary>
+        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;
+        /// <summary>
+        /// Gets the path to ffprobe.exe
+        /// </summary>
+        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;
+            }
+        }
     }
     }
 }
 }

+ 0 - 0
MediaBrowser.Api/ffmpeg/ffmpeg.exe.REMOVED.git-id → MediaBrowser.Controller/FFMpeg/ffmpeg.exe.REMOVED.git-id


+ 1 - 0
MediaBrowser.Controller/FFMpeg/ffprobe.exe.REMOVED.git-id

@@ -0,0 +1 @@
+a304265e8410291c1f696e74a4f9b84970bb5753

+ 0 - 0
MediaBrowser.Api/ffmpeg/readme.txt → MediaBrowser.Controller/FFMpeg/readme.txt


+ 7 - 0
MediaBrowser.Controller/MediaBrowser.Controller.csproj

@@ -79,6 +79,13 @@
   <ItemGroup>
   <ItemGroup>
     <None Include="packages.config" />
     <None Include="packages.config" />
   </ItemGroup>
   </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="FFMpeg\ffmpeg.exe" />
+  </ItemGroup>
+  <ItemGroup>
+    <EmbeddedResource Include="FFMpeg\ffprobe.exe" />
+    <Content Include="FFMpeg\readme.txt" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.
        Other similar extension points exist, see Microsoft.Common.targets.