mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-05-31 12:14:21 -04:00
Don't extract chapter images if chapters are <1s long on average (#11832)
This commit is contained in:
parent
62712aa12c
commit
6b646e24ea
@ -91,8 +91,30 @@ namespace Emby.Server.Implementations.MediaEncoder
|
|||||||
return video.DefaultVideoStreamIndex.HasValue;
|
return video.DefaultVideoStreamIndex.HasValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private long GetAverageDurationBetweenChapters(IReadOnlyList<ChapterInfo> chapters)
|
||||||
|
{
|
||||||
|
if (chapters.Count < 2)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
long sum = 0;
|
||||||
|
for (int i = 1; i < chapters.Count; i++)
|
||||||
|
{
|
||||||
|
sum += chapters[i].StartPositionTicks - chapters[i - 1].StartPositionTicks;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sum / chapters.Count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<bool> RefreshChapterImages(Video video, IDirectoryService directoryService, IReadOnlyList<ChapterInfo> chapters, bool extractImages, bool saveChapters, CancellationToken cancellationToken)
|
public async Task<bool> RefreshChapterImages(Video video, IDirectoryService directoryService, IReadOnlyList<ChapterInfo> chapters, bool extractImages, bool saveChapters, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
if (chapters.Count == 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
var libraryOptions = _libraryManager.GetLibraryOptions(video);
|
var libraryOptions = _libraryManager.GetLibraryOptions(video);
|
||||||
|
|
||||||
if (!IsEligibleForChapterImageExtraction(video, libraryOptions))
|
if (!IsEligibleForChapterImageExtraction(video, libraryOptions))
|
||||||
@ -100,6 +122,14 @@ namespace Emby.Server.Implementations.MediaEncoder
|
|||||||
extractImages = false;
|
extractImages = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var averageChapterDuration = GetAverageDurationBetweenChapters(chapters);
|
||||||
|
var threshold = TimeSpan.FromSeconds(1).Ticks;
|
||||||
|
if (averageChapterDuration < threshold)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Skipping chapter image extraction for {Video} as the average chapter duration {AverageDuration} was lower than the minimum threshold {Threshold}", video.Name, averageChapterDuration, threshold);
|
||||||
|
extractImages = false;
|
||||||
|
}
|
||||||
|
|
||||||
var success = true;
|
var success = true;
|
||||||
var changesMade = false;
|
var changesMade = false;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user