mirror of
https://github.com/rosenbjerg/FFMpegCore.git
synced 2026-01-15 01:15:45 +00:00
Merge fc78b6ec8f into cc75e03ec9
This commit is contained in:
commit
0f095c3cea
2 changed files with 79 additions and 2 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using FFMpegCore.Arguments;
|
using FFMpegCore.Arguments;
|
||||||
using FFMpegCore.Enums;
|
using FFMpegCore.Enums;
|
||||||
|
using FFMpegCore.Exceptions;
|
||||||
using FFMpegCore.Pipes;
|
using FFMpegCore.Pipes;
|
||||||
|
|
||||||
namespace FFMpegCore.Test;
|
namespace FFMpegCore.Test;
|
||||||
|
|
@ -141,6 +142,62 @@ public class ArgumentBuilderTest
|
||||||
Assert.AreEqual("-i \"input.mp4\" -vn \"output.mp4\"", str);
|
Assert.AreEqual("-i \"input.mp4\" -vn \"output.mp4\"", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void Builder_BuildString_DisableChannel_Subtitle()
|
||||||
|
{
|
||||||
|
var str = FFMpegArguments.FromFileInput("input.mp4")
|
||||||
|
.OutputToFile("output.mp4", false, opt => opt.DisableChannel(Channel.Subtitle)).Arguments;
|
||||||
|
Assert.AreEqual("-i \"input.mp4\" -sn \"output.mp4\"", str);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void Builder_BuildString_DisableChannel_Data()
|
||||||
|
{
|
||||||
|
var str = FFMpegArguments.FromFileInput("input.mp4")
|
||||||
|
.OutputToFile("output.mp4", false, opt => opt.DisableChannel(Channel.Data)).Arguments;
|
||||||
|
Assert.AreEqual("-i \"input.mp4\" -dn \"output.mp4\"", str);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void Builder_BuildString_DisableChannel_Multiple()
|
||||||
|
{
|
||||||
|
var str = FFMpegArguments.FromFileInput("input.mp4")
|
||||||
|
.OutputToFile("output.mp4", false, opt => opt.DisableChannel(Channel.Audio).DisableChannel(Channel.Video)).Arguments;
|
||||||
|
Assert.AreEqual("-i \"input.mp4\" -an -vn \"output.mp4\"", str);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void Builder_BuildString_DisableChannel_Both_InvalidChannel()
|
||||||
|
{
|
||||||
|
Assert.ThrowsExactly<FFMpegException>(() => FFMpegArguments
|
||||||
|
.FromFileInput("input.mp4")
|
||||||
|
.OutputToFile("output.mp4", false, opt => opt.DisableChannel(Channel.Both)).Arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void Builder_BuildString_DisableChannel_All_InvalidChannel()
|
||||||
|
{
|
||||||
|
Assert.ThrowsExactly<FFMpegException>(() => FFMpegArguments
|
||||||
|
.FromFileInput("input.mp4")
|
||||||
|
.OutputToFile("output.mp4", false, opt => opt.DisableChannel(Channel.All)).Arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void Builder_BuildString_DisableChannel_Attachments_UnsupportedChannel()
|
||||||
|
{
|
||||||
|
Assert.ThrowsExactly<FFMpegException>(() => FFMpegArguments
|
||||||
|
.FromFileInput("input.mp4")
|
||||||
|
.OutputToFile("output.mp4", false, opt => opt.DisableChannel(Channel.Attachments)).Arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void Builder_BuildString_DisableChannel_VideoNoAttachedPic_UnsupportedChannel()
|
||||||
|
{
|
||||||
|
Assert.ThrowsExactly<FFMpegException>(() => FFMpegArguments
|
||||||
|
.FromFileInput("input.mp4")
|
||||||
|
.OutputToFile("output.mp4", false, opt => opt.DisableChannel(Channel.VideoNoAttachedPic)).Arguments);
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Builder_BuildString_AudioSamplingRate_Default()
|
public void Builder_BuildString_AudioSamplingRate_Default()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,8 @@ using FFMpegCore.Exceptions;
|
||||||
namespace FFMpegCore.Arguments;
|
namespace FFMpegCore.Arguments;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents cpu speed parameter
|
/// Represents channel disabling parameter
|
||||||
|
/// Used to disable processing of all streams of a particular type so that they are not filtered, automatically selected or mapped for any input or output
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DisableChannelArgument : IArgument
|
public class DisableChannelArgument : IArgument
|
||||||
{
|
{
|
||||||
|
|
@ -12,9 +13,26 @@ public class DisableChannelArgument : IArgument
|
||||||
|
|
||||||
public DisableChannelArgument(Channel channel)
|
public DisableChannelArgument(Channel channel)
|
||||||
{
|
{
|
||||||
|
if (channel == Channel.All)
|
||||||
|
{
|
||||||
|
throw new FFMpegException(FFMpegExceptionType.Conversion, "Cannot disable all channels");
|
||||||
|
}
|
||||||
|
|
||||||
if (channel == Channel.Both)
|
if (channel == Channel.Both)
|
||||||
{
|
{
|
||||||
throw new FFMpegException(FFMpegExceptionType.Conversion, "Cannot disable both channels");
|
throw new FFMpegException(FFMpegExceptionType.Conversion, "Cannot disable both video and audio channels at once");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (channel == Channel.Attachments)
|
||||||
|
{
|
||||||
|
// ffmpeg does not support disabling attachment streams
|
||||||
|
throw new FFMpegException(FFMpegExceptionType.Operation, $"{nameof(Channel.Attachments)} channel cannot be disabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (channel == Channel.VideoNoAttachedPic)
|
||||||
|
{
|
||||||
|
// ffmpeg does not support disabling no-picture-filtered video steams
|
||||||
|
throw new FFMpegException(FFMpegExceptionType.Operation, $"{nameof(Channel.VideoNoAttachedPic)} channel cannot be disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel = channel;
|
Channel = channel;
|
||||||
|
|
@ -24,6 +42,8 @@ public class DisableChannelArgument : IArgument
|
||||||
{
|
{
|
||||||
Channel.Video => "-vn",
|
Channel.Video => "-vn",
|
||||||
Channel.Audio => "-an",
|
Channel.Audio => "-an",
|
||||||
|
Channel.Subtitle => "-sn",
|
||||||
|
Channel.Data => "-dn",
|
||||||
_ => string.Empty
|
_ => string.Empty
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue