Skip to content

Commit

Permalink
Added blackdetect and blackframe arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Thodoris Koskinopoulos authored and rosenbjerg committed Jan 31, 2023
1 parent 4262fb2 commit 7f72625
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
14 changes: 14 additions & 0 deletions FFMpegCore/FFMpeg/Arguments/BlackDetectArgument.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace FFMpegCore.Arguments
{
public class BlackDetectArgument : IVideoFilterArgument
{
public string Key => "blackdetect";

public string Value { get; }

public BlackDetectArgument(double minimumDuration = 2.0, double pictureBlackRatioThreshold = 0.98, double pixelBlackThreshold = 0.1)
{
Value = $"d={minimumDuration}:pic_th={pictureBlackRatioThreshold}:pix_th={pixelBlackThreshold}";
}
}
}
14 changes: 14 additions & 0 deletions FFMpegCore/FFMpeg/Arguments/BlackFrameArgument.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace FFMpegCore.Arguments
{
internal class BlackFrameArgument : IVideoFilterArgument
{
public string Key => "blackframe";

public string Value { get; }

public BlackFrameArgument(int amount = 98, int threshold = 32)
{
Value = $"amount={amount}:threshold={threshold}";
}
}
}
2 changes: 2 additions & 0 deletions FFMpegCore/FFMpeg/Arguments/VideoFiltersArgument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public class VideoFilterOptions
public VideoFilterOptions Mirror(Mirroring mirroring) => WithArgument(new SetMirroringArgument(mirroring));
public VideoFilterOptions DrawText(DrawTextOptions drawTextOptions) => WithArgument(new DrawTextArgument(drawTextOptions));
public VideoFilterOptions HardBurnSubtitle(SubtitleHardBurnOptions subtitleHardBurnOptions) => WithArgument(new SubtitleHardBurnArgument(subtitleHardBurnOptions));
public VideoFilterOptions BlackDetect(double minimumDuration = 2.0, double pictureBlackRatioThreshold = 0.98, double pixelBlackThreshold = 0.1) => WithArgument(new BlackDetectArgument(minimumDuration, pictureBlackRatioThreshold, pixelBlackThreshold));
public VideoFilterOptions BlackFrame(int amount = 98, int threshold = 32) => WithArgument(new BlackFrameArgument(amount, threshold));

private VideoFilterOptions WithArgument(IVideoFilterArgument argument)
{
Expand Down

0 comments on commit 7f72625

Please sign in to comment.