Merge branch 'master' into clean-dependency

This commit is contained in:
Weihan Li 2020-05-02 18:14:03 +08:00 committed by GitHub
commit 398184225b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 12 deletions

View file

@ -9,10 +9,10 @@ namespace FFMpegCore.Test
[TestClass]
public class ArgumentBuilderTest : BaseTest
{
List<string> concatFiles = new List<string>
private List<string> concatFiles = new List<string>
{ "1.mp4", "2.mp4", "3.mp4", "4.mp4"};
FFArgumentBuilder builder;
private FFArgumentBuilder builder;
public ArgumentBuilderTest() : base()
{
@ -31,7 +31,6 @@ private string GetArgumentsString(params Argument[] args)
return builder.BuildArguments(container);
}
[TestMethod]
public void Builder_BuildString_IO_1()
{
@ -82,7 +81,6 @@ public void Builder_BuildString_Concat()
{
var container = new ArgumentContainer { new ConcatArgument(concatFiles), new OutputArgument("output.mp4") };
var str = builder.BuildArguments(container);
Assert.AreEqual(str, "-i \"concat:1.mp4|2.mp4|3.mp4|4.mp4\" \"output.mp4\"");
@ -96,7 +94,6 @@ public void Builder_BuildString_Copy_Audio()
Assert.AreEqual(str, "-i \"input.mp4\" -c:a copy \"output.mp4\"");
}
[TestMethod]
public void Builder_BuildString_Copy_Video()
{
@ -224,7 +221,6 @@ public void Builder_BuildString_Threads_2()
Assert.AreEqual(str, $"-i \"input.mp4\" -threads {Environment.ProcessorCount} \"output.mp4\"");
}
[TestMethod]
public void Builder_BuildString_Codec()
{
@ -242,10 +238,21 @@ public void Builder_BuildString_Codec_Override()
}
[TestMethod]
public void Builder_BuildString_Duration() {
public void Builder_BuildString_Duration()
{
var str = GetArgumentsString(new DurationArgument(TimeSpan.FromSeconds(20)));
Assert.AreEqual(str, "-i \"input.mp4\" -t 00:00:20 \"output.mp4\"");
}
[TestMethod]
public void Builder_BuildString_Raw()
{
var str = GetArgumentsString(new CustomArgument(null));
Assert.AreEqual(str, "-i \"input.mp4\" \"output.mp4\"");
str = GetArgumentsString(new CustomArgument("-acodec copy"));
Assert.AreEqual(str, "-i \"input.mp4\" -acodec copy \"output.mp4\"");
}
}
}

View file

@ -0,0 +1,14 @@
namespace FFMpegCore.FFMPEG.Argument
{
public class CustomArgument : Argument<string>
{
public CustomArgument(string argument) : base(argument)
{
}
public override string GetStringValue()
{
return Value ?? string.Empty;
}
}
}