Update black frame and chapter analyzer
This commit is contained in:
parent
3e2dc377b7
commit
cb234bedd3
@ -76,8 +76,10 @@ public class BlackFrameAnalyzer : IMediaFileAnalyzer
|
|||||||
/// <returns>Credits timestamp.</returns>
|
/// <returns>Credits timestamp.</returns>
|
||||||
public Intro? AnalyzeMediaFile(QueuedEpisode episode, AnalysisMode mode, int minimum)
|
public Intro? AnalyzeMediaFile(QueuedEpisode episode, AnalysisMode mode, int minimum)
|
||||||
{
|
{
|
||||||
// Start by analyzing the last four minutes of the file.
|
var config = Plugin.Instance?.Configuration ?? new Configuration.PluginConfiguration();
|
||||||
var start = TimeSpan.FromMinutes(4);
|
|
||||||
|
// Start by analyzing the last N minutes of the file.
|
||||||
|
var start = TimeSpan.FromSeconds(config.MaximumEpisodeCreditsDuration);
|
||||||
var end = TimeSpan.Zero;
|
var end = TimeSpan.Zero;
|
||||||
var firstFrameTime = 0.0;
|
var firstFrameTime = 0.0;
|
||||||
|
|
||||||
@ -100,7 +102,11 @@ public class BlackFrameAnalyzer : IMediaFileAnalyzer
|
|||||||
tr.End);
|
tr.End);
|
||||||
|
|
||||||
var frames = FFmpegWrapper.DetectBlackFrames(episode, tr, minimum);
|
var frames = FFmpegWrapper.DetectBlackFrames(episode, tr, minimum);
|
||||||
_logger.LogTrace("{Episode}, black frames: {Count}", episode.Name, frames.Length);
|
_logger.LogTrace(
|
||||||
|
"{Episode} at {Start} has {Count} black frames",
|
||||||
|
episode.Name,
|
||||||
|
tr.Start,
|
||||||
|
frames.Length);
|
||||||
|
|
||||||
if (frames.Length == 0)
|
if (frames.Length == 0)
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@ -31,7 +32,6 @@ public class ChapterAnalyzer : IMediaFileAnalyzer
|
|||||||
AnalysisMode mode,
|
AnalysisMode mode,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var unsuccessful = new List<QueuedEpisode>();
|
|
||||||
var skippableRanges = new Dictionary<Guid, Intro>();
|
var skippableRanges = new Dictionary<Guid, Intro>();
|
||||||
|
|
||||||
var expression = mode == AnalysisMode.Introduction ?
|
var expression = mode == AnalysisMode.Introduction ?
|
||||||
@ -53,7 +53,6 @@ public class ChapterAnalyzer : IMediaFileAnalyzer
|
|||||||
|
|
||||||
if (skipRange is null)
|
if (skipRange is null)
|
||||||
{
|
{
|
||||||
unsuccessful.Add(episode);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +61,10 @@ public class ChapterAnalyzer : IMediaFileAnalyzer
|
|||||||
|
|
||||||
Plugin.Instance!.UpdateTimestamps(skippableRanges, mode);
|
Plugin.Instance!.UpdateTimestamps(skippableRanges, mode);
|
||||||
|
|
||||||
return unsuccessful.AsReadOnly();
|
return analysisQueue
|
||||||
|
.Where(x => !skippableRanges.ContainsKey(x.EpisodeId))
|
||||||
|
.ToList()
|
||||||
|
.AsReadOnly();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -33,12 +33,12 @@ public class QueuedEpisode
|
|||||||
public string Name { get; set; } = string.Empty;
|
public string Name { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the timestamp (in seconds) to stop searching for an introduction.
|
/// Gets or sets the timestamp (in seconds) to stop searching for an introduction at.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int IntroFingerprintEnd { get; set; }
|
public int IntroFingerprintEnd { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the timestamp (in seconds) to start looking for end credits.
|
/// Gets or sets the timestamp (in seconds) to start looking for end credits at.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int CreditsFingerprintStart { get; set; }
|
public int CreditsFingerprintStart { get; set; }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user