using System.Collections.Generic; using ErsatzTV.FFmpeg.Capabilities; using NUnit.Framework; using Shouldly; namespace ErsatzTV.FFmpeg.Tests.Capabilities; [TestFixture] public class FFmpegFilterOptionParserTests { // stock ffmpeg vpp_qsv, without the pad_w/pad_h/pad_x/pad_y/pad_color options private const string WithoutPadOptions = @"Filter vpp_qsv Quick Sync Video VPP. Inputs: #0: default (video) Outputs: #0: default (video) vpp_qsv AVOptions: deinterlace ..FV....... deinterlace mode (from 0 to 2) (default 0) bob 1 ..FV....... Get one frame for each field advanced 2 ..FV....... Get one frame for each frame denoise ..FV....... denoise level [0, 100] (from 0 to 100) (default 0) framerate ..FV....... output framerate (from 0 to DBL_MAX) (default 0/1) w ..FV....... Output video width h ..FV....... Output video height format ..FV....... Output pixel format async_depth ..FV....... Internal parallelization depth (from 0 to INT_MAX) (default 4) scale_mode ..FV....... scaling mode (from 0 to 2) (default 0) "; // patched ffmpeg vpp_qsv, carrying the pad_w/pad_h/pad_x/pad_y/pad_color options private const string WithPadOptions = @"Filter vpp_qsv Quick Sync Video VPP. Inputs: #0: default (video) Outputs: #0: default (video) vpp_qsv AVOptions: deinterlace ..FV....... deinterlace mode (from 0 to 2) (default 0) bob 1 ..FV....... Get one frame for each field advanced 2 ..FV....... Get one frame for each frame denoise ..FV....... denoise level [0, 100] (from 0 to 100) (default 0) framerate ..FV....... output framerate (from 0 to DBL_MAX) (default 0/1) w ..FV....... Output video width h ..FV....... Output video height format ..FV....... Output pixel format async_depth ..FV....... Internal parallelization depth (from 0 to INT_MAX) (default 4) scale_mode ..FV....... scaling mode (from 0 to 2) (default 0) pad_w ..FV....... Padded width (from 0 to 8192) (default 0) pad_h ..FV....... Padded height (from 0 to 8192) (default 0) pad_x ..FV....... Horizontal position (from -1 to 8192) (default -1) pad_y ..FV....... Vertical position (from -1 to 8192) (default -1) pad_color ..FV....... Padding color (default ""black"") "; [Test] public void Should_Parse_Option_Names() { IReadOnlySet options = FFmpegFilterOptionParser.Parse(WithoutPadOptions); options.ShouldContain("deinterlace"); options.ShouldContain("denoise"); options.ShouldContain("framerate"); options.ShouldContain("w"); options.ShouldContain("h"); options.ShouldContain("format"); } [Test] public void Should_Not_Parse_Enum_Constants() { IReadOnlySet options = FFmpegFilterOptionParser.Parse(WithoutPadOptions); options.ShouldNotContain("bob"); options.ShouldNotContain("advanced"); } [Test] public void Should_Detect_Pad_Options_When_Present() { IReadOnlySet options = FFmpegFilterOptionParser.Parse(WithPadOptions); options.ShouldContain("pad_w"); options.ShouldContain("pad_h"); options.ShouldContain("pad_x"); options.ShouldContain("pad_y"); options.ShouldContain("pad_color"); } [Test] public void Should_Not_Detect_Pad_Options_When_Absent() { IReadOnlySet options = FFmpegFilterOptionParser.Parse(WithoutPadOptions); options.ShouldNotContain("pad_w"); options.ShouldNotContain("pad_h"); options.ShouldNotContain("pad_color"); } }