From c3b5cd997e10b4c79eaa8bec169858f88fbd5757 Mon Sep 17 00:00:00 2001 From: Malte Rosenbjerg Date: Sat, 9 May 2020 17:53:03 +0200 Subject: [PATCH] Cleanup Former-commit-id: 72366d573a3bce1428f7daa8d2f2aff11ead9e7f --- FFMpegCore.Test/ArgumentBuilderTest.cs | 88 ++++++++++++++++++- FFMpegCore.Test/AudioTest.cs | 2 - FFMpegCore.Test/BaseTest.cs | 3 +- FFMpegCore.Test/BitmapSources.cs | 2 +- FFMpegCore.Test/FFMpegOptions.cs | 3 +- FFMpegCore.Test/FFProbeTests.cs | 30 ++++++- FFMpegCore.Test/VideoTest.cs | 8 +- FFMpegCore/Enums/FileExtension.cs | 5 +- FFMpegCore/Extend/BitmapExtensions.cs | 1 - FFMpegCore/Extend/BitmapVideoFrameWrapper.cs | 7 +- FFMpegCore/Extend/UriExtensions.cs | 1 - .../FFMpeg/Arguments/AudioBitrateArgument.cs | 4 +- .../FFMpeg/Arguments/AudioCodecArgument.cs | 4 +- .../Arguments/AudioSamplingRateArgument.cs | 2 +- .../Arguments/BitStreamFilterArgument.cs | 4 +- FFMpegCore/FFMpeg/Arguments/ConcatArgument.cs | 2 +- .../Arguments/ConstantRateFactorArgument.cs | 2 +- FFMpegCore/FFMpeg/Arguments/CopyArgument.cs | 4 +- .../FFMpeg/Arguments/CpuSpeedArgument.cs | 2 +- FFMpegCore/FFMpeg/Arguments/CustomArgument.cs | 2 +- .../Arguments/DisableChannelArgument.cs | 6 +- .../FFMpeg/Arguments/DrawTextArgument.cs | 7 +- .../FFMpeg/Arguments/DurationArgument.cs | 2 +- .../FFMpeg/Arguments/FaststartArgument.cs | 2 +- .../FFMpeg/Arguments/ForceFormatArgument.cs | 4 +- .../Arguments/FrameOutputCountArgument.cs | 4 +- .../FFMpeg/Arguments/FrameRateArgument.cs | 2 +- FFMpegCore/FFMpeg/Arguments/InputArgument.cs | 22 +++-- .../FFMpeg/Arguments/InputPipeArgument.cs | 4 +- FFMpegCore/FFMpeg/Arguments/LoopArgument.cs | 2 +- FFMpegCore/FFMpeg/Arguments/OutputArgument.cs | 4 +- .../FFMpeg/Arguments/OutputPipeArgument.cs | 4 +- .../FFMpeg/Arguments/OverwriteArgument.cs | 2 +- FFMpegCore/FFMpeg/Arguments/PipeArgument.cs | 4 +- FFMpegCore/FFMpeg/Arguments/QuietArgument.cs | 2 +- .../Arguments/RemoveMetadataArgument.cs | 2 +- FFMpegCore/FFMpeg/Arguments/ScaleArgument.cs | 4 +- FFMpegCore/FFMpeg/Arguments/SeekArgument.cs | 2 +- .../FFMpeg/Arguments/ShortestArgument.cs | 2 +- FFMpegCore/FFMpeg/Arguments/SizeArgument.cs | 4 +- .../FFMpeg/Arguments/SpeedPresetArgument.cs | 4 +- .../FFMpeg/Arguments/StartNumberArgument.cs | 2 +- .../FFMpeg/Arguments/ThreadsArgument.cs | 2 +- .../FFMpeg/Arguments/TransposeArgument.cs | 4 +- .../Arguments/VariableBitRateArgument.cs | 2 +- .../FFMpeg/Arguments/VideoBitrateArgument.cs | 2 +- .../FFMpeg/Arguments/VideoCodecArgument.cs | 4 +- FFMpegCore/FFMpeg/Enums/AudioQuality.cs | 2 +- FFMpegCore/FFMpeg/Enums/Codec.cs | 2 +- FFMpegCore/FFMpeg/Enums/Speed.cs | 2 +- FFMpegCore/FFMpeg/Enums/Transposition.cs | 2 +- FFMpegCore/FFMpeg/Enums/VideoSize.cs | 2 +- .../FFMpeg/Exceptions/FFMpegException.cs | 2 +- FFMpegCore/FFMpeg/FFMpeg.cs | 6 +- FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs | 2 +- FFMpegCore/FFMpeg/FFMpegArguments.cs | 9 +- FFMpegCore/FFMpeg/FFMpegOptions.cs | 2 +- FFMpegCore/FFMpeg/Pipes/IPipeDataReader.cs | 2 +- FFMpegCore/FFMpeg/Pipes/IPipeDataWriter.cs | 2 +- FFMpegCore/FFMpeg/Pipes/IVideoFrame.cs | 2 +- FFMpegCore/FFMpeg/Pipes/PipeHelpers.cs | 10 ++- .../FFMpeg/Pipes/RawVideoPipeDataWriter.cs | 4 +- .../FFMpeg/Pipes/StreamPipeDataReader.cs | 2 +- .../FFMpeg/Pipes/StreamPipeDataWriter.cs | 2 +- FFMpegCore/FFMpegCore.csproj.DotSettings | 3 + FFMpegCore/FFProbe/AudioStream.cs | 2 +- FFMpegCore/FFProbe/FFProbe.cs | 8 +- FFMpegCore/FFProbe/FFProbeAnalysis.cs | 5 +- FFMpegCore/FFProbe/MediaAnalysis.cs | 10 +-- FFMpegCore/FFProbe/MediaStream.cs | 2 +- FFMpegCore/FFProbe/VideoStream.cs | 4 +- FFMpegCore/Helpers/FFMpegHelper.cs | 3 +- FFMpegCore/Helpers/FFProbeHelper.cs | 2 +- 73 files changed, 238 insertions(+), 137 deletions(-) create mode 100644 FFMpegCore/FFMpegCore.csproj.DotSettings diff --git a/FFMpegCore.Test/ArgumentBuilderTest.cs b/FFMpegCore.Test/ArgumentBuilderTest.cs index 76a0281..97f1db3 100644 --- a/FFMpegCore.Test/ArgumentBuilderTest.cs +++ b/FFMpegCore.Test/ArgumentBuilderTest.cs @@ -1,7 +1,7 @@ -using FFMpegCore.FFMPEG.Argument; -using FFMpegCore.FFMPEG.Enums; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; using System; +using FFMpegCore.Arguments; +using FFMpegCore.Enums; namespace FFMpegCore.Test { @@ -89,6 +89,76 @@ public void Builder_BuildString_Copy_Both() Assert.AreEqual("-i \"input.mp4\" -c copy \"output.mp4\"", str); } + [TestMethod] + public void Builder_BuildString_DisableChannel_Audio() + { + var str = FFMpegArguments.FromInputFiles(true, "input.mp4").DisableChannel(Channel.Audio).OutputToFile("output.mp4").Arguments; + Assert.AreEqual("-i \"input.mp4\" -an \"output.mp4\"", str); + } + + [TestMethod] + public void Builder_BuildString_DisableChannel_Video() + { + var str = FFMpegArguments.FromInputFiles(true, "input.mp4").DisableChannel(Channel.Video).OutputToFile("output.mp4").Arguments; + Assert.AreEqual("-i \"input.mp4\" -vn \"output.mp4\"", str); + } + + [TestMethod] + public void Builder_BuildString_DisableChannel_Both() + { + var str = FFMpegArguments.FromInputFiles(true, "input.mp4").DisableChannel(Channel.Both).OutputToFile("output.mp4").Arguments; + Assert.AreEqual("-i \"input.mp4\" \"output.mp4\"", str); + } + + [TestMethod] + public void Builder_BuildString_AudioSamplingRate_Default() + { + var str = FFMpegArguments.FromInputFiles(true, "input.mp4").WithAudioSamplingRate().OutputToFile("output.mp4").Arguments; + Assert.AreEqual("-i \"input.mp4\" -ar 48000 \"output.mp4\"", str); + } + + [TestMethod] + public void Builder_BuildString_AudioSamplingRate() + { + var str = FFMpegArguments.FromInputFiles(true, "input.mp4").WithAudioSamplingRate(44000).OutputToFile("output.mp4").Arguments; + Assert.AreEqual("-i \"input.mp4\" -ar 44000 \"output.mp4\"", str); + } + + [TestMethod] + public void Builder_BuildString_VariableBitrate() + { + var str = FFMpegArguments.FromInputFiles(true, "input.mp4").WithVariableBitrate(5).OutputToFile("output.mp4").Arguments; + Assert.AreEqual("-i \"input.mp4\" -vbr 5 \"output.mp4\"", str); + } + + [TestMethod] + public void Builder_BuildString_Faststart() + { + var str = FFMpegArguments.FromInputFiles(true, "input.mp4").WithFastStart().OutputToFile("output.mp4").Arguments; + Assert.AreEqual("-i \"input.mp4\" -movflags faststart \"output.mp4\"", str); + } + + [TestMethod] + public void Builder_BuildString_Overwrite() + { + var str = FFMpegArguments.FromInputFiles(true, "input.mp4").OverwriteExisting().OutputToFile("output.mp4").Arguments; + Assert.AreEqual("-i \"input.mp4\" -y \"output.mp4\"", str); + } + + [TestMethod] + public void Builder_BuildString_RemoveMetadata() + { + var str = FFMpegArguments.FromInputFiles(true, "input.mp4").WithoutMetadata().OutputToFile("output.mp4").Arguments; + Assert.AreEqual("-i \"input.mp4\" -map_metadata -1 \"output.mp4\"", str); + } + + [TestMethod] + public void Builder_BuildString_Transpose() + { + var str = FFMpegArguments.FromInputFiles(true, "input.mp4").Transpose(Transposition.CounterClockwise90).OutputToFile("output.mp4").Arguments; + Assert.AreEqual("-i \"input.mp4\" -vf \"transpose=2\" \"output.mp4\"", str); + } + [TestMethod] public void Builder_BuildString_CpuSpeed() { @@ -170,6 +240,18 @@ public void Builder_BuildString_DrawtextFilter() Assert.AreEqual("-i \"input.mp4\" -vf drawtext=\"text='Stack Overflow':fontfile=/path/to/font.ttf:fontcolor=white:fontsize=24:box=1:boxcolor=black@0.5:boxborderw=5:x=(w-text_w)/2:y=(h-text_h)/2\" \"output.mp4\"", str); } + + [TestMethod] + public void Builder_BuildString_DrawtextFilter_Alt() + { + var str = FFMpegArguments + .FromInputFiles(true, "input.mp4") + .DrawText(DrawTextOptions + .Create("Stack Overflow", "/path/to/font.ttf", ("fontcolor", "white"), ("fontsize", "24"))) + .OutputToFile("output.mp4").Arguments; + + Assert.AreEqual("-i \"input.mp4\" -vf drawtext=\"text='Stack Overflow':fontfile=/path/to/font.ttf:fontcolor=white:fontsize=24\" \"output.mp4\"", str); + } [TestMethod] public void Builder_BuildString_StartNumber() diff --git a/FFMpegCore.Test/AudioTest.cs b/FFMpegCore.Test/AudioTest.cs index 1a3d316..552ca24 100644 --- a/FFMpegCore.Test/AudioTest.cs +++ b/FFMpegCore.Test/AudioTest.cs @@ -3,8 +3,6 @@ using FFMpegCore.Test.Resources; using Microsoft.VisualStudio.TestTools.UnitTesting; using System.IO; -using FFMpegCore.FFMPEG; -using FFMpegCore.FFMPEG.Argument; namespace FFMpegCore.Test { diff --git a/FFMpegCore.Test/BaseTest.cs b/FFMpegCore.Test/BaseTest.cs index aa16315..38a5bcc 100644 --- a/FFMpegCore.Test/BaseTest.cs +++ b/FFMpegCore.Test/BaseTest.cs @@ -1,5 +1,4 @@ -using FFMpegCore.FFMPEG; -using FFMpegCore.Test.Resources; +using FFMpegCore.Test.Resources; using System.IO; namespace FFMpegCore.Test diff --git a/FFMpegCore.Test/BitmapSources.cs b/FFMpegCore.Test/BitmapSources.cs index d732ff7..2a81d57 100644 --- a/FFMpegCore.Test/BitmapSources.cs +++ b/FFMpegCore.Test/BitmapSources.cs @@ -1,10 +1,10 @@ using FFMpegCore.Extend; -using FFMpegCore.FFMPEG.Pipes; using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; using System.Numerics; +using FFMpegCore.Pipes; namespace FFMpegCore.Test { diff --git a/FFMpegCore.Test/FFMpegOptions.cs b/FFMpegCore.Test/FFMpegOptions.cs index efdd6e3..b7359a4 100644 --- a/FFMpegCore.Test/FFMpegOptions.cs +++ b/FFMpegCore.Test/FFMpegOptions.cs @@ -1,5 +1,4 @@ -using FFMpegCore.FFMPEG; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; using Newtonsoft.Json; using System.IO; diff --git a/FFMpegCore.Test/FFProbeTests.cs b/FFMpegCore.Test/FFProbeTests.cs index c306139..13cd901 100644 --- a/FFMpegCore.Test/FFProbeTests.cs +++ b/FFMpegCore.Test/FFProbeTests.cs @@ -1,6 +1,5 @@ using System.IO; using System.Threading.Tasks; -using FFMpegCore.FFMPEG; using FFMpegCore.Test.Resources; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -20,6 +19,35 @@ public void Probe_Success() { var info = FFProbe.Analyse(VideoLibrary.LocalVideo.FullName); Assert.AreEqual(13, info.Duration.Seconds); + Assert.AreEqual(".mp4", info.Extension); + Assert.AreEqual(VideoLibrary.LocalVideo.FullName, info.Path); + + Assert.AreEqual("5.1", info.PrimaryAudioStream.ChannelLayout); + Assert.AreEqual(6, info.PrimaryAudioStream.Channels); + Assert.AreEqual("AAC (Advanced Audio Coding)", info.PrimaryAudioStream.CodecLongName); + Assert.AreEqual("aac", info.PrimaryAudioStream.CodecName); + Assert.AreEqual(381988, info.PrimaryAudioStream.BitRate); + Assert.AreEqual(48000, info.PrimaryAudioStream.SampleRateHz); + + Assert.AreEqual(862991, info.PrimaryVideoStream.BitRate); + Assert.AreEqual(16, info.PrimaryVideoStream.DisplayAspectRatio.Width); + Assert.AreEqual(9, info.PrimaryVideoStream.DisplayAspectRatio.Height); + Assert.AreEqual("yuv420p", info.PrimaryVideoStream.PixelFormat); + Assert.AreEqual(1280, info.PrimaryVideoStream.Width); + Assert.AreEqual(720, info.PrimaryVideoStream.Height); + Assert.AreEqual(25, info.PrimaryVideoStream.AvgFrameRate); + Assert.AreEqual(25, info.PrimaryVideoStream.FrameRate); + Assert.AreEqual("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10", info.PrimaryVideoStream.CodecLongName); + Assert.AreEqual("h264", info.PrimaryVideoStream.CodecName); + Assert.AreEqual(8, info.PrimaryVideoStream.BitsPerRawSample); + Assert.AreEqual("Main", info.PrimaryVideoStream.Profile); + } + + [TestMethod] + public async Task Probe_Async_Success() + { + var info = await FFProbe.AnalyseAsync(VideoLibrary.LocalVideo.FullName); + Assert.AreEqual(13, info.Duration.Seconds); } [TestMethod] diff --git a/FFMpegCore.Test/VideoTest.cs b/FFMpegCore.Test/VideoTest.cs index 67ef2db..74f0051 100644 --- a/FFMpegCore.Test/VideoTest.cs +++ b/FFMpegCore.Test/VideoTest.cs @@ -1,8 +1,4 @@ using FFMpegCore.Enums; -using FFMpegCore.FFMPEG.Argument; -using FFMpegCore.FFMPEG.Enums; -using FFMpegCore.FFMPEG.Exceptions; -using FFMpegCore.FFMPEG.Pipes; using FFMpegCore.Test.Resources; using Microsoft.VisualStudio.TestTools.UnitTesting; using System; @@ -11,7 +7,9 @@ using System.IO; using System.Linq; using System.Threading.Tasks; -using FFMpegCore.FFMPEG; +using FFMpegCore.Arguments; +using FFMpegCore.Exceptions; +using FFMpegCore.Pipes; namespace FFMpegCore.Test { diff --git a/FFMpegCore/Enums/FileExtension.cs b/FFMpegCore/Enums/FileExtension.cs index d2a4519..8661c7d 100644 --- a/FFMpegCore/Enums/FileExtension.cs +++ b/FFMpegCore/Enums/FileExtension.cs @@ -1,11 +1,10 @@ using System; -using FFMpegCore.FFMPEG.Enums; namespace FFMpegCore.Enums { public static class FileExtension { - public static string ForType(VideoType type) + public static string Extension(this VideoType type) { return type switch { @@ -16,7 +15,7 @@ public static string ForType(VideoType type) _ => throw new Exception("The extension for this video type is not defined.") }; } - public static string ForCodec(VideoCodec type) + public static string Extension(this VideoCodec type) { return type switch { diff --git a/FFMpegCore/Extend/BitmapExtensions.cs b/FFMpegCore/Extend/BitmapExtensions.cs index 3381fe8..bf10336 100644 --- a/FFMpegCore/Extend/BitmapExtensions.cs +++ b/FFMpegCore/Extend/BitmapExtensions.cs @@ -1,7 +1,6 @@ using System; using System.Drawing; using System.IO; -using FFMpegCore.FFMPEG; namespace FFMpegCore.Extend { diff --git a/FFMpegCore/Extend/BitmapVideoFrameWrapper.cs b/FFMpegCore/Extend/BitmapVideoFrameWrapper.cs index 3f55831..c8645ab 100644 --- a/FFMpegCore/Extend/BitmapVideoFrameWrapper.cs +++ b/FFMpegCore/Extend/BitmapVideoFrameWrapper.cs @@ -1,10 +1,9 @@ using System; using System.Drawing; using System.Drawing.Imaging; -using System.IO; using System.Runtime.InteropServices; using System.Threading.Tasks; -using FFMpegCore.FFMPEG.Pipes; +using FFMpegCore.Pipes; namespace FFMpegCore.Extend { @@ -24,7 +23,7 @@ public BitmapVideoFrameWrapper(Bitmap bitmap) Format = ConvertStreamFormat(bitmap.PixelFormat); } - public void Serialize(Stream stream) + public void Serialize(System.IO.Stream stream) { var data = Source.LockBits(new Rectangle(0, 0, Width, Height), ImageLockMode.ReadOnly, Source.PixelFormat); @@ -40,7 +39,7 @@ public void Serialize(Stream stream) } } - public async Task SerializeAsync(Stream stream) + public async Task SerializeAsync(System.IO.Stream stream) { var data = Source.LockBits(new Rectangle(0, 0, Width, Height), ImageLockMode.ReadOnly, Source.PixelFormat); diff --git a/FFMpegCore/Extend/UriExtensions.cs b/FFMpegCore/Extend/UriExtensions.cs index cff950d..ebe92c0 100644 --- a/FFMpegCore/Extend/UriExtensions.cs +++ b/FFMpegCore/Extend/UriExtensions.cs @@ -1,5 +1,4 @@ using System; -using FFMpegCore.FFMPEG; namespace FFMpegCore.Extend { diff --git a/FFMpegCore/FFMpeg/Arguments/AudioBitrateArgument.cs b/FFMpegCore/FFMpeg/Arguments/AudioBitrateArgument.cs index a637a96..9c7e813 100644 --- a/FFMpegCore/FFMpeg/Arguments/AudioBitrateArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/AudioBitrateArgument.cs @@ -1,6 +1,6 @@ -using FFMpegCore.FFMPEG.Enums; +using FFMpegCore.Enums; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Represents parameter of audio codec and it's quality diff --git a/FFMpegCore/FFMpeg/Arguments/AudioCodecArgument.cs b/FFMpegCore/FFMpeg/Arguments/AudioCodecArgument.cs index a849fbc..3b81ddd 100644 --- a/FFMpegCore/FFMpeg/Arguments/AudioCodecArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/AudioCodecArgument.cs @@ -1,6 +1,6 @@ -using FFMpegCore.FFMPEG.Enums; +using FFMpegCore.Enums; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Represents parameter of audio codec and it's quality diff --git a/FFMpegCore/FFMpeg/Arguments/AudioSamplingRateArgument.cs b/FFMpegCore/FFMpeg/Arguments/AudioSamplingRateArgument.cs index e34941c..6f1365d 100644 --- a/FFMpegCore/FFMpeg/Arguments/AudioSamplingRateArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/AudioSamplingRateArgument.cs @@ -1,4 +1,4 @@ -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Audio sampling rate argument. Defaults to 48000 (Hz) diff --git a/FFMpegCore/FFMpeg/Arguments/BitStreamFilterArgument.cs b/FFMpegCore/FFMpeg/Arguments/BitStreamFilterArgument.cs index 5381516..871df5e 100644 --- a/FFMpegCore/FFMpeg/Arguments/BitStreamFilterArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/BitStreamFilterArgument.cs @@ -1,6 +1,6 @@ -using FFMpegCore.FFMPEG.Enums; +using FFMpegCore.Enums; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Represents parameter of bitstream filter diff --git a/FFMpegCore/FFMpeg/Arguments/ConcatArgument.cs b/FFMpegCore/FFMpeg/Arguments/ConcatArgument.cs index c7460fa..b0908b4 100644 --- a/FFMpegCore/FFMpeg/Arguments/ConcatArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/ConcatArgument.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// diff --git a/FFMpegCore/FFMpeg/Arguments/ConstantRateFactorArgument.cs b/FFMpegCore/FFMpeg/Arguments/ConstantRateFactorArgument.cs index db84603..c02cfa3 100644 --- a/FFMpegCore/FFMpeg/Arguments/ConstantRateFactorArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/ConstantRateFactorArgument.cs @@ -1,6 +1,6 @@ using System; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Constant Rate Factor (CRF) argument diff --git a/FFMpegCore/FFMpeg/Arguments/CopyArgument.cs b/FFMpegCore/FFMpeg/Arguments/CopyArgument.cs index 3bbbdfe..91419d5 100644 --- a/FFMpegCore/FFMpeg/Arguments/CopyArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/CopyArgument.cs @@ -1,6 +1,6 @@ -using FFMpegCore.FFMPEG.Enums; +using FFMpegCore.Enums; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Represents parameter of copy parameter diff --git a/FFMpegCore/FFMpeg/Arguments/CpuSpeedArgument.cs b/FFMpegCore/FFMpeg/Arguments/CpuSpeedArgument.cs index fc861fc..228262e 100644 --- a/FFMpegCore/FFMpeg/Arguments/CpuSpeedArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/CpuSpeedArgument.cs @@ -1,4 +1,4 @@ -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Represents cpu speed parameter diff --git a/FFMpegCore/FFMpeg/Arguments/CustomArgument.cs b/FFMpegCore/FFMpeg/Arguments/CustomArgument.cs index 8e98242..8eedb12 100644 --- a/FFMpegCore/FFMpeg/Arguments/CustomArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/CustomArgument.cs @@ -1,4 +1,4 @@ -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { public class CustomArgument : IArgument { diff --git a/FFMpegCore/FFMpeg/Arguments/DisableChannelArgument.cs b/FFMpegCore/FFMpeg/Arguments/DisableChannelArgument.cs index 4a35beb..d683775 100644 --- a/FFMpegCore/FFMpeg/Arguments/DisableChannelArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/DisableChannelArgument.cs @@ -1,7 +1,7 @@ -using FFMpegCore.FFMPEG.Enums; -using FFMpegCore.FFMPEG.Exceptions; +using FFMpegCore.Enums; +using FFMpegCore.Exceptions; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Represents cpu speed parameter diff --git a/FFMpegCore/FFMpeg/Arguments/DrawTextArgument.cs b/FFMpegCore/FFMpeg/Arguments/DrawTextArgument.cs index 4ab80b0..d4eabb8 100644 --- a/FFMpegCore/FFMpeg/Arguments/DrawTextArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/DrawTextArgument.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Drawtext video filter argument @@ -9,9 +9,6 @@ namespace FFMpegCore.FFMPEG.Argument public class DrawTextArgument : IArgument { public readonly DrawTextOptions Options; - - public DrawTextArgument(string text, string fontPath, params (string, string)[] optionalArguments) - : this(DrawTextOptions.Create(text, fontPath, optionalArguments)) { } public DrawTextArgument(DrawTextOptions options) { @@ -31,7 +28,7 @@ public static DrawTextOptions Create(string text, string font) { return new DrawTextOptions(text, font, new List<(string, string)>()); } - public static DrawTextOptions Create(string text, string font, IEnumerable<(string key, string value)> parameters) + public static DrawTextOptions Create(string text, string font, params (string key, string value)[] parameters) { return new DrawTextOptions(text, font, parameters); } diff --git a/FFMpegCore/FFMpeg/Arguments/DurationArgument.cs b/FFMpegCore/FFMpeg/Arguments/DurationArgument.cs index cc4f045..e47b966 100644 --- a/FFMpegCore/FFMpeg/Arguments/DurationArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/DurationArgument.cs @@ -1,6 +1,6 @@ using System; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Represents duration parameter diff --git a/FFMpegCore/FFMpeg/Arguments/FaststartArgument.cs b/FFMpegCore/FFMpeg/Arguments/FaststartArgument.cs index 14710b8..54cdd6f 100644 --- a/FFMpegCore/FFMpeg/Arguments/FaststartArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/FaststartArgument.cs @@ -1,4 +1,4 @@ -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Faststart argument - for moving moov atom to the start of file diff --git a/FFMpegCore/FFMpeg/Arguments/ForceFormatArgument.cs b/FFMpegCore/FFMpeg/Arguments/ForceFormatArgument.cs index 38e1f0a..503c6ec 100644 --- a/FFMpegCore/FFMpeg/Arguments/ForceFormatArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/ForceFormatArgument.cs @@ -1,6 +1,6 @@ -using FFMpegCore.FFMPEG.Enums; +using FFMpegCore.Enums; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Represents force format parameter diff --git a/FFMpegCore/FFMpeg/Arguments/FrameOutputCountArgument.cs b/FFMpegCore/FFMpeg/Arguments/FrameOutputCountArgument.cs index fe492fc..08bc56b 100644 --- a/FFMpegCore/FFMpeg/Arguments/FrameOutputCountArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/FrameOutputCountArgument.cs @@ -1,4 +1,4 @@ -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Represents frame output count parameter @@ -6,8 +6,6 @@ public class FrameOutputCountArgument : IArgument { public readonly int Frames; - public FrameOutputCountArgument() { } - public FrameOutputCountArgument(int frames) { Frames = frames; diff --git a/FFMpegCore/FFMpeg/Arguments/FrameRateArgument.cs b/FFMpegCore/FFMpeg/Arguments/FrameRateArgument.cs index abc6fc5..e000e2e 100644 --- a/FFMpegCore/FFMpeg/Arguments/FrameRateArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/FrameRateArgument.cs @@ -1,4 +1,4 @@ -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Represents frame rate parameter diff --git a/FFMpegCore/FFMpeg/Arguments/InputArgument.cs b/FFMpegCore/FFMpeg/Arguments/InputArgument.cs index 3e3ba2b..c201c1f 100644 --- a/FFMpegCore/FFMpeg/Arguments/InputArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/InputArgument.cs @@ -4,7 +4,7 @@ using System.Threading; using System.Threading.Tasks; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Represents input parameter @@ -41,19 +41,23 @@ public void Pre() public interface IArgument { + /// + /// The textual representation of the argument + /// string Text { get; } + } + + public interface IInputOutputArgument : IArgument + { + void Pre() {} + Task During(CancellationToken? cancellationToken = null) => Task.CompletedTask; + void Post() {} } - public interface IInputArgument : IArgument + public interface IInputArgument : IInputOutputArgument { - void Pre() {} - Task During(CancellationToken? cancellationToken = null) => Task.CompletedTask; - void Post() {} } - public interface IOutputArgument : IArgument + public interface IOutputArgument : IInputOutputArgument { - void Pre() {} - Task During(CancellationToken? cancellationToken = null) => Task.CompletedTask; - void Post() {} } } diff --git a/FFMpegCore/FFMpeg/Arguments/InputPipeArgument.cs b/FFMpegCore/FFMpeg/Arguments/InputPipeArgument.cs index 50809e4..9fcace9 100644 --- a/FFMpegCore/FFMpeg/Arguments/InputPipeArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/InputPipeArgument.cs @@ -1,9 +1,9 @@ using System.IO.Pipes; using System.Threading; using System.Threading.Tasks; -using FFMpegCore.FFMPEG.Pipes; +using FFMpegCore.Pipes; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Represents input parameter for a named pipe diff --git a/FFMpegCore/FFMpeg/Arguments/LoopArgument.cs b/FFMpegCore/FFMpeg/Arguments/LoopArgument.cs index e1eeeda..26adc3e 100644 --- a/FFMpegCore/FFMpeg/Arguments/LoopArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/LoopArgument.cs @@ -1,4 +1,4 @@ -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Represents loop parameter diff --git a/FFMpegCore/FFMpeg/Arguments/OutputArgument.cs b/FFMpegCore/FFMpeg/Arguments/OutputArgument.cs index cb64d22..5a53886 100644 --- a/FFMpegCore/FFMpeg/Arguments/OutputArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/OutputArgument.cs @@ -1,8 +1,8 @@ using System; using System.IO; -using FFMpegCore.FFMPEG.Exceptions; +using FFMpegCore.Exceptions; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Represents output parameter diff --git a/FFMpegCore/FFMpeg/Arguments/OutputPipeArgument.cs b/FFMpegCore/FFMpeg/Arguments/OutputPipeArgument.cs index 1b955f3..0988f1c 100644 --- a/FFMpegCore/FFMpeg/Arguments/OutputPipeArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/OutputPipeArgument.cs @@ -1,9 +1,9 @@ using System.IO.Pipes; using System.Threading; using System.Threading.Tasks; -using FFMpegCore.FFMPEG.Pipes; +using FFMpegCore.Pipes; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { public class OutputPipeArgument : PipeArgument { diff --git a/FFMpegCore/FFMpeg/Arguments/OverwriteArgument.cs b/FFMpegCore/FFMpeg/Arguments/OverwriteArgument.cs index bf42a62..3a633af 100644 --- a/FFMpegCore/FFMpeg/Arguments/OverwriteArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/OverwriteArgument.cs @@ -1,4 +1,4 @@ -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Represents overwrite parameter diff --git a/FFMpegCore/FFMpeg/Arguments/PipeArgument.cs b/FFMpegCore/FFMpeg/Arguments/PipeArgument.cs index 2f7092d..4a4bd46 100644 --- a/FFMpegCore/FFMpeg/Arguments/PipeArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/PipeArgument.cs @@ -2,9 +2,9 @@ using System.IO.Pipes; using System.Threading; using System.Threading.Tasks; -using FFMpegCore.FFMPEG.Pipes; +using FFMpegCore.Pipes; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { public abstract class PipeArgument : IInputArgument, IOutputArgument { diff --git a/FFMpegCore/FFMpeg/Arguments/QuietArgument.cs b/FFMpegCore/FFMpeg/Arguments/QuietArgument.cs index 87c67bb..2bab939 100644 --- a/FFMpegCore/FFMpeg/Arguments/QuietArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/QuietArgument.cs @@ -1,4 +1,4 @@ -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { public class QuietArgument : IArgument { diff --git a/FFMpegCore/FFMpeg/Arguments/RemoveMetadataArgument.cs b/FFMpegCore/FFMpeg/Arguments/RemoveMetadataArgument.cs index 2d57ca0..29cdac6 100644 --- a/FFMpegCore/FFMpeg/Arguments/RemoveMetadataArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/RemoveMetadataArgument.cs @@ -1,4 +1,4 @@ -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Remove metadata argument diff --git a/FFMpegCore/FFMpeg/Arguments/ScaleArgument.cs b/FFMpegCore/FFMpeg/Arguments/ScaleArgument.cs index 0874cb4..40e98d0 100644 --- a/FFMpegCore/FFMpeg/Arguments/ScaleArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/ScaleArgument.cs @@ -1,7 +1,7 @@ using System.Drawing; -using FFMpegCore.FFMPEG.Enums; +using FFMpegCore.Enums; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Represents scale parameter diff --git a/FFMpegCore/FFMpeg/Arguments/SeekArgument.cs b/FFMpegCore/FFMpeg/Arguments/SeekArgument.cs index 6d7c956..1057b88 100644 --- a/FFMpegCore/FFMpeg/Arguments/SeekArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/SeekArgument.cs @@ -1,6 +1,6 @@ using System; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Represents seek parameter diff --git a/FFMpegCore/FFMpeg/Arguments/ShortestArgument.cs b/FFMpegCore/FFMpeg/Arguments/ShortestArgument.cs index bccb4aa..d85813e 100644 --- a/FFMpegCore/FFMpeg/Arguments/ShortestArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/ShortestArgument.cs @@ -1,4 +1,4 @@ -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Represents shortest parameter diff --git a/FFMpegCore/FFMpeg/Arguments/SizeArgument.cs b/FFMpegCore/FFMpeg/Arguments/SizeArgument.cs index 3ebbd7d..2ccde92 100644 --- a/FFMpegCore/FFMpeg/Arguments/SizeArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/SizeArgument.cs @@ -1,7 +1,7 @@ using System.Drawing; -using FFMpegCore.FFMPEG.Enums; +using FFMpegCore.Enums; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Represents size parameter diff --git a/FFMpegCore/FFMpeg/Arguments/SpeedPresetArgument.cs b/FFMpegCore/FFMpeg/Arguments/SpeedPresetArgument.cs index 19e2893..401e2dd 100644 --- a/FFMpegCore/FFMpeg/Arguments/SpeedPresetArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/SpeedPresetArgument.cs @@ -1,6 +1,6 @@ -using FFMpegCore.FFMPEG.Enums; +using FFMpegCore.Enums; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Represents speed parameter diff --git a/FFMpegCore/FFMpeg/Arguments/StartNumberArgument.cs b/FFMpegCore/FFMpeg/Arguments/StartNumberArgument.cs index d408b40..f7c09da 100644 --- a/FFMpegCore/FFMpeg/Arguments/StartNumberArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/StartNumberArgument.cs @@ -1,4 +1,4 @@ -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Represents start number parameter diff --git a/FFMpegCore/FFMpeg/Arguments/ThreadsArgument.cs b/FFMpegCore/FFMpeg/Arguments/ThreadsArgument.cs index 13a651e..6fd94e6 100644 --- a/FFMpegCore/FFMpeg/Arguments/ThreadsArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/ThreadsArgument.cs @@ -1,6 +1,6 @@ using System; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Represents threads parameter diff --git a/FFMpegCore/FFMpeg/Arguments/TransposeArgument.cs b/FFMpegCore/FFMpeg/Arguments/TransposeArgument.cs index 713b8eb..acc26f4 100644 --- a/FFMpegCore/FFMpeg/Arguments/TransposeArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/TransposeArgument.cs @@ -1,6 +1,6 @@ -using FFMpegCore.FFMPEG.Enums; +using FFMpegCore.Enums; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Transpose argument. diff --git a/FFMpegCore/FFMpeg/Arguments/VariableBitRateArgument.cs b/FFMpegCore/FFMpeg/Arguments/VariableBitRateArgument.cs index e2e54b3..b656ec4 100644 --- a/FFMpegCore/FFMpeg/Arguments/VariableBitRateArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/VariableBitRateArgument.cs @@ -1,6 +1,6 @@ using System; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Variable Bitrate Argument (VBR) argument diff --git a/FFMpegCore/FFMpeg/Arguments/VideoBitrateArgument.cs b/FFMpegCore/FFMpeg/Arguments/VideoBitrateArgument.cs index 5a8211b..ea5e641 100644 --- a/FFMpegCore/FFMpeg/Arguments/VideoBitrateArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/VideoBitrateArgument.cs @@ -1,4 +1,4 @@ -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Represents video bitrate parameter diff --git a/FFMpegCore/FFMpeg/Arguments/VideoCodecArgument.cs b/FFMpegCore/FFMpeg/Arguments/VideoCodecArgument.cs index cf26682..4e2b782 100644 --- a/FFMpegCore/FFMpeg/Arguments/VideoCodecArgument.cs +++ b/FFMpegCore/FFMpeg/Arguments/VideoCodecArgument.cs @@ -1,6 +1,6 @@ -using FFMpegCore.FFMPEG.Enums; +using FFMpegCore.Enums; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore.Arguments { /// /// Represents video codec parameter diff --git a/FFMpegCore/FFMpeg/Enums/AudioQuality.cs b/FFMpegCore/FFMpeg/Enums/AudioQuality.cs index 25760e3..60ba0eb 100644 --- a/FFMpegCore/FFMpeg/Enums/AudioQuality.cs +++ b/FFMpegCore/FFMpeg/Enums/AudioQuality.cs @@ -1,4 +1,4 @@ -namespace FFMpegCore.FFMPEG.Enums +namespace FFMpegCore.Enums { public enum AudioQuality { diff --git a/FFMpegCore/FFMpeg/Enums/Codec.cs b/FFMpegCore/FFMpeg/Enums/Codec.cs index 95f58b9..7576501 100644 --- a/FFMpegCore/FFMpeg/Enums/Codec.cs +++ b/FFMpegCore/FFMpeg/Enums/Codec.cs @@ -1,4 +1,4 @@ -namespace FFMpegCore.FFMPEG.Enums +namespace FFMpegCore.Enums { public enum VideoCodec { diff --git a/FFMpegCore/FFMpeg/Enums/Speed.cs b/FFMpegCore/FFMpeg/Enums/Speed.cs index 089ed9c..52272f0 100644 --- a/FFMpegCore/FFMpeg/Enums/Speed.cs +++ b/FFMpegCore/FFMpeg/Enums/Speed.cs @@ -1,4 +1,4 @@ -namespace FFMpegCore.FFMPEG.Enums +namespace FFMpegCore.Enums { public enum Speed { diff --git a/FFMpegCore/FFMpeg/Enums/Transposition.cs b/FFMpegCore/FFMpeg/Enums/Transposition.cs index 8032f0d..bacfccc 100644 --- a/FFMpegCore/FFMpeg/Enums/Transposition.cs +++ b/FFMpegCore/FFMpeg/Enums/Transposition.cs @@ -1,4 +1,4 @@ -namespace FFMpegCore.FFMPEG.Enums +namespace FFMpegCore.Enums { public enum Transposition { diff --git a/FFMpegCore/FFMpeg/Enums/VideoSize.cs b/FFMpegCore/FFMpeg/Enums/VideoSize.cs index 501be83..d774b95 100644 --- a/FFMpegCore/FFMpeg/Enums/VideoSize.cs +++ b/FFMpegCore/FFMpeg/Enums/VideoSize.cs @@ -1,4 +1,4 @@ -namespace FFMpegCore.FFMPEG.Enums +namespace FFMpegCore.Enums { public enum VideoSize { diff --git a/FFMpegCore/FFMpeg/Exceptions/FFMpegException.cs b/FFMpegCore/FFMpeg/Exceptions/FFMpegException.cs index 6026c9b..00d3c19 100644 --- a/FFMpegCore/FFMpeg/Exceptions/FFMpegException.cs +++ b/FFMpegCore/FFMpeg/Exceptions/FFMpegException.cs @@ -1,6 +1,6 @@ using System; -namespace FFMpegCore.FFMPEG.Exceptions +namespace FFMpegCore.Exceptions { public enum FFMpegExceptionType { diff --git a/FFMpegCore/FFMpeg/FFMpeg.cs b/FFMpegCore/FFMpeg/FFMpeg.cs index e2018c9..0d9786a 100644 --- a/FFMpegCore/FFMpeg/FFMpeg.cs +++ b/FFMpegCore/FFMpeg/FFMpeg.cs @@ -5,11 +5,9 @@ using System.IO; using System.Linq; using FFMpegCore.Enums; -using FFMpegCore.FFMPEG.Argument; -using FFMpegCore.FFMPEG.Enums; using FFMpegCore.Helpers; -namespace FFMpegCore.FFMPEG +namespace FFMpegCore { public static class FFMpeg { @@ -98,7 +96,7 @@ public static bool Convert( AudioQuality audioQuality = AudioQuality.Normal, bool multithreaded = false) { - FFMpegHelper.ExtensionExceptionCheck(output, FileExtension.ForType(type)); + FFMpegHelper.ExtensionExceptionCheck(output, type.Extension()); FFMpegHelper.ConversionSizeExceptionCheck(source); var scale = VideoSize.Original == size ? 1 : (double)source.PrimaryVideoStream.Height / (int)size; diff --git a/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs b/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs index 7c0df4e..e86bf5c 100644 --- a/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs +++ b/FFMpegCore/FFMpeg/FFMpegArgumentProcessor.cs @@ -7,7 +7,7 @@ using FFMpegCore.Helpers; using Instances; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore { public class FFMpegArgumentProcessor { diff --git a/FFMpegCore/FFMpeg/FFMpegArguments.cs b/FFMpegCore/FFMpeg/FFMpegArguments.cs index 565be02..bb0def7 100644 --- a/FFMpegCore/FFMpeg/FFMpegArguments.cs +++ b/FFMpegCore/FFMpeg/FFMpegArguments.cs @@ -5,10 +5,11 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using FFMpegCore.FFMPEG.Enums; -using FFMpegCore.FFMPEG.Pipes; +using FFMpegCore.Arguments; +using FFMpegCore.Enums; +using FFMpegCore.Pipes; -namespace FFMpegCore.FFMPEG.Argument +namespace FFMpegCore { public class FFMpegArguments { @@ -71,7 +72,7 @@ private FFMpegArguments(IInputArgument inputArgument) public FFMpegArguments WithCustomArgument(string argument) => WithArgument(new CustomArgument(argument)); public FFMpegArguments Seek(TimeSpan? seekTo) => WithArgument(new SeekArgument(seekTo)); - public FFMpegArguments Transpose(TimeSpan? seekTo) => WithArgument(new SeekArgument(seekTo)); + public FFMpegArguments Transpose(Transposition transposition) => WithArgument(new TransposeArgument(transposition)); public FFMpegArguments Loop(int times) => WithArgument(new LoopArgument(times)); public FFMpegArguments OverwriteExisting() => WithArgument(new OverwriteArgument()); public FFMpegArguments Quiet() => WithArgument(new QuietArgument()); diff --git a/FFMpegCore/FFMpeg/FFMpegOptions.cs b/FFMpegCore/FFMpeg/FFMpegOptions.cs index 055e0dc..175c011 100644 --- a/FFMpegCore/FFMpeg/FFMpegOptions.cs +++ b/FFMpegCore/FFMpeg/FFMpegOptions.cs @@ -3,7 +3,7 @@ using System.Runtime.InteropServices; using System.Text.Json; -namespace FFMpegCore.FFMPEG +namespace FFMpegCore { public class FFMpegOptions { diff --git a/FFMpegCore/FFMpeg/Pipes/IPipeDataReader.cs b/FFMpegCore/FFMpeg/Pipes/IPipeDataReader.cs index 8fa7ea2..370124f 100644 --- a/FFMpegCore/FFMpeg/Pipes/IPipeDataReader.cs +++ b/FFMpegCore/FFMpeg/Pipes/IPipeDataReader.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace FFMpegCore.FFMPEG.Pipes +namespace FFMpegCore.Pipes { public interface IPipeDataReader { diff --git a/FFMpegCore/FFMpeg/Pipes/IPipeDataWriter.cs b/FFMpegCore/FFMpeg/Pipes/IPipeDataWriter.cs index 79a6a0f..bd80ec4 100644 --- a/FFMpegCore/FFMpeg/Pipes/IPipeDataWriter.cs +++ b/FFMpegCore/FFMpeg/Pipes/IPipeDataWriter.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace FFMpegCore.FFMPEG.Pipes +namespace FFMpegCore.Pipes { /// /// Interface for ffmpeg pipe source data IO diff --git a/FFMpegCore/FFMpeg/Pipes/IVideoFrame.cs b/FFMpegCore/FFMpeg/Pipes/IVideoFrame.cs index 53eed82..e3be232 100644 --- a/FFMpegCore/FFMpeg/Pipes/IVideoFrame.cs +++ b/FFMpegCore/FFMpeg/Pipes/IVideoFrame.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace FFMpegCore.FFMPEG.Pipes +namespace FFMpegCore.Pipes { /// /// Interface for Video frame diff --git a/FFMpegCore/FFMpeg/Pipes/PipeHelpers.cs b/FFMpegCore/FFMpeg/Pipes/PipeHelpers.cs index 2504856..ddd788c 100644 --- a/FFMpegCore/FFMpeg/Pipes/PipeHelpers.cs +++ b/FFMpegCore/FFMpeg/Pipes/PipeHelpers.cs @@ -1,14 +1,18 @@ using System; +using System.Runtime.InteropServices; -namespace FFMpegCore.FFMPEG.Pipes +namespace FFMpegCore.Pipes { static class PipeHelpers { - public static string GetUnqiuePipeName() => "FFMpegCore_Pipe_" + Guid.NewGuid(); + public static string GetUnqiuePipeName() => "FFMpegCore_" + Guid.NewGuid(); public static string GetPipePath(string pipeName) { - return $@"\\.\pipe\{pipeName}"; + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + return $@"\\.\pipe\{pipeName}"; + else + return $"unix:/tmp/CoreFxPipe_{pipeName}"; // dotnet uses unix sockets on unix, for more see https://github.com/dotnet/runtime/issues/24390 } } } diff --git a/FFMpegCore/FFMpeg/Pipes/RawVideoPipeDataWriter.cs b/FFMpegCore/FFMpeg/Pipes/RawVideoPipeDataWriter.cs index 229921b..7f2737c 100644 --- a/FFMpegCore/FFMpeg/Pipes/RawVideoPipeDataWriter.cs +++ b/FFMpegCore/FFMpeg/Pipes/RawVideoPipeDataWriter.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using FFMpegCore.FFMPEG.Exceptions; +using FFMpegCore.Exceptions; -namespace FFMpegCore.FFMPEG.Pipes +namespace FFMpegCore.Pipes { /// /// Implementation of for a raw video stream that is gathered from diff --git a/FFMpegCore/FFMpeg/Pipes/StreamPipeDataReader.cs b/FFMpegCore/FFMpeg/Pipes/StreamPipeDataReader.cs index 56f6bb1..cb39cfa 100644 --- a/FFMpegCore/FFMpeg/Pipes/StreamPipeDataReader.cs +++ b/FFMpegCore/FFMpeg/Pipes/StreamPipeDataReader.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace FFMpegCore.FFMPEG.Pipes +namespace FFMpegCore.Pipes { public class StreamPipeDataReader : IPipeDataReader { diff --git a/FFMpegCore/FFMpeg/Pipes/StreamPipeDataWriter.cs b/FFMpegCore/FFMpeg/Pipes/StreamPipeDataWriter.cs index cf5573c..af9cf7f 100644 --- a/FFMpegCore/FFMpeg/Pipes/StreamPipeDataWriter.cs +++ b/FFMpegCore/FFMpeg/Pipes/StreamPipeDataWriter.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; -namespace FFMpegCore.FFMPEG.Pipes +namespace FFMpegCore.Pipes { /// /// Implementation of used for stream redirection diff --git a/FFMpegCore/FFMpegCore.csproj.DotSettings b/FFMpegCore/FFMpegCore.csproj.DotSettings new file mode 100644 index 0000000..7a8d17a --- /dev/null +++ b/FFMpegCore/FFMpegCore.csproj.DotSettings @@ -0,0 +1,3 @@ + + True + True \ No newline at end of file diff --git a/FFMpegCore/FFProbe/AudioStream.cs b/FFMpegCore/FFProbe/AudioStream.cs index 9cdd74e..ad1e513 100644 --- a/FFMpegCore/FFProbe/AudioStream.cs +++ b/FFMpegCore/FFProbe/AudioStream.cs @@ -1,4 +1,4 @@ -namespace FFMpegCore.FFMPEG +namespace FFMpegCore { public class AudioStream : MediaStream { diff --git a/FFMpegCore/FFProbe/FFProbe.cs b/FFMpegCore/FFProbe/FFProbe.cs index e5415b4..90f6bfc 100644 --- a/FFMpegCore/FFProbe/FFProbe.cs +++ b/FFMpegCore/FFProbe/FFProbe.cs @@ -2,13 +2,13 @@ using System.IO; using System.Text.Json; using System.Threading.Tasks; -using FFMpegCore.FFMPEG.Argument; -using FFMpegCore.FFMPEG.Exceptions; -using FFMpegCore.FFMPEG.Pipes; +using FFMpegCore.Arguments; +using FFMpegCore.Exceptions; using FFMpegCore.Helpers; +using FFMpegCore.Pipes; using Instances; -namespace FFMpegCore.FFMPEG +namespace FFMpegCore { public static class FFProbe { diff --git a/FFMpegCore/FFProbe/FFProbeAnalysis.cs b/FFMpegCore/FFProbe/FFProbeAnalysis.cs index 419145c..2a82528 100644 --- a/FFMpegCore/FFProbe/FFProbeAnalysis.cs +++ b/FFMpegCore/FFProbe/FFProbeAnalysis.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Text.Json.Serialization; -namespace FFMpegCore.FFMPEG +namespace FFMpegCore { public class FFProbeAnalysis { @@ -37,9 +37,6 @@ public class Stream [JsonPropertyName("codec_long_name")] public string CodecLongName { get; set; } = null!; - - [JsonPropertyName("codec_tag_string")] - public string CodecTagString { get; set; } = null!; [JsonPropertyName("display_aspect_ratio")] public string DisplayAspectRatio { get; set; } = null!; diff --git a/FFMpegCore/FFProbe/MediaAnalysis.cs b/FFMpegCore/FFProbe/MediaAnalysis.cs index a73009a..223abef 100644 --- a/FFMpegCore/FFProbe/MediaAnalysis.cs +++ b/FFMpegCore/FFProbe/MediaAnalysis.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using System.Linq; -namespace FFMpegCore.FFMPEG +namespace FFMpegCore { public class MediaAnalysis { @@ -41,7 +41,7 @@ private VideoStream ParseVideoStream(Stream stream) CodecLongName = stream.CodecLongName, DisplayAspectRatio = ParseRatioInt(stream.DisplayAspectRatio, ':'), Duration = ParseDuration(stream), - FrameRate = DivideRatio(ParseRatioDouble(stream.AvgFrameRate, '/')), + FrameRate = DivideRatio(ParseRatioDouble(stream.FrameRate, '/')), Height = stream.Height!.Value, Width = stream.Width!.Value, Profile = stream.Profile, @@ -74,15 +74,15 @@ private AudioStream ParseAudioStream(Stream stream) private static double DivideRatio((double, double) ratio) => ratio.Item1 / ratio.Item2; private static (int, int) ParseRatioInt(string input, char separator) { - if (string.IsNullOrEmpty(input)) return (default, default); + if (string.IsNullOrEmpty(input)) return (0, 0); var ratio = input.Split(separator); return (int.Parse(ratio[0]), int.Parse(ratio[1])); } private static (double, double) ParseRatioDouble(string input, char separator) { - if (string.IsNullOrEmpty(input)) return (default, default); + if (string.IsNullOrEmpty(input)) return (0, 0); var ratio = input.Split(separator); - return (ratio.Length > 0 ? int.Parse(ratio[0]) : default, ratio.Length > 1 ? int.Parse(ratio[1]) : default); + return (ratio.Length > 0 ? double.Parse(ratio[0]) : 0, ratio.Length > 1 ? double.Parse(ratio[1]) : 0); } } } \ No newline at end of file diff --git a/FFMpegCore/FFProbe/MediaStream.cs b/FFMpegCore/FFProbe/MediaStream.cs index 315aecb..bdc32e9 100644 --- a/FFMpegCore/FFProbe/MediaStream.cs +++ b/FFMpegCore/FFProbe/MediaStream.cs @@ -1,6 +1,6 @@ using System; -namespace FFMpegCore.FFMPEG +namespace FFMpegCore { public class MediaStream { diff --git a/FFMpegCore/FFProbe/VideoStream.cs b/FFMpegCore/FFProbe/VideoStream.cs index 7da72a7..05b273c 100644 --- a/FFMpegCore/FFProbe/VideoStream.cs +++ b/FFMpegCore/FFProbe/VideoStream.cs @@ -1,10 +1,10 @@ -namespace FFMpegCore.FFMPEG +namespace FFMpegCore { public class VideoStream : MediaStream { public double AvgFrameRate { get; internal set; } public int BitsPerRawSample { get; internal set; } - public (int width, int height) DisplayAspectRatio { get; internal set; } + public (int Width, int Height) DisplayAspectRatio { get; internal set; } public string Profile { get; internal set; } = null!; public int Width { get; internal set; } public int Height { get; internal set; } diff --git a/FFMpegCore/Helpers/FFMpegHelper.cs b/FFMpegCore/Helpers/FFMpegHelper.cs index 42478b6..063760c 100644 --- a/FFMpegCore/Helpers/FFMpegHelper.cs +++ b/FFMpegCore/Helpers/FFMpegHelper.cs @@ -1,8 +1,7 @@ using System; using System.Drawing; using System.IO; -using FFMpegCore.FFMPEG; -using FFMpegCore.FFMPEG.Exceptions; +using FFMpegCore.Exceptions; namespace FFMpegCore.Helpers { diff --git a/FFMpegCore/Helpers/FFProbeHelper.cs b/FFMpegCore/Helpers/FFProbeHelper.cs index 5b6b423..eed1b7a 100644 --- a/FFMpegCore/Helpers/FFProbeHelper.cs +++ b/FFMpegCore/Helpers/FFProbeHelper.cs @@ -1,4 +1,4 @@ -using FFMpegCore.FFMPEG.Exceptions; +using FFMpegCore.Exceptions; namespace FFMpegCore.Helpers {