弹来弹去跑马灯!

C# 判断是否安装了ffmpeg

C# 判断是否安装了ffmpeg

internal  static bool IsFfmpegInstalled()
 {
     try
     {
         ProcessStartInfo startInfo = new ProcessStartInfo
         {
             FileName = "ffmpeg",
             Arguments = "-version",
             RedirectStandardOutput = true,
             RedirectStandardError = true,
             UseShellExecute = false,
             CreateNoWindow = true
         };

         using (Process process = Process.Start(startInfo))
         {
             process.WaitForExit();
             string output = process.StandardOutput.ReadToEnd();
             string error = process.StandardError.ReadToEnd();

             if (process.ExitCode == 0 && !string.IsNullOrEmpty(output))
             {
                 return true;
             }
         }
     }
     catch
     {
         // 如果发生异常,说明ffmpeg未安装或无法运行
         return false;
     }

     return false;
 }

  

posted @ 2025-03-18 16:42  wgscd  阅读(14)  评论(0)    收藏  举报