mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 08:34:12 +01:00
Cleanup
This commit is contained in:
parent
821044f33d
commit
72366d573a
73 changed files with 238 additions and 137 deletions
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using FFMpegCore.FFMPEG;
|
||||
using FFMpegCore.Test.Resources;
|
||||
using FFMpegCore.Test.Resources;
|
||||
using System.IO;
|
||||
|
||||
namespace FFMpegCore.Test
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using FFMpegCore.FFMPEG;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Newtonsoft.Json;
|
||||
using System.IO;
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using FFMpegCore.FFMPEG;
|
||||
|
||||
namespace FFMpegCore.Extend
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using FFMpegCore.FFMPEG;
|
||||
|
||||
namespace FFMpegCore.Extend
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
/// <summary>
|
||||
/// Audio sampling rate argument. Defaults to 48000 (Hz)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using FFMpegCore.FFMPEG.Enums;
|
||||
using FFMpegCore.Enums;
|
||||
|
||||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents parameter of bitstream filter
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
|
||||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
/// <summary>
|
||||
/// Constant Rate Factor (CRF) argument
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using FFMpegCore.FFMPEG.Enums;
|
||||
using FFMpegCore.Enums;
|
||||
|
||||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents parameter of copy parameter
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents cpu speed parameter
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
public class CustomArgument : IArgument
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
/// <summary>
|
||||
/// 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);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
|
||||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents duration parameter
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
/// <summary>
|
||||
/// Faststart argument - for moving moov atom to the start of file
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using FFMpegCore.FFMPEG.Enums;
|
||||
using FFMpegCore.Enums;
|
||||
|
||||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents force format parameter
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents frame rate parameter
|
||||
|
|
|
@ -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 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() {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents loop parameter
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents overwrite parameter
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
public class QuietArgument : IArgument
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
/// <summary>
|
||||
/// Remove metadata argument
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
|
||||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents seek parameter
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents shortest parameter
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using FFMpegCore.FFMPEG.Enums;
|
||||
using FFMpegCore.Enums;
|
||||
|
||||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents speed parameter
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents start number parameter
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
|
||||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents threads parameter
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using FFMpegCore.FFMPEG.Enums;
|
||||
using FFMpegCore.Enums;
|
||||
|
||||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
/// <summary>
|
||||
/// Transpose argument.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
|
||||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
/// <summary>
|
||||
/// Variable Bitrate Argument (VBR) argument
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents video bitrate parameter
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using FFMpegCore.FFMPEG.Enums;
|
||||
using FFMpegCore.Enums;
|
||||
|
||||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore.Arguments
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents video codec parameter
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace FFMpegCore.FFMPEG.Enums
|
||||
namespace FFMpegCore.Enums
|
||||
{
|
||||
public enum AudioQuality
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace FFMpegCore.FFMPEG.Enums
|
||||
namespace FFMpegCore.Enums
|
||||
{
|
||||
public enum VideoCodec
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace FFMpegCore.FFMPEG.Enums
|
||||
namespace FFMpegCore.Enums
|
||||
{
|
||||
public enum Speed
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace FFMpegCore.FFMPEG.Enums
|
||||
namespace FFMpegCore.Enums
|
||||
{
|
||||
public enum Transposition
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
namespace FFMpegCore.FFMPEG.Enums
|
||||
namespace FFMpegCore.Enums
|
||||
{
|
||||
public enum VideoSize
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
|
||||
namespace FFMpegCore.FFMPEG.Exceptions
|
||||
namespace FFMpegCore.Exceptions
|
||||
{
|
||||
public enum FFMpegExceptionType
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
using FFMpegCore.Helpers;
|
||||
using Instances;
|
||||
|
||||
namespace FFMpegCore.FFMPEG.Argument
|
||||
namespace FFMpegCore
|
||||
{
|
||||
public class FFMpegArgumentProcessor
|
||||
{
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace FFMpegCore.FFMPEG
|
||||
namespace FFMpegCore
|
||||
{
|
||||
public class FFMpegOptions
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace FFMpegCore.FFMPEG.Pipes
|
||||
namespace FFMpegCore.Pipes
|
||||
{
|
||||
public interface IPipeDataReader
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace FFMpegCore.FFMPEG.Pipes
|
||||
namespace FFMpegCore.Pipes
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface for ffmpeg pipe source data IO
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace FFMpegCore.FFMPEG.Pipes
|
||||
namespace FFMpegCore.Pipes
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface for Video frame
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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}"/>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System.Threading.Tasks;
|
||||
|
||||
namespace FFMpegCore.FFMPEG.Pipes
|
||||
namespace FFMpegCore.Pipes
|
||||
{
|
||||
public class StreamPipeDataReader : IPipeDataReader
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
3
FFMpegCore/FFMpegCore.csproj.DotSettings
Normal file
3
FFMpegCore/FFMpegCore.csproj.DotSettings
Normal 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>
|
|
@ -1,4 +1,4 @@
|
|||
namespace FFMpegCore.FFMPEG
|
||||
namespace FFMpegCore
|
||||
{
|
||||
public class AudioStream : MediaStream
|
||||
{
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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!;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
|
||||
namespace FFMpegCore.FFMPEG
|
||||
namespace FFMpegCore
|
||||
{
|
||||
public class MediaStream
|
||||
{
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using FFMpegCore.FFMPEG.Exceptions;
|
||||
using FFMpegCore.Exceptions;
|
||||
|
||||
namespace FFMpegCore.Helpers
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue