From 5643544a3b7ff082f84285df1014856f85a511c6 Mon Sep 17 00:00:00 2001 From: weihanli Date: Tue, 28 Apr 2020 12:26:42 +0800 Subject: [PATCH] add RawArgument.cs --- FFMpegCore.Test/ArgumentBuilderTest.cs | 31 ++++++++++++------- .../FFMPEG/Argument/Atoms/RawArgument.cs | 14 +++++++++ 2 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 FFMpegCore/FFMPEG/Argument/Atoms/RawArgument.cs diff --git a/FFMpegCore.Test/ArgumentBuilderTest.cs b/FFMpegCore.Test/ArgumentBuilderTest.cs index cde8da2..38066c5 100644 --- a/FFMpegCore.Test/ArgumentBuilderTest.cs +++ b/FFMpegCore.Test/ArgumentBuilderTest.cs @@ -9,10 +9,10 @@ namespace FFMpegCore.Test [TestClass] public class ArgumentBuilderTest : BaseTest { - List concatFiles = new List + private List concatFiles = new List { "1.mp4", "2.mp4", "3.mp4", "4.mp4"}; - FFArgumentBuilder builder; + private FFArgumentBuilder builder; public ArgumentBuilderTest() : base() { @@ -21,7 +21,7 @@ public ArgumentBuilderTest() : base() 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) { container.Add(a); @@ -31,7 +31,6 @@ private string GetArgumentsString(params Argument[] args) return builder.BuildArguments(container); } - [TestMethod] public void Builder_BuildString_IO_1() { @@ -66,8 +65,7 @@ public void Builder_BuildString_BitStream() [TestMethod] 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); @@ -82,7 +80,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() { @@ -174,7 +171,7 @@ public void Builder_BuildString_Speed() [TestMethod] 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"), ("fontsize", "24"), ("box", "1"), @@ -198,7 +195,7 @@ public void Builder_BuildString_StartNumber() public void Builder_BuildString_Threads_1() { var str = GetArgumentsString(new ThreadsArgument(50)); - + Assert.AreEqual(str, "-i \"input.mp4\" -threads 50 \"output.mp4\""); } @@ -210,7 +207,6 @@ public void Builder_BuildString_Threads_2() Assert.AreEqual(str, $"-i \"input.mp4\" -threads {Environment.ProcessorCount} \"output.mp4\""); } - [TestMethod] public void Builder_BuildString_Codec() { @@ -228,10 +224,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 RawArgument(null)); + Assert.AreEqual(str, "-i \"input.mp4\" \"output.mp4\""); + + str = GetArgumentsString(new RawArgument("-acodec copy")); + Assert.AreEqual(str, "-i \"input.mp4\" -acodec copy \"output.mp4\""); + } } -} +} \ No newline at end of file diff --git a/FFMpegCore/FFMPEG/Argument/Atoms/RawArgument.cs b/FFMpegCore/FFMPEG/Argument/Atoms/RawArgument.cs new file mode 100644 index 0000000..74a9df6 --- /dev/null +++ b/FFMpegCore/FFMPEG/Argument/Atoms/RawArgument.cs @@ -0,0 +1,14 @@ +namespace FFMpegCore.FFMPEG.Argument +{ + public class RawArgument : Argument + { + public RawArgument(string argument) : base(argument) + { + } + + public override string GetStringValue() + { + return Value ?? string.Empty; + } + } +} \ No newline at end of file