Add minimum end credit duration

This commit is contained in:
ConfusedPolarBear 2022-11-29 20:11:22 -06:00
parent 16251f0735
commit 0afc4cab41
3 changed files with 9 additions and 2 deletions

View File

@ -30,6 +30,8 @@ public class TestBlackFrames
[FactSkipFFmpegTests] [FactSkipFFmpegTests]
public void TestEndCreditDetection() public void TestEndCreditDetection()
{ {
var range = 1;
var analyzer = CreateBlackFrameAnalyzer(); var analyzer = CreateBlackFrameAnalyzer();
var episode = queueFile("credits.mp4"); var episode = queueFile("credits.mp4");
@ -37,7 +39,7 @@ public class TestBlackFrames
var result = analyzer.AnalyzeMediaFile(episode, AnalysisMode.Credits, 85); var result = analyzer.AnalyzeMediaFile(episode, AnalysisMode.Credits, 85);
Assert.NotNull(result); Assert.NotNull(result);
Assert.Equal(300, result.IntroStart); Assert.InRange(result.IntroStart, 300 - range, 300 + range);
} }
private QueuedEpisode queueFile(string path) private QueuedEpisode queueFile(string path)

View File

@ -80,7 +80,7 @@ public class BlackFrameAnalyzer : IMediaFileAnalyzer
// Start by analyzing the last N minutes of the file. // Start by analyzing the last N minutes of the file.
var start = TimeSpan.FromSeconds(config.MaximumEpisodeCreditsDuration); var start = TimeSpan.FromSeconds(config.MaximumEpisodeCreditsDuration);
var end = TimeSpan.Zero; var end = TimeSpan.FromSeconds(config.MinimumCreditsDuration);
var firstFrameTime = 0.0; var firstFrameTime = 0.0;
// Continue bisecting the end of the file until the range that contains the first black // Continue bisecting the end of the file until the range that contains the first black

View File

@ -72,6 +72,11 @@ public class PluginConfiguration : BasePluginConfiguration
/// </summary> /// </summary>
public int MaximumIntroDuration { get; set; } = 120; public int MaximumIntroDuration { get; set; } = 120;
/// <summary>
/// Gets or sets the minimum length of similar audio that will be considered ending credits.
/// </summary>
public int MinimumCreditsDuration { get; set; } = 15;
/// <summary> /// <summary>
/// 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. /// 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.
/// </summary> /// </summary>