public void Should_Return_Software_Video_Filter( bool deinterlace, bool scale, bool pad, string expectedVideoFilter, string expectedVideoLabel) { FFmpegComplexFilterBuilder builder = new FFmpegComplexFilterBuilder() .WithDeinterlace(deinterlace); if (scale) { builder = builder.WithScaling(new Resolution { Width = 1920, Height = 1000 }); } if (pad) { builder = builder.WithBlackBars(new Resolution { Width = 1920, Height = 1080 }); } Option <FFmpegComplexFilter> result = builder.Build(false, 0, 0, 0, 1, false); result.IsSome.Should().BeTrue(); result.IfSome( filter => { filter.ComplexFilter.Should().Be(expectedVideoFilter); filter.AudioLabel.Should().Be("0:1"); filter.VideoLabel.Should().Be(expectedVideoLabel); }); }
public void Should_Return_VAAPI_Video_Filter( string codec, bool deinterlace, bool scale, bool pad, string expectedVideoFilter, string expectedVideoLabel) { FFmpegComplexFilterBuilder builder = new FFmpegComplexFilterBuilder() .WithHardwareAcceleration(HardwareAccelerationKind.Vaapi) .WithInputCodec(codec) .WithDeinterlace(deinterlace); if (scale) { builder = builder.WithScaling(new Resolution { Width = 1920, Height = 1000 }); } if (pad) { builder = builder.WithBlackBars(new Resolution { Width = 1920, Height = 1080 }); } Option <FFmpegComplexFilter> result = builder.Build(); result.IsSome.Should().BeTrue(); result.IfSome( filter => { filter.ComplexFilter.Should().Be(expectedVideoFilter); filter.AudioLabel.Should().Be("0:a"); filter.VideoLabel.Should().Be(expectedVideoLabel); }); }
public void Should_Return_NVENC_Watermark( bool alignAudio, bool deinterlace, bool intermittent, WatermarkLocation location, bool scaled, int opacity, string expectedVideoFilter, string expectedAudioLabel, string expectedVideoLabel, bool scaledSource) { var watermark = new ChannelWatermark { Mode = intermittent ? ChannelWatermarkMode.Intermittent : ChannelWatermarkMode.Permanent, DurationSeconds = intermittent ? 15 : 0, FrequencyMinutes = intermittent ? 10 : 0, Location = location, Size = scaled ? WatermarkSize.Scaled : WatermarkSize.ActualSize, WidthPercent = scaled ? 20 : 0, Opacity = opacity, HorizontalMarginPercent = 7, VerticalMarginPercent = 5 }; Option <List <FadePoint> > maybeFadePoints = watermark.Mode == ChannelWatermarkMode.Intermittent ? Some( WatermarkCalculator.CalculateFadePoints( new DateTimeOffset(2022, 01, 31, 12, 25, 0, TimeSpan.FromHours(-5)), TimeSpan.Zero, TimeSpan.FromMinutes(55), TimeSpan.Zero, watermark.FrequencyMinutes, watermark.DurationSeconds)) : None; FFmpegComplexFilterBuilder builder = new FFmpegComplexFilterBuilder() .WithHardwareAcceleration(HardwareAccelerationKind.Nvenc) .WithWatermark( Some(watermark), maybeFadePoints, new Resolution { Width = 1920, Height = 1080 }, None) .WithDeinterlace(deinterlace) .WithAlignedAudio(alignAudio ? Some(TimeSpan.FromMinutes(55)) : None); if (scaledSource) { builder = builder.WithScaling(new Resolution { Width = 1920, Height = 1080 }); } Option <FFmpegComplexFilter> result = builder.Build(false, 0, 0, 0, 1, false); result.IsSome.Should().BeTrue(); result.IfSome( filter => { filter.ComplexFilter.Should().Be(expectedVideoFilter); filter.AudioLabel.Should().Be(expectedAudioLabel); filter.VideoLabel.Should().Be(expectedVideoLabel); }); }