From d8b2cbe3ca4d9c2be1d13365da35226e6ed33ea3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=91=D0=B0=D0=B3?= =?UTF-8?q?=D1=80=D1=8F=D0=BD=D1=86=D0=B5=D0=B2?= Date: Thu, 30 Apr 2020 14:46:20 +0300 Subject: [PATCH] Added Fluent API methods for ArgumentContainer --- .../ArgumentContainerFluentExtensions.cs | 331 ++++++++++++++++++ 1 file changed, 331 insertions(+) create mode 100644 FFMpegCore/FFMPEG/Argument/ArgumentContainerFluentExtensions.cs diff --git a/FFMpegCore/FFMPEG/Argument/ArgumentContainerFluentExtensions.cs b/FFMpegCore/FFMPEG/Argument/ArgumentContainerFluentExtensions.cs new file mode 100644 index 0000000..4e8cc98 --- /dev/null +++ b/FFMpegCore/FFMPEG/Argument/ArgumentContainerFluentExtensions.cs @@ -0,0 +1,331 @@ +using FFMpegCore.FFMPEG.Enums; +using System; +using System.Collections.Generic; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Text; + +namespace FFMpegCore.FFMPEG.Argument.Fluent +{ + public static class ArgumentContainerFluentExtensions + { + public static ArgumentContainer AudioCodec(this ArgumentContainer container, AudioCodec codec) + { + container.Add(new AudioCodecArgument(codec)); + return container; + } + + public static ArgumentContainer AudioCodec(this ArgumentContainer container, AudioCodec codec, AudioQuality bitrate) + { + container.Add(new AudioCodecArgument(codec, bitrate)); + return container; + } + + public static ArgumentContainer AudioCodec(this ArgumentContainer container, AudioCodec codec, int bitrate) + { + container.Add(new AudioCodecArgument(codec, bitrate)); + return container; + } + + public static ArgumentContainer AudioSamplingRate(this ArgumentContainer container) + { + container.Add(new AudioSamplingRateArgument()); + return container; + } + + public static ArgumentContainer AudioSamplingRate(this ArgumentContainer container, int sampleRate) + { + container.Add(new AudioSamplingRateArgument(sampleRate)); + return container; + } + + public static ArgumentContainer BitStreamFilter(this ArgumentContainer container, Channel first, Filter second) + { + container.Add(new BitStreamFilterArgument(first, second)); + return container; + } + + public static ArgumentContainer Concat(this ArgumentContainer container, IEnumerable paths) + { + container.Add(new ConcatArgument(paths)); + return container; + } + + public static ArgumentContainer ConstantRateFactor(this ArgumentContainer container, int crf) + { + container.Add(new ConstantRateFactorArgument(crf)); + return container; + } + + public static ArgumentContainer Copy(this ArgumentContainer container) + { + container.Add(new CopyArgument()); + return container; + } + + public static ArgumentContainer Copy(this ArgumentContainer container, Channel value) + { + container.Add(new CopyArgument(value)); + return container; + } + + public static ArgumentContainer CpuSpeed(this ArgumentContainer container, int value) + { + container.Add(new CpuSpeedArgument(value)); + return container; + } + + public static ArgumentContainer DisableChannel(this ArgumentContainer container, Channel channel) + { + container.Add(new DisableChannelArgument(channel)); + return container; + } + + public static ArgumentContainer DrawText(this ArgumentContainer container, string text, string fontPath, params (string, string)[] optionalArguments) + { + container.Add(new DrawTextArgument(text, fontPath, optionalArguments)); + return container; + } + + public static ArgumentContainer Duration(this ArgumentContainer container, TimeSpan? duration) + { + container.Add(new DurationArgument(duration)); + return container; + } + + public static ArgumentContainer FastStart(this ArgumentContainer container) + { + container.Add(new FaststartArgument()); + return container; + } + + public static ArgumentContainer ForceFormat(this ArgumentContainer container, VideoCodec codec) + { + container.Add(new ForceFormatArgument(codec)); + return container; + } + + public static ArgumentContainer FrameOutputCount(this ArgumentContainer container, int count) + { + container.Add(new FrameOutputCountArgument(count)); + return container; + } + + public static ArgumentContainer FrameRate(this ArgumentContainer container, double framerate) + { + container.Add(new FrameRateArgument(framerate)); + return container; + } + + public static ArgumentContainer Input(this ArgumentContainer container, string path) + { + container.Add(new InputArgument(path)); + return container; + } + + public static ArgumentContainer Input(this ArgumentContainer container, IEnumerable paths) + { + container.Add(new InputArgument(paths.ToArray())); + return container; + } + + public static ArgumentContainer Input(this ArgumentContainer container, params string[] paths) + { + container.Add(new InputArgument(paths)); + return container; + } + + public static ArgumentContainer Input(this ArgumentContainer container, VideoInfo path) + { + container.Add(new InputArgument(path)); + return container; + } + + public static ArgumentContainer Input(this ArgumentContainer container, IEnumerable paths) + { + container.Add(new InputArgument(paths.ToArray())); + return container; + } + + public static ArgumentContainer Input(this ArgumentContainer container, params VideoInfo[] paths) + { + container.Add(new InputArgument(paths)); + return container; + } + + public static ArgumentContainer Input(this ArgumentContainer container, FileInfo path) + { + container.Add(new InputArgument(path)); + return container; + } + + public static ArgumentContainer Input(this ArgumentContainer container, IEnumerable paths) + { + container.Add(new InputArgument(paths.ToArray())); + return container; + } + + public static ArgumentContainer Input(this ArgumentContainer container, params FileInfo[] paths) + { + container.Add(new InputArgument(paths)); + return container; + } + + public static ArgumentContainer Input(this ArgumentContainer container, Uri uri) + { + container.Add(new InputArgument(uri)); + return container; + } + + public static ArgumentContainer Input(this ArgumentContainer container, IEnumerable uris) + { + container.Add(new InputArgument(uris.ToArray())); + return container; + } + + public static ArgumentContainer Input(this ArgumentContainer container, params Uri[] uris) + { + container.Add(new InputArgument(uris)); + return container; + } + + public static ArgumentContainer Loop(this ArgumentContainer container, int times) + { + container.Add(new LoopArgument(times)); + return container; + } + + public static ArgumentContainer Output(this ArgumentContainer container, string path) + { + container.Add(new OutputArgument(path)); + return container; + } + + public static ArgumentContainer Output(this ArgumentContainer container, VideoInfo path) + { + container.Add(new OutputArgument(path)); + return container; + } + + public static ArgumentContainer Output(this ArgumentContainer container, FileInfo path) + { + container.Add(new OutputArgument(path)); + return container; + } + + public static ArgumentContainer Output(this ArgumentContainer container, Uri path) + { + container.Add(new OutputArgument(path)); + return container; + } + + public static ArgumentContainer Override(this ArgumentContainer container) + { + container.Add(new OverrideArgument()); + return container; + } + + public static ArgumentContainer RemoveMetadata(this ArgumentContainer container) + { + container.Add(new RemoveMetadataArgument()); + return container; + } + + public static ArgumentContainer Scale(this ArgumentContainer container, Size value) + { + container.Add(new ScaleArgument(value)); + return container; + } + + public static ArgumentContainer Scale(this ArgumentContainer container, VideoSize value) + { + container.Add(new ScaleArgument(value)); + return container; + } + + public static ArgumentContainer Scale(this ArgumentContainer container, int width, int height) + { + container.Add(new ScaleArgument(width, height)); + return container; + } + + public static ArgumentContainer Seek(this ArgumentContainer container, TimeSpan? value) + { + container.Add(new SeekArgument(value)); + return container; + } + + public static ArgumentContainer Shortest(this ArgumentContainer container) + { + container.Add(new ShortestArgument(true)); + return container; + } + + public static ArgumentContainer Size(this ArgumentContainer container, Size value) + { + container.Add(new SizeArgument(value)); + return container; + } + + public static ArgumentContainer Size(this ArgumentContainer container, VideoSize value) + { + container.Add(new SizeArgument(value)); + return container; + } + + public static ArgumentContainer Size(this ArgumentContainer container, int width, int height) + { + container.Add(new SizeArgument(width, height)); + return container; + } + + public static ArgumentContainer Speed(this ArgumentContainer container, Speed value) + { + container.Add(new SpeedArgument(value)); + return container; + } + + public static ArgumentContainer StartNumber(this ArgumentContainer container, int value) + { + container.Add(new StartNumberArgument(value)); + return container; + } + + public static ArgumentContainer Threads(this ArgumentContainer container, int value) + { + container.Add(new ThreadsArgument(value)); + return container; + } + + public static ArgumentContainer MultiThreaded(this ArgumentContainer container) + { + container.Add(new ThreadsArgument(true)); + return container; + } + + public static ArgumentContainer Transpose(this ArgumentContainer container, int transpose) + { + container.Add(new TransposeArgument(transpose)); + return container; + } + + public static ArgumentContainer VariableBitRate(this ArgumentContainer container, int vbr) + { + container.Add(new VariableBitRateArgument(vbr)); + return container; + } + + public static ArgumentContainer VideoCodec(this ArgumentContainer container, VideoCodec codec) + { + container.Add(new VideoCodecArgument(codec)); + return container; + } + + public static ArgumentContainer VideoCodec(this ArgumentContainer container, VideoCodec codec, int bitrate) + { + container.Add(new VideoCodecArgument(codec, bitrate)); + return container; + } + } +}