diff --git a/FFMpegCore/FFMpegCore.csproj b/FFMpegCore/FFMpegCore.csproj
index 5f7b969..daf7901 100644
--- a/FFMpegCore/FFMpegCore.csproj
+++ b/FFMpegCore/FFMpegCore.csproj
@@ -26,7 +26,7 @@
Always
-
+
diff --git a/FFMpegCore/GlobalFFOptions.cs b/FFMpegCore/GlobalFFOptions.cs
index 358787a..37340cc 100644
--- a/FFMpegCore/GlobalFFOptions.cs
+++ b/FFMpegCore/GlobalFFOptions.cs
@@ -8,27 +8,20 @@ namespace FFMpegCore
public static class GlobalFFOptions
{
private static readonly string ConfigFile = "ffmpeg.config.json";
+ private static FFOptions? _current;
- public static FFOptions Current { get; private set; }
- static GlobalFFOptions()
+ public static FFOptions Current
{
- if (File.Exists(ConfigFile))
- {
- Current = JsonSerializer.Deserialize(File.ReadAllText(ConfigFile))!;
- }
- else
- {
- Current = new FFOptions();
- }
+ get { return _current ??= LoadFFOptions(); }
}
-
+
public static void Configure(Action optionsAction)
{
optionsAction?.Invoke(Current);
}
public static void Configure(FFOptions ffOptions)
{
- Current = ffOptions ?? throw new ArgumentNullException(nameof(ffOptions));
+ _current = ffOptions ?? throw new ArgumentNullException(nameof(ffOptions));
}
@@ -48,5 +41,17 @@ private static string GetFFBinaryPath(string name, FFOptions ffOptions)
return Path.Combine(ffOptions.BinaryFolder, ffName);
}
+
+ private static FFOptions LoadFFOptions()
+ {
+ if (File.Exists(ConfigFile))
+ {
+ return JsonSerializer.Deserialize(File.ReadAllText(ConfigFile))!;
+ }
+ else
+ {
+ return new FFOptions();
+ }
+ }
}
}