From 0afc4cab41d2e6737bb1ddb83643417753f1d2f2 Mon Sep 17 00:00:00 2001 From: ConfusedPolarBear <33811686+ConfusedPolarBear@users.noreply.github.com> Date: Tue, 29 Nov 2022 20:11:22 -0600 Subject: [PATCH] Add minimum end credit duration --- .../TestBlackFrames.cs | 4 +++- .../Analyzers/BlackFrameAnalyzer.cs | 2 +- .../Configuration/PluginConfiguration.cs | 5 +++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ConfusedPolarBear.Plugin.IntroSkipper.Tests/TestBlackFrames.cs b/ConfusedPolarBear.Plugin.IntroSkipper.Tests/TestBlackFrames.cs index bdd34e5..16caf27 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper.Tests/TestBlackFrames.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper.Tests/TestBlackFrames.cs @@ -30,6 +30,8 @@ public void TestBlackFrameDetection() [FactSkipFFmpegTests] public void TestEndCreditDetection() { + var range = 1; + var analyzer = CreateBlackFrameAnalyzer(); var episode = queueFile("credits.mp4"); @@ -37,7 +39,7 @@ public void TestEndCreditDetection() var result = analyzer.AnalyzeMediaFile(episode, AnalysisMode.Credits, 85); Assert.NotNull(result); - Assert.Equal(300, result.IntroStart); + Assert.InRange(result.IntroStart, 300 - range, 300 + range); } private QueuedEpisode queueFile(string path) diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/BlackFrameAnalyzer.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/BlackFrameAnalyzer.cs index ba2ee30..89a4018 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/BlackFrameAnalyzer.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Analyzers/BlackFrameAnalyzer.cs @@ -80,7 +80,7 @@ public ReadOnlyCollection AnalyzeMediaFiles( // Start by analyzing the last N minutes of the file. var start = TimeSpan.FromSeconds(config.MaximumEpisodeCreditsDuration); - var end = TimeSpan.Zero; + var end = TimeSpan.FromSeconds(config.MinimumCreditsDuration); var firstFrameTime = 0.0; // Continue bisecting the end of the file until the range that contains the first black diff --git a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs index 463d5b6..d6b38bb 100644 --- a/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs +++ b/ConfusedPolarBear.Plugin.IntroSkipper/Configuration/PluginConfiguration.cs @@ -72,6 +72,11 @@ public PluginConfiguration() /// public int MaximumIntroDuration { get; set; } = 120; + /// + /// Gets or sets the minimum length of similar audio that will be considered ending credits. + /// + public int MinimumCreditsDuration { get; set; } = 15; + /// /// Gets or sets the upper limit (in seconds) on the length of each episode's audio track that will be analyzed when searching for ending credits. ///