Skip to content

Commit

Permalink
search the path for ffmpeg
Browse files Browse the repository at this point in the history
  • Loading branch information
hahn-kev committed Nov 18, 2024
1 parent 43cbcd6 commit 6d7fb90
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion SIL.Media/FFmpegRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class FFmpegRunner
/// If your app knows where FFmpeg lives, you can tell us before making any calls.
/// </summary>
public static string FFmpegLocation;
private static bool? _ffmpegOnPath;

/// <summary>
/// Find the path to FFmpeg, and remember it (some apps (like SayMore) call FFmpeg a lot)
Expand Down Expand Up @@ -96,7 +97,23 @@ private static string LocateFFmpeg()
if (File.Exists(exePath))
return exePath;
}
return null;

//Locate may be called multiple times, we don't want to run this command every time.
if (_ffmpegOnPath == null)
{
try
{
//try to just run ffmpeg from the path, if it works then we can use that directly.
var results = CommandLineRunner.Run("ffmpeg", "-version", ".", 5, new NullProgress());
_ffmpegOnPath = results.StandardOutput
.Contains("ffmpeg version");
}
catch
{
_ffmpegOnPath = false;
}
}
return _ffmpegOnPath.Value ? "ffmpeg" : null;
}

private static string GetPathToBundledFFmpeg()
Expand Down

0 comments on commit 6d7fb90

Please sign in to comment.