.NET Standard 2.0 support

Former-commit-id: 19856923c6
This commit is contained in:
Malte Rosenbjerg 2020-06-18 21:44:45 +02:00
parent c3a2104d84
commit 4e0ee69348
8 changed files with 31 additions and 23 deletions

View file

@ -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<string> 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)}\"";
}
}

View file

@ -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<string> 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}\"";
}

View file

@ -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();
}
}

View file

@ -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}\""));
}
}

View file

@ -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))

View file

@ -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<TArgument>() where TArgument : class, IArgument
public TArgument Find<TArgument>() where TArgument : class, IArgument
{
return _arguments.FirstOrDefault(arg => arg is TArgument) as TArgument;
}

View file

@ -33,8 +33,8 @@ static FFMpegOptions()
if (File.Exists(ConfigFile))
{
Options = JsonSerializer.Deserialize<FFMpegOptions>(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);
}
}

View file

@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<NeutralLanguage>en</NeutralLanguage>
<RepositoryUrl>https://github.com/rosenbjerg/FFMpegCore</RepositoryUrl>
<PackageProjectUrl>https://github.com/rosenbjerg/FFMpegCore</PackageProjectUrl>
@ -10,14 +9,17 @@
<Version>1.0.12</Version>
<AssemblyVersion>1.1.0.0</AssemblyVersion>
<FileVersion>1.1.0.0</FileVersion>
<PackageReleaseNotes>Fix null reference exception in ParseAudioStream (#67)</PackageReleaseNotes>
<PackageReleaseNotes>- Support for .NET Standard 2.0
- Minor fixes
- DemuxConcatArgument</PackageReleaseNotes>
<LangVersion>8</LangVersion>
<PackageVersion>2.0.1</PackageVersion>
<PackageVersion>2.1.0</PackageVersion>
<Authors>Vlad Jerca, Malte Rosenbjerg</Authors>
<PackageTags>ffmpeg ffprobe convert video audio mediafile resize analyze muxing</PackageTags>
<RepositoryType>GitHub</RepositoryType>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Nullable>enable</Nullable>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
@ -32,8 +34,4 @@
<PackageReference Include="System.Text.Json" Version="4.7.1" />
</ItemGroup>
<ItemGroup>
<Folder Include="FFMpeg\Models\" />
</ItemGroup>
</Project>