mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-10 08:34:12 +01:00
parent
9434715fba
commit
ca1035fde2
5 changed files with 47 additions and 1 deletions
|
@ -61,6 +61,19 @@ public void Builder_BuildString_BitStream()
|
||||||
var str = FFMpegArguments.FromFileInput("input.mp4").OutputToFile("output.mp4", false, opt => opt.WithBitStreamFilter(Channel.Audio, Filter.H264_Mp4ToAnnexB)).Arguments;
|
var str = FFMpegArguments.FromFileInput("input.mp4").OutputToFile("output.mp4", false, opt => opt.WithBitStreamFilter(Channel.Audio, Filter.H264_Mp4ToAnnexB)).Arguments;
|
||||||
Assert.AreEqual("-i \"input.mp4\" -bsf:a h264_mp4toannexb \"output.mp4\"", str);
|
Assert.AreEqual("-i \"input.mp4\" -bsf:a h264_mp4toannexb \"output.mp4\"", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void Builder_BuildString_HardwareAcceleration_Auto()
|
||||||
|
{
|
||||||
|
var str = FFMpegArguments.FromFileInput("input.mp4").OutputToFile("output.mp4", false, opt => opt.WithHardwareAcceleration()).Arguments;
|
||||||
|
Assert.AreEqual("-i \"input.mp4\" -hwaccel \"output.mp4\"", str);
|
||||||
|
}
|
||||||
|
[TestMethod]
|
||||||
|
public void Builder_BuildString_HardwareAcceleration_Specific()
|
||||||
|
{
|
||||||
|
var str = FFMpegArguments.FromFileInput("input.mp4").OutputToFile("output.mp4", false, opt => opt.WithHardwareAcceleration(HardwareAccelerationDevice.CUVID)).Arguments;
|
||||||
|
Assert.AreEqual("-i \"input.mp4\" -hwaccel cuvid \"output.mp4\"", str);
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Builder_BuildString_Concat()
|
public void Builder_BuildString_Concat()
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace FFMpegCore.Arguments
|
||||||
{
|
{
|
||||||
public class ForcePixelFormat : IArgument
|
public class ForcePixelFormat : IArgument
|
||||||
{
|
{
|
||||||
public string PixelFormat { get; private set; }
|
public string PixelFormat { get; }
|
||||||
public string Text => $"-pix_fmt {PixelFormat}";
|
public string Text => $"-pix_fmt {PixelFormat}";
|
||||||
|
|
||||||
public ForcePixelFormat(string format)
|
public ForcePixelFormat(string format)
|
||||||
|
|
18
FFMpegCore/FFMpeg/Arguments/HardwareAccelerationArgument.cs
Normal file
18
FFMpegCore/FFMpeg/Arguments/HardwareAccelerationArgument.cs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
using FFMpegCore.Enums;
|
||||||
|
|
||||||
|
namespace FFMpegCore.Arguments
|
||||||
|
{
|
||||||
|
public class HardwareAccelerationArgument : IArgument
|
||||||
|
{
|
||||||
|
public HardwareAccelerationDevice HardwareAccelerationDevice { get; }
|
||||||
|
|
||||||
|
public HardwareAccelerationArgument(HardwareAccelerationDevice hardwareAccelerationDevice)
|
||||||
|
{
|
||||||
|
HardwareAccelerationDevice = hardwareAccelerationDevice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Text => HardwareAccelerationDevice != HardwareAccelerationDevice.Auto
|
||||||
|
? $"-hwaccel {HardwareAccelerationDevice.ToString().ToLower()}"
|
||||||
|
: "-hwaccel";
|
||||||
|
}
|
||||||
|
}
|
14
FFMpegCore/FFMpeg/Enums/HardwareAccelerationDevice.cs
Normal file
14
FFMpegCore/FFMpeg/Enums/HardwareAccelerationDevice.cs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
namespace FFMpegCore.Enums
|
||||||
|
{
|
||||||
|
public enum HardwareAccelerationDevice
|
||||||
|
{
|
||||||
|
Auto,
|
||||||
|
D3D11VA,
|
||||||
|
DXVA2,
|
||||||
|
QSV,
|
||||||
|
CUVID,
|
||||||
|
VDPAU,
|
||||||
|
VAAPI,
|
||||||
|
LibMFX
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,6 +31,7 @@ internal FFMpegArgumentOptions() { }
|
||||||
public FFMpegArgumentOptions WithDuration(TimeSpan? duration) => WithArgument(new DurationArgument(duration));
|
public FFMpegArgumentOptions WithDuration(TimeSpan? duration) => WithArgument(new DurationArgument(duration));
|
||||||
public FFMpegArgumentOptions WithFastStart() => WithArgument(new FaststartArgument());
|
public FFMpegArgumentOptions WithFastStart() => WithArgument(new FaststartArgument());
|
||||||
public FFMpegArgumentOptions WithFrameOutputCount(int frames) => WithArgument(new FrameOutputCountArgument(frames));
|
public FFMpegArgumentOptions WithFrameOutputCount(int frames) => WithArgument(new FrameOutputCountArgument(frames));
|
||||||
|
public FFMpegArgumentOptions WithHardwareAcceleration(HardwareAccelerationDevice hardwareAccelerationDevice = HardwareAccelerationDevice.Auto) => WithArgument(new HardwareAccelerationArgument(hardwareAccelerationDevice));
|
||||||
|
|
||||||
public FFMpegArgumentOptions UsingShortest(bool shortest = true) => WithArgument(new ShortestArgument(shortest));
|
public FFMpegArgumentOptions UsingShortest(bool shortest = true) => WithArgument(new ShortestArgument(shortest));
|
||||||
public FFMpegArgumentOptions UsingMultithreading(bool multithread) => WithArgument(new ThreadsArgument(multithread));
|
public FFMpegArgumentOptions UsingMultithreading(bool multithread) => WithArgument(new ThreadsArgument(multithread));
|
||||||
|
|
Loading…
Reference in a new issue