Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added call to GlobalFFOptions.Configure when setting FFprobeFolder. #1333

Merged
merged 4 commits into from
Aug 1, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions SIL.Media/MediaInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public class MediaInfo
/// <exception cref="DirectoryNotFoundException">Folder does not exist</exception>
/// <exception cref="FileNotFoundException">Folder does not contain the ffprobe
/// executable</exception>
/// <exception cref="ArgumentException">FFMpegCore failed to set the requested
/// FFprobe folder.</exception>
/// <remarks>If set to <see cref="Empty"/>, indicates to this library that
/// FFprobe is not installed, and therefore methods to retrieve media info will
/// fail unconditionally (i.e. they will throw an exception)</remarks>
Expand All @@ -51,6 +53,16 @@ public static string FFprobeFolder
throw new FileNotFoundException(
"Path is not a folder containing FFprobe.exe: " + value);
}

GlobalFFOptions.Configure(new FFOptions { BinaryFolder = value });
var testResult = Path.GetDirectoryName(GlobalFFOptions.GetFFProbeBinaryPath());
// Although we would generally be safe to check that the testResult folder is
// equal to the passed-in value, there are several edge cases where that might
// not be quite true, but if it couldn't find FFprobe in the requested folder,
// GetFFProbeBinaryPath just returns the filename with no folder (meaning that
// it expects to find it somewhere on the system path).
if (testResult == null)
throw new ArgumentException("FFMpegCore failed to set the requested FFprobe folder.");
}

s_ffProbeFolder = value;
Expand Down Expand Up @@ -103,16 +115,9 @@ private static string GetPresumedFFprobeFolder()
GetFileDistributedWithApplication(true, "ffmpeg", FFprobeExe) ??
GetFileDistributedWithApplication(true, "ffprobe", FFprobeExe);

folder = !IsNullOrEmpty(withApplicationDirectory) ?
folder = (!IsNullOrEmpty(withApplicationDirectory) ?
Path.GetDirectoryName(withApplicationDirectory) :
GetFFmpegFolderFromChocoInstall(FFprobeExe);

if (folder != null)
{
GlobalFFOptions.Configure(new FFOptions { BinaryFolder = folder });
}
else
folder = Empty;
GetFFmpegFolderFromChocoInstall(FFprobeExe)) ?? Empty;
}
}

Expand Down