From 19856923c68722087f23e5a2f2edce9c2968e220 Mon Sep 17 00:00:00 2001 From: Malte Rosenbjerg Date: Thu, 18 Jun 2020 21:44:45 +0200 Subject: [PATCH] .NET Standard 2.0 support --- FFMpegCore/FFMpeg/Arguments/ConcatArgument.cs | 6 ++++++ FFMpegCore/FFMpeg/Arguments/DemuxConcatArgument.cs | 14 +++++--------- .../FFMpeg/Arguments/IInputOutputArgument.cs | 6 +++--- FFMpegCore/FFMpeg/Arguments/InputArgument.cs | 5 +++++ FFMpegCore/FFMpeg/Arguments/OutputArgument.cs | 3 +++ FFMpegCore/FFMpeg/FFMpegArguments.cs | 4 ++-- FFMpegCore/FFMpeg/FFMpegOptions.cs | 4 ++-- FFMpegCore/FFMpegCore.csproj | 12 +++++------- 8 files changed, 31 insertions(+), 23 deletions(-) diff --git a/FFMpegCore/FFMpeg/Arguments/ConcatArgument.cs b/FFMpegCore/FFMpeg/Arguments/ConcatArgument.cs index b0908b4..d43988f 100644 --- a/FFMpegCore/FFMpeg/Arguments/ConcatArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/ConcatArgument.cs @@ -1,4 +1,6 @@ using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; namespace FFMpegCore.Arguments { @@ -15,6 +17,10 @@ public ConcatArgument(IEnumerable values) Values = values; } + public void Pre() { } + public Task During(CancellationToken? cancellationToken = null) => Task.CompletedTask; + public void Post() { } + public string Text => $"-i \"concat:{string.Join(@"|", Values)}\""; } } diff --git a/FFMpegCore/FFMpeg/Arguments/DemuxConcatArgument.cs b/FFMpegCore/FFMpeg/Arguments/DemuxConcatArgument.cs index 2570db8..1378359 100644 --- a/FFMpegCore/FFMpeg/Arguments/DemuxConcatArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/DemuxConcatArgument.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; using System.IO; +using System.Threading; +using System.Threading.Tasks; namespace FFMpegCore.Arguments { @@ -17,15 +19,9 @@ public DemuxConcatArgument(IEnumerable values) } private readonly string _tempFileName = Path.Combine(FFMpegOptions.Options.TempDirectory, Guid.NewGuid() + ".txt"); - public void Pre() - { - File.WriteAllLines(_tempFileName, Values); - } - - public void Post() - { - File.Delete(_tempFileName); - } + public void Pre() => File.WriteAllLines(_tempFileName, Values); + public Task During(CancellationToken? cancellationToken = null) => Task.CompletedTask; + public void Post() => File.Delete(_tempFileName); public string Text => $"-f concat -safe 0 -i \"{_tempFileName}\""; } diff --git a/FFMpegCore/FFMpeg/Arguments/IInputOutputArgument.cs b/FFMpegCore/FFMpeg/Arguments/IInputOutputArgument.cs index 939cc3f..6998d5c 100644 --- a/FFMpegCore/FFMpeg/Arguments/IInputOutputArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/IInputOutputArgument.cs @@ -5,8 +5,8 @@ namespace FFMpegCore.Arguments { public interface IInputOutputArgument : IArgument { - void Pre() {} - Task During(CancellationToken? cancellationToken = null) => Task.CompletedTask; - void Post() {} + void Pre(); + Task During(CancellationToken? cancellationToken = null); + void Post(); } } \ No newline at end of file diff --git a/FFMpegCore/FFMpeg/Arguments/InputArgument.cs b/FFMpegCore/FFMpeg/Arguments/InputArgument.cs index 57d8ffe..0ff4bd8 100644 --- a/FFMpegCore/FFMpeg/Arguments/InputArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/InputArgument.cs @@ -1,6 +1,8 @@ using System; using System.IO; using System.Linq; +using System.Threading; +using System.Threading.Tasks; namespace FFMpegCore.Arguments { @@ -34,6 +36,9 @@ public void Pre() } } + public Task During(CancellationToken? cancellationToken = null) => Task.CompletedTask; + public void Post() { } + public string Text => string.Join(" ", FilePaths.Select(v => $"-i \"{v}\"")); } } diff --git a/FFMpegCore/FFMpeg/Arguments/OutputArgument.cs b/FFMpegCore/FFMpeg/Arguments/OutputArgument.cs index 5a53886..1321402 100644 --- a/FFMpegCore/FFMpeg/Arguments/OutputArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/OutputArgument.cs @@ -1,5 +1,7 @@ using System; using System.IO; +using System.Threading; +using System.Threading.Tasks; using FFMpegCore.Exceptions; namespace FFMpegCore.Arguments @@ -23,6 +25,7 @@ public void Pre() if (!Overwrite && File.Exists(Path)) throw new FFMpegException(FFMpegExceptionType.File, "Output file already exists and overwrite is disabled"); } + public Task During(CancellationToken? cancellationToken = null) => Task.CompletedTask; public void Post() { if (!File.Exists(Path)) diff --git a/FFMpegCore/FFMpeg/FFMpegArguments.cs b/FFMpegCore/FFMpeg/FFMpegArguments.cs index d3b900c..09e1019 100644 --- a/FFMpegCore/FFMpeg/FFMpegArguments.cs +++ b/FFMpegCore/FFMpeg/FFMpegArguments.cs @@ -32,7 +32,7 @@ private FFMpegArguments(IInputArgument inputArgument) public static FFMpegArguments FromInputFiles(params FileInfo[] files) => new FFMpegArguments(new InputArgument(false, files)); public static FFMpegArguments FromInputFiles(bool verifyExists, params FileInfo[] files) => new FFMpegArguments(new InputArgument(verifyExists, files)); public static FFMpegArguments FromConcatenation(params string[] files) => new FFMpegArguments(new ConcatArgument(files)); - public static FFMpegArguments FromDemuxConcatenation(params string[] files) => new FFMpegArguments(new ConcatArgument(files)); + public static FFMpegArguments FromDemuxConcatenation(params string[] files) => new FFMpegArguments(new DemuxConcatArgument(files)); public static FFMpegArguments FromPipe(IPipeSource writer) => new FFMpegArguments(new InputPipeArgument(writer)); @@ -117,7 +117,7 @@ internal void Post() _outputArgument.Post(); } - public TArgument? Find() where TArgument : class, IArgument + public TArgument Find() where TArgument : class, IArgument { return _arguments.FirstOrDefault(arg => arg is TArgument) as TArgument; } diff --git a/FFMpegCore/FFMpeg/FFMpegOptions.cs b/FFMpegCore/FFMpeg/FFMpegOptions.cs index 426b844..8a98a0a 100644 --- a/FFMpegCore/FFMpeg/FFMpegOptions.cs +++ b/FFMpegCore/FFMpeg/FFMpegOptions.cs @@ -33,8 +33,8 @@ static FFMpegOptions() if (File.Exists(ConfigFile)) { Options = JsonSerializer.Deserialize(File.ReadAllText(ConfigFile)); - foreach (var (key, value) in DefaultExtensionsOverrides) - if (!Options.ExtensionOverrides.ContainsKey(key)) Options.ExtensionOverrides.Add(key, value); + foreach (var pair in DefaultExtensionsOverrides) + if (!Options.ExtensionOverrides.ContainsKey(pair.Key)) Options.ExtensionOverrides.Add(pair.Key, pair.Value); } } diff --git a/FFMpegCore/FFMpegCore.csproj b/FFMpegCore/FFMpegCore.csproj index b7a84c6..8b17892 100644 --- a/FFMpegCore/FFMpegCore.csproj +++ b/FFMpegCore/FFMpegCore.csproj @@ -1,7 +1,6 @@  - netstandard2.1 en https://github.com/rosenbjerg/FFMpegCore https://github.com/rosenbjerg/FFMpegCore @@ -10,14 +9,17 @@ 1.0.12 1.1.0.0 1.1.0.0 - Fix null reference exception in ParseAudioStream (#67) + - Support for .NET Standard 2.0 +- Minor fixes +- DemuxConcatArgument 8 - 2.0.1 + 2.1.0 Vlad Jerca, Malte Rosenbjerg ffmpeg ffprobe convert video audio mediafile resize analyze muxing GitHub true enable + netstandard2.0 @@ -32,8 +34,4 @@ - - - -