From aed33a3d5c13f15e4aefa6380833007f069bff10 Mon Sep 17 00:00:00 2001 From: Vlad Jerca Date: Tue, 26 Feb 2019 21:47:11 +0200 Subject: [PATCH] FFMpegCore: support configuration via `ffmpeg.config.json` --- FFMpegCore.Test/FFMpegCore.Test.csproj | 10 ++++++++++ FFMpegCore.Test/ffmpeg.config.json | 3 +++ FFMpegCore/FFMPEG/FFBase.cs | 12 ++++++++++-- README.md | 10 ++++++++++ 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 FFMpegCore.Test/ffmpeg.config.json diff --git a/FFMpegCore.Test/FFMpegCore.Test.csproj b/FFMpegCore.Test/FFMpegCore.Test.csproj index b3defdd..d7fa1ad 100644 --- a/FFMpegCore.Test/FFMpegCore.Test.csproj +++ b/FFMpegCore.Test/FFMpegCore.Test.csproj @@ -6,6 +6,16 @@ false + + + + + + + Always + + + diff --git a/FFMpegCore.Test/ffmpeg.config.json b/FFMpegCore.Test/ffmpeg.config.json new file mode 100644 index 0000000..7d50e79 --- /dev/null +++ b/FFMpegCore.Test/ffmpeg.config.json @@ -0,0 +1,3 @@ +{ + "RootDirectory": ".//FFMPEG//bin" +} \ No newline at end of file diff --git a/FFMpegCore/FFMPEG/FFBase.cs b/FFMpegCore/FFMPEG/FFBase.cs index 03bb3d7..cc52b39 100644 --- a/FFMpegCore/FFMPEG/FFBase.cs +++ b/FFMpegCore/FFMPEG/FFBase.cs @@ -1,17 +1,25 @@ -using System; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; using System.Diagnostics; +using System.IO; using System.Linq; namespace FFMpegCore.FFMPEG { public abstract class FFBase : IDisposable { + private static string _ConfigFile = "./ffmpeg.config.json"; + private static string _DefaultRoot = ".\\FFMPEG\\bin"; protected string ConfiguredRoot; protected Process Process; protected FFBase() { - ConfiguredRoot = ".\\FFMPEG\\bin"; + ConfiguredRoot = + !File.Exists(_ConfigFile) ? + _DefaultRoot : + JsonConvert.DeserializeObject>(File.ReadAllText(_ConfigFile))["RootDirectory"]; } /// diff --git a/README.md b/README.md index 58b322d..9aa2809 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,16 @@ Install-Package FFMpegCore A great way to use FFMpeg encoding when writing video applications, client-side and server-side. It has wrapper methods that allow conversion to all web formats: MP4, OGV, TS and methods of capturing screens from the videos. +### Configuratoin + +The root directory for the ffmpeg binaries can be configured via the `ffmpeg.config.json` file. + +```json +{ + "RootDirectory": ".//FFMPEG//bin" +} +``` + ### FFProbe FFProbe is used to gather video information