Add phash generation and dupe checking (#1158)

This commit is contained in:
InfiniteTF
2021-04-12 01:04:40 +02:00
committed by GitHub
parent a2582047ca
commit c38660d209
70 changed files with 4342 additions and 214 deletions

View File

@@ -222,6 +222,7 @@ func (s *singleton) Scan(input models.ScanMetadataInput) {
GeneratePreview: utils.IsTrue(input.ScanGeneratePreviews),
GenerateImagePreview: utils.IsTrue(input.ScanGenerateImagePreviews),
GenerateSprite: utils.IsTrue(input.ScanGenerateSprites),
GeneratePhash: utils.IsTrue(input.ScanGeneratePhashes),
}
go task.Start(&wg)
@@ -427,7 +428,7 @@ func (s *singleton) Generate(input models.GenerateMetadataInput) {
logger.Infof("Taking too long to count content. Skipping...")
logger.Infof("Generating content")
} else {
logger.Infof("Generating %d sprites %d previews %d image previews %d markers %d transcodes", totalsNeeded.sprites, totalsNeeded.previews, totalsNeeded.imagePreviews, totalsNeeded.markers, totalsNeeded.transcodes)
logger.Infof("Generating %d sprites %d previews %d image previews %d markers %d transcodes %d phashes", totalsNeeded.sprites, totalsNeeded.previews, totalsNeeded.imagePreviews, totalsNeeded.markers, totalsNeeded.transcodes, totalsNeeded.phashes)
}
fileNamingAlgo := config.GetVideoFileNamingAlgorithm()
@@ -501,6 +502,16 @@ func (s *singleton) Generate(input models.GenerateMetadataInput) {
}
go task.Start(&wg)
}
if input.Phashes {
task := GeneratePhashTask{
Scene: *scene,
fileNamingAlgorithm: fileNamingAlgo,
txnManager: s.TxnManager,
}
wg.Add()
go task.Start(&wg)
}
}
wg.Wait()
@@ -992,6 +1003,7 @@ type totalsGenerate struct {
imagePreviews int64
markers int64
transcodes int64
phashes int64
}
func (s *singleton) neededGenerate(scenes []*models.Scene, input models.GenerateMetadataInput) *totalsGenerate {
@@ -1065,6 +1077,17 @@ func (s *singleton) neededGenerate(scenes []*models.Scene, input models.Generate
totals.transcodes++
}
}
if input.Phashes {
task := GeneratePhashTask{
Scene: *scene,
fileNamingAlgorithm: fileNamingAlgo,
}
if task.shouldGenerate() {
totals.phashes++
}
}
}
//check for timeout
select {