mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2024-11-14 02:04:14 +01:00
Add HardwareAccelerationArgument
This commit is contained in:
parent
010e9947e9
commit
5fb2305b5b
5 changed files with 47 additions and 1 deletions
|
@ -62,6 +62,19 @@ public void Builder_BuildString_BitStream()
|
||||||
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