Skip to content

Commit

Permalink
Merge branch 'master' into sil.windows.forms.archiving
Browse files Browse the repository at this point in the history
  • Loading branch information
tombogle committed Aug 1, 2024
2 parents 23cd3e0 + 269c813 commit 414f7ef
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions SIL.Media/MediaInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@ public class MediaInfo

/// <summary>
/// The folder where FFprobe should be found. An application can use this to set
/// the location before making any calls.
/// the location before making calls to obtain media info. Note that this sets a global
/// setting in FFmpegCore. If the application uses FFmpegCore to call FFprobe or FFmpeg
/// for other purposes, this folder will also be used for those calls.
/// </summary>
/// <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 +55,16 @@ public static string FFprobeFolder
throw new FileNotFoundException(
"Path is not a folder containing FFprobe.exe: " + value);
}

// Configure tells FFMpegCore to remember the folder where it should find
// FFprobe (and also FFmpeg).
GlobalFFOptions.Configure(new FFOptions { BinaryFolder = value });
var testResult = Path.GetDirectoryName(GlobalFFOptions.GetFFProbeBinaryPath());
// If it couldn't find FFprobe in the requested folder, GetFFProbeBinaryPath
// returns the filename with no folder (meaning that it hopes 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 +117,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

0 comments on commit 414f7ef

Please sign in to comment.