mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 08:34:12 +01:00
Merge pull request #49 from WeihanLi/features/raw-argument
add CustomArgument
Former-commit-id: bca5aa9502
This commit is contained in:
commit
fbd3689ce4
2 changed files with 33 additions and 12 deletions
|
@ -9,10 +9,10 @@ namespace FFMpegCore.Test
|
||||||
[TestClass]
|
[TestClass]
|
||||||
public class ArgumentBuilderTest : BaseTest
|
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"};
|
{ "1.mp4", "2.mp4", "3.mp4", "4.mp4"};
|
||||||
|
|
||||||
FFArgumentBuilder builder;
|
private FFArgumentBuilder builder;
|
||||||
|
|
||||||
public ArgumentBuilderTest() : base()
|
public ArgumentBuilderTest() : base()
|
||||||
{
|
{
|
||||||
|
@ -21,7 +21,7 @@ public ArgumentBuilderTest() : base()
|
||||||
|
|
||||||
private string GetArgumentsString(params Argument[] args)
|
private string GetArgumentsString(params Argument[] args)
|
||||||
{
|
{
|
||||||
var container = new ArgumentContainer {new InputArgument("input.mp4")};
|
var container = new ArgumentContainer { new InputArgument("input.mp4") };
|
||||||
foreach (var a in args)
|
foreach (var a in args)
|
||||||
{
|
{
|
||||||
container.Add(a);
|
container.Add(a);
|
||||||
|
@ -31,7 +31,6 @@ private string GetArgumentsString(params Argument[] args)
|
||||||
return builder.BuildArguments(container);
|
return builder.BuildArguments(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Builder_BuildString_IO_1()
|
public void Builder_BuildString_IO_1()
|
||||||
{
|
{
|
||||||
|
@ -80,8 +79,7 @@ public void Builder_BuildString_BitStream()
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Builder_BuildString_Concat()
|
public void Builder_BuildString_Concat()
|
||||||
{
|
{
|
||||||
var container = new ArgumentContainer {new ConcatArgument(concatFiles), new OutputArgument("output.mp4")};
|
var container = new ArgumentContainer { new ConcatArgument(concatFiles), new OutputArgument("output.mp4") };
|
||||||
|
|
||||||
|
|
||||||
var str = builder.BuildArguments(container);
|
var str = builder.BuildArguments(container);
|
||||||
|
|
||||||
|
@ -96,7 +94,6 @@ public void Builder_BuildString_Copy_Audio()
|
||||||
Assert.AreEqual(str, "-i \"input.mp4\" -c:a copy \"output.mp4\"");
|
Assert.AreEqual(str, "-i \"input.mp4\" -c:a copy \"output.mp4\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Builder_BuildString_Copy_Video()
|
public void Builder_BuildString_Copy_Video()
|
||||||
{
|
{
|
||||||
|
@ -188,7 +185,7 @@ public void Builder_BuildString_Speed()
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Builder_BuildString_DrawtextFilter()
|
public void Builder_BuildString_DrawtextFilter()
|
||||||
{
|
{
|
||||||
var str = GetArgumentsString(new DrawTextArgument("Stack Overflow", "/path/to/font.ttf",
|
var str = GetArgumentsString(new DrawTextArgument("Stack Overflow", "/path/to/font.ttf",
|
||||||
("fontcolor", "white"),
|
("fontcolor", "white"),
|
||||||
("fontsize", "24"),
|
("fontsize", "24"),
|
||||||
("box", "1"),
|
("box", "1"),
|
||||||
|
@ -212,7 +209,7 @@ public void Builder_BuildString_StartNumber()
|
||||||
public void Builder_BuildString_Threads_1()
|
public void Builder_BuildString_Threads_1()
|
||||||
{
|
{
|
||||||
var str = GetArgumentsString(new ThreadsArgument(50));
|
var str = GetArgumentsString(new ThreadsArgument(50));
|
||||||
|
|
||||||
Assert.AreEqual(str, "-i \"input.mp4\" -threads 50 \"output.mp4\"");
|
Assert.AreEqual(str, "-i \"input.mp4\" -threads 50 \"output.mp4\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,7 +221,6 @@ public void Builder_BuildString_Threads_2()
|
||||||
Assert.AreEqual(str, $"-i \"input.mp4\" -threads {Environment.ProcessorCount} \"output.mp4\"");
|
Assert.AreEqual(str, $"-i \"input.mp4\" -threads {Environment.ProcessorCount} \"output.mp4\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Builder_BuildString_Codec()
|
public void Builder_BuildString_Codec()
|
||||||
{
|
{
|
||||||
|
@ -242,10 +238,21 @@ public void Builder_BuildString_Codec_Override()
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Builder_BuildString_Duration() {
|
public void Builder_BuildString_Duration()
|
||||||
|
{
|
||||||
var str = GetArgumentsString(new DurationArgument(TimeSpan.FromSeconds(20)));
|
var str = GetArgumentsString(new DurationArgument(TimeSpan.FromSeconds(20)));
|
||||||
|
|
||||||
Assert.AreEqual(str, "-i \"input.mp4\" -t 00:00:20 \"output.mp4\"");
|
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\"");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
14
FFMpegCore/FFMPEG/Argument/Atoms/CustomArgument.cs
Normal file
14
FFMpegCore/FFMPEG/Argument/Atoms/CustomArgument.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue