Skip to content

Commit

Permalink
Setup error checking - Adds method to compare timecodes in a thumbnai…
Browse files Browse the repository at this point in the history
…l chache and cache the results
  • Loading branch information
Agrarvolution committed Feb 22, 2024
1 parent 694955e commit 740bca5
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/jsx/KBRG/CacheThumbnails.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,22 @@ CacheThumbnails.prototype.extractTimecodeFromThumbnail = function (thumb, search
return true;
}

CacheThumbnails.prototype.compareTimecodes = function (timecodes) {
var result = {};

for (var i = 0; i < this.mediaCache.length; i++) {
var comparisonCache = this.mediaCache[i].updateThumbnailMetadata(timecodes);

if (comparisonCache && this.logging ?
true :
!comparisonCache.isMatching //error only
) {
result.push(comparisonCache);
}
}

return result;
}
// -----------------
// Process methods
// -----------------
Expand Down
8 changes: 8 additions & 0 deletions src/jsx/KBRG/KBRG_TimecodeCorrection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ Agrarvolution.timecodeCorrection = {
return false;
}

//check processing
var checkCache = new CacheThumbnails(parameters);
if (parameters.logging) {

} else {

}

Agrarvolution.logToCEP("Time formats for " + processedMedia + " media thumbnails have been updated.",
Agrarvolution.logLevels.status, parameters.logTarget, parameters.logging);
return true;
Expand Down
24 changes: 22 additions & 2 deletions src/jsx/KBRG/ThumbnailMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ ThumbnailMetadata.prototype.updateFromTimecodes = function (updates, enableMedia
return false;
}

var update = this.compareTimecode(updates, enableMediaStartComparison);
var update = this.compareInTimecodeUpdates(updates, enableMediaStartComparison);

if (update) {
return this.updateFromTimecode(update.audioTC, overrideFramerate);
Expand Down Expand Up @@ -327,7 +327,7 @@ ThumbnailMetadata.prototype.updateTimecodeMetadata = function (newStartTime) {
* @param {boolean} enableMediaStartComparison
* @returns {object|undefined} on successfull match returns the matching object in the timecodes array
*/
ThumbnailMetadata.prototype.compareTimecode = function (timecodes, enableMediaStartComparison) {
ThumbnailMetadata.prototype.compareInTimecodeUpdates = function (timecodes, enableMediaStartComparison) {
for (var i = 0; i < timecodes.length; i++) {
if (timecodes[i].fileTC
&& timecodes[i].fileTC instanceof Timecode
Expand Down Expand Up @@ -365,6 +365,26 @@ ThumbnailMetadata.prototype.updateThumbnailMetadata = function () {
return true;
}

/**
* Checks the thumbnail metadata for matching timecodes. Returns an object if a matching filename is contained within the timecodes array.
* @param {array} timecodes
* @returns {object} containing essential data for reprocessing
*/
ThumbnailMetadata.prototype.checkMatchingStartTimecodes = function (timecodes) {
var matchedTimecode = this.compareInTimecodeUpdates(timecodes, false); //enableMediaStartComparison has to be disabled, otherwise no errors will be detected

if (matchedTimecode === undefined) {
return undefined;
}

return {
filename: this.filename,
isMatching: matchedTimecode.fileTC === this.timecodeMetadata.startTime,
fileTC: this.timecodeMetadata.startTime,
audioTC: matchedTimecode.fileTC
}
}

/**
* Validates framerates read from metadata.
* Returns 0 if the framerate was not a number.
Expand Down

0 comments on commit 740bca5

Please sign in to comment.