Former-commit-id: 72366d573a
This commit is contained in:
Malte Rosenbjerg 2020-05-09 17:53:03 +02:00
parent e8dcdc2238
commit c3b5cd997e
73 changed files with 238 additions and 137 deletions

View file

@ -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()
{
@ -171,6 +241,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()
{

View file

@ -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
{

View file

@ -1,5 +1,4 @@
using FFMpegCore.FFMPEG;
using FFMpegCore.Test.Resources;
using FFMpegCore.Test.Resources;
using System.IO;
namespace FFMpegCore.Test

View file

@ -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
{

View file

@ -1,5 +1,4 @@
using FFMpegCore.FFMPEG;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using System.IO;

View file

@ -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]

View file

@ -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
{

View file

@ -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
{

View file

@ -1,7 +1,6 @@
using System;
using System.Drawing;
using System.IO;
using FFMpegCore.FFMPEG;
namespace FFMpegCore.Extend
{

View file

@ -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);

View file

@ -1,5 +1,4 @@
using System;
using FFMpegCore.FFMPEG;
namespace FFMpegCore.Extend
{

View file

@ -1,6 +1,6 @@
using FFMpegCore.FFMPEG.Enums;
using FFMpegCore.Enums;
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Represents parameter of audio codec and it's quality

View file

@ -1,6 +1,6 @@
using FFMpegCore.FFMPEG.Enums;
using FFMpegCore.Enums;
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Represents parameter of audio codec and it's quality

View file

@ -1,4 +1,4 @@
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Audio sampling rate argument. Defaults to 48000 (Hz)

View file

@ -1,6 +1,6 @@
using FFMpegCore.FFMPEG.Enums;
using FFMpegCore.Enums;
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Represents parameter of bitstream filter

View file

@ -1,6 +1,6 @@
using System.Collections.Generic;
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>

View file

@ -1,6 +1,6 @@
using System;
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Constant Rate Factor (CRF) argument

View file

@ -1,6 +1,6 @@
using FFMpegCore.FFMPEG.Enums;
using FFMpegCore.Enums;
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Represents parameter of copy parameter

View file

@ -1,4 +1,4 @@
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Represents cpu speed parameter

View file

@ -1,4 +1,4 @@
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
public class CustomArgument : IArgument
{

View file

@ -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
{
/// <summary>
/// Represents cpu speed parameter

View file

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Drawtext video filter argument
@ -10,9 +10,6 @@ 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)
{
Options = 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);
}

View file

@ -1,6 +1,6 @@
using System;
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Represents duration parameter

View file

@ -1,4 +1,4 @@
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Faststart argument - for moving moov atom to the start of file

View file

@ -1,6 +1,6 @@
using FFMpegCore.FFMPEG.Enums;
using FFMpegCore.Enums;
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Represents force format parameter

View file

@ -1,4 +1,4 @@
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// 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;

View file

@ -1,4 +1,4 @@
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Represents frame rate parameter

View file

@ -4,7 +4,7 @@
using System.Threading;
using System.Threading.Tasks;
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Represents input parameter
@ -41,19 +41,23 @@ public void Pre()
public interface IArgument
{
/// <summary>
/// The textual representation of the argument
/// </summary>
string Text { get; }
}
public interface IInputArgument : IArgument
public interface IInputOutputArgument : IArgument
{
void Pre() {}
Task During(CancellationToken? cancellationToken = null) => Task.CompletedTask;
void Post() {}
}
public interface IOutputArgument : IArgument
public interface IInputArgument : IInputOutputArgument
{
}
public interface IOutputArgument : IInputOutputArgument
{
void Pre() {}
Task During(CancellationToken? cancellationToken = null) => Task.CompletedTask;
void Post() {}
}
}

View file

@ -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
{
/// <summary>
/// Represents input parameter for a named pipe

View file

@ -1,4 +1,4 @@
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Represents loop parameter

View file

@ -1,8 +1,8 @@
using System;
using System.IO;
using FFMpegCore.FFMPEG.Exceptions;
using FFMpegCore.Exceptions;
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Represents output parameter

View file

@ -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
{

View file

@ -1,4 +1,4 @@
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Represents overwrite parameter

View file

@ -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
{

View file

@ -1,4 +1,4 @@
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
public class QuietArgument : IArgument
{

View file

@ -1,4 +1,4 @@
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Remove metadata argument

View file

@ -1,7 +1,7 @@
using System.Drawing;
using FFMpegCore.FFMPEG.Enums;
using FFMpegCore.Enums;
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Represents scale parameter

View file

@ -1,6 +1,6 @@
using System;
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Represents seek parameter

View file

@ -1,4 +1,4 @@
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Represents shortest parameter

View file

@ -1,7 +1,7 @@
using System.Drawing;
using FFMpegCore.FFMPEG.Enums;
using FFMpegCore.Enums;
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Represents size parameter

View file

@ -1,6 +1,6 @@
using FFMpegCore.FFMPEG.Enums;
using FFMpegCore.Enums;
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Represents speed parameter

View file

@ -1,4 +1,4 @@
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Represents start number parameter

View file

@ -1,6 +1,6 @@
using System;
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Represents threads parameter

View file

@ -1,6 +1,6 @@
using FFMpegCore.FFMPEG.Enums;
using FFMpegCore.Enums;
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Transpose argument.

View file

@ -1,6 +1,6 @@
using System;
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Variable Bitrate Argument (VBR) argument

View file

@ -1,4 +1,4 @@
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Represents video bitrate parameter

View file

@ -1,6 +1,6 @@
using FFMpegCore.FFMPEG.Enums;
using FFMpegCore.Enums;
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore.Arguments
{
/// <summary>
/// Represents video codec parameter

View file

@ -1,4 +1,4 @@
namespace FFMpegCore.FFMPEG.Enums
namespace FFMpegCore.Enums
{
public enum AudioQuality
{

View file

@ -1,4 +1,4 @@
namespace FFMpegCore.FFMPEG.Enums
namespace FFMpegCore.Enums
{
public enum VideoCodec
{

View file

@ -1,4 +1,4 @@
namespace FFMpegCore.FFMPEG.Enums
namespace FFMpegCore.Enums
{
public enum Speed
{

View file

@ -1,4 +1,4 @@
namespace FFMpegCore.FFMPEG.Enums
namespace FFMpegCore.Enums
{
public enum Transposition
{

View file

@ -1,4 +1,4 @@
namespace FFMpegCore.FFMPEG.Enums
namespace FFMpegCore.Enums
{
public enum VideoSize
{

View file

@ -1,6 +1,6 @@
using System;
namespace FFMpegCore.FFMPEG.Exceptions
namespace FFMpegCore.Exceptions
{
public enum FFMpegExceptionType
{

View file

@ -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;

View file

@ -7,7 +7,7 @@
using FFMpegCore.Helpers;
using Instances;
namespace FFMpegCore.FFMPEG.Argument
namespace FFMpegCore
{
public class FFMpegArgumentProcessor
{

View file

@ -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());

View file

@ -3,7 +3,7 @@
using System.Runtime.InteropServices;
using System.Text.Json;
namespace FFMpegCore.FFMPEG
namespace FFMpegCore
{
public class FFMpegOptions
{

View file

@ -1,6 +1,6 @@
using System.Threading.Tasks;
namespace FFMpegCore.FFMPEG.Pipes
namespace FFMpegCore.Pipes
{
public interface IPipeDataReader
{

View file

@ -1,6 +1,6 @@
using System.Threading.Tasks;
namespace FFMpegCore.FFMPEG.Pipes
namespace FFMpegCore.Pipes
{
/// <summary>
/// Interface for ffmpeg pipe source data IO

View file

@ -1,6 +1,6 @@
using System.Threading.Tasks;
namespace FFMpegCore.FFMPEG.Pipes
namespace FFMpegCore.Pipes
{
/// <summary>
/// Interface for Video frame

View file

@ -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)
{
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
}
}
}

View file

@ -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
{
/// <summary>
/// Implementation of <see cref="IPipeDataWriter"/> for a raw video stream that is gathered from <see cref="IEnumerator{IVideoFrame}"/>

View file

@ -1,6 +1,6 @@
using System.Threading.Tasks;
namespace FFMpegCore.FFMPEG.Pipes
namespace FFMpegCore.Pipes
{
public class StreamPipeDataReader : IPipeDataReader
{

View file

@ -1,6 +1,6 @@
using System.Threading.Tasks;
namespace FFMpegCore.FFMPEG.Pipes
namespace FFMpegCore.Pipes
{
/// <summary>
/// Implementation of <see cref="IPipeDataWriter"/> used for stream redirection

View file

@ -0,0 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=ffmpeg/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=ffprobe/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

View file

@ -1,4 +1,4 @@
namespace FFMpegCore.FFMPEG
namespace FFMpegCore
{
public class AudioStream : MediaStream
{

View file

@ -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
{

View file

@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace FFMpegCore.FFMPEG
namespace FFMpegCore
{
public class FFProbeAnalysis
{
@ -38,9 +38,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!;

View file

@ -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);
}
}
}

View file

@ -1,6 +1,6 @@
using System;
namespace FFMpegCore.FFMPEG
namespace FFMpegCore
{
public class MediaStream
{

View file

@ -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; }

View file

@ -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
{

View file

@ -1,4 +1,4 @@
using FFMpegCore.FFMPEG.Exceptions;
using FFMpegCore.Exceptions;
namespace FFMpegCore.Helpers
{