Skip to content

Commit 02ac7c5

Browse files
committed
FFMpegCore: enable root configuration view ctor
1 parent 7dca87a commit 02ac7c5

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

FFMpegCore/FFMPEG/FFBase.cs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,27 @@ public abstract class FFBase : IDisposable
1414
protected string ConfiguredRoot;
1515
protected Process Process;
1616

17-
protected FFBase()
17+
protected FFBase(FFMpegOptions opts = null)
1818
{
19-
ConfiguredRoot =
20-
!File.Exists(_ConfigFile) ?
21-
_DefaultRoot :
22-
JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(_ConfigFile))["RootDirectory"];
19+
var options = opts;
20+
21+
if (
22+
opts == null &&
23+
File.Exists(_ConfigFile)
24+
)
25+
{
26+
options = JsonConvert.DeserializeObject<FFMpegOptions>(File.ReadAllText(_ConfigFile));
27+
}
28+
29+
if (options == null)
30+
{
31+
options = new FFMpegOptions
32+
{
33+
RootDirectory = _DefaultRoot
34+
};
35+
}
36+
37+
ConfiguredRoot = options.RootDirectory;
2338
}
2439

2540
/// <summary>

FFMpegCore/FFMPEG/FFMpegOptions.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace FFMpegCore.FFMPEG
2+
{
3+
public class FFMpegOptions
4+
{
5+
public string RootDirectory { get; set; }
6+
}
7+
}

0 commit comments

Comments
 (0)