From 2fe9395cc6d3aa31acd2fa4b71b3023d3a411460 Mon Sep 17 00:00:00 2001 From: blaze-developer Date: Tue, 17 Mar 2026 15:54:49 -0700 Subject: [PATCH 1/3] Sync Videos at end of auto --- src/hub/controllers/VideoController.ts | 21 ++++++++++++--------- src/main/electron/VideoProcessor.ts | 10 +++++----- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/hub/controllers/VideoController.ts b/src/hub/controllers/VideoController.ts index 773bef8ee..b4ade87c4 100644 --- a/src/hub/controllers/VideoController.ts +++ b/src/hub/controllers/VideoController.ts @@ -35,7 +35,7 @@ export default class VideoController implements TabController { private fps: number | null = null; private totalFrames: number | null = null; private completedFrames: number | null = null; - private matchStartFrame = -1; + private autoEndFrame = -1; private locked: boolean = false; private lockedStartLog: number = 0; @@ -328,24 +328,27 @@ export default class VideoController implements TabController { } // Lock time when match start frame received - if (this.matchStartFrame <= 0 && data.matchStartFrame > 0 && !this.locked) { - let enabledTime: number | null = null; + if (this.autoEndFrame <= 0 && data.autoEndFrame > 0 && !this.locked) { + let autoEndTime: number | null = null; let enabledData = getEnabledData(window.log); - if (enabledData) { + if (enabledData && enabledData) { + let wasEnabledLastCycle: boolean = false; for (let i = 0; i < enabledData.timestamps.length; i++) { - if (enabledData.values[i]) { - enabledTime = enabledData.timestamps[i]; + if (wasEnabledLastCycle && !enabledData.values[i]) { + autoEndTime = enabledData.timestamps[i]; break; } + + wasEnabledLastCycle = enabledData.values[i]; } } - if (enabledTime !== null) { + if (autoEndTime !== null) { this.playing = false; this.locked = true; - this.lockedStartLog = enabledTime - (data.matchStartFrame - 1) / this.fps!; + this.lockedStartLog = autoEndTime - (data.autoEndFrame - 1) / this.fps!; } } - this.matchStartFrame = data.matchStartFrame; + this.autoEndFrame = data.autoEndFrame; } else { // Start to load new source, reset controls this.locked = false; diff --git a/src/main/electron/VideoProcessor.ts b/src/main/electron/VideoProcessor.ts index 02481088f..eaaf100bf 100644 --- a/src/main/electron/VideoProcessor.ts +++ b/src/main/electron/VideoProcessor.ts @@ -340,7 +340,7 @@ export class VideoProcessor { let height = 0; let durationSecs = 0; let completedFrames = 0; - let matchStartFrame = -1; + let autoEndFrame = -1; let timerSample = 0; let timerValues: { frame: number; text: string }[] = []; let timerStartFound = false; @@ -462,10 +462,10 @@ export class VideoProcessor { } const results = await Promise.all(jobs); results.forEach((timerText, index) => { - if (matchStartFrame > 0) return; + if (autoEndFrame > 0) return; if (timerText.includes("12")) { let secs12Frame = secs13Frame! + index; - matchStartFrame = Math.round(secs12Frame - fps * 3); + autoEndFrame = Math.round(secs12Frame + fps * 12); } }); } @@ -481,7 +481,7 @@ export class VideoProcessor { fps: fps, totalFrames: Math.round(durationSecs * fps), completedFrames: completedFrames, - matchStartFrame: matchStartFrame + autoEndFrame: autoEndFrame }); } }); @@ -496,7 +496,7 @@ export class VideoProcessor { fps: fps, totalFrames: completedFrames, // In case original value was inaccurate completedFrames: completedFrames, - matchStartFrame: matchStartFrame + autoEndFrame: autoEndFrame }); } else if (code === 1) { if (videoCache === VIDEO_CACHE && fullOutput.includes("No space left on device")) { From 5c5b81a5ea4ed462e4ea12073ce67991a56b6e9a Mon Sep 17 00:00:00 2001 From: blaze-developer Date: Sat, 21 Mar 2026 19:24:04 -0700 Subject: [PATCH 2/3] Search for smaller numbers to reduce latency adding up --- src/main/electron/VideoProcessor.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/electron/VideoProcessor.ts b/src/main/electron/VideoProcessor.ts index eaaf100bf..6bea5565e 100644 --- a/src/main/electron/VideoProcessor.ts +++ b/src/main/electron/VideoProcessor.ts @@ -440,32 +440,32 @@ export class VideoProcessor { timerValues.push({ frame: sampleFrame, text: timerText }); timerValues.sort((a, b) => a.frame - b.frame); - // Search for 13 -> 12 transition - let lastIs13 = false; - let secs13Frame: number | null = null; + // Search for 4 -> 3 transition + let lastIs4 = false; + let secs4Frame: number | null = null; for (let i = 0; i < timerValues.length; i++) { - let is13 = timerValues[i].text.includes("13"); - let is12 = !is13 && timerValues[i].text.includes("12"); - if (lastIs13 && is12) { - secs13Frame = timerValues[i - 1].frame; + let is4 = timerValues[i].text.includes("04"); + let is3 = !is4 && timerValues[i].text.includes("03"); + if (lastIs4 && is3) { + secs4Frame = timerValues[i - 1].frame; break; } - lastIs13 = is13; + lastIs4 = is4; } - if (secs13Frame === null) return; + if (secs4Frame === null) return; timerStartFound = true; // Find exact frame let jobs: Promise[] = []; - for (let frame = secs13Frame; frame < secs13Frame + fps; frame++) { + for (let frame = secs4Frame; frame < secs4Frame + fps; frame++) { jobs.push(this.readTimerText(cachePath + zfill(frame.toString(), 8) + ".jpg", width, height)); } const results = await Promise.all(jobs); results.forEach((timerText, index) => { if (autoEndFrame > 0) return; - if (timerText.includes("12")) { - let secs12Frame = secs13Frame! + index; - autoEndFrame = Math.round(secs12Frame + fps * 12); + if (timerText.includes("03")) { + let secs3Frame = secs4Frame! + index; + autoEndFrame = Math.round(secs3Frame + fps * 3); } }); } From 2dc51f3ae94c9b3486327f2d16df9b5541e05f99 Mon Sep 17 00:00:00 2001 From: blaze-developer Date: Sun, 22 Mar 2026 00:11:11 -0700 Subject: [PATCH 3/3] Check formatting, fix double check. Finalize --- src/hub/controllers/VideoController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hub/controllers/VideoController.ts b/src/hub/controllers/VideoController.ts index b4ade87c4..48c8af141 100644 --- a/src/hub/controllers/VideoController.ts +++ b/src/hub/controllers/VideoController.ts @@ -331,7 +331,7 @@ export default class VideoController implements TabController { if (this.autoEndFrame <= 0 && data.autoEndFrame > 0 && !this.locked) { let autoEndTime: number | null = null; let enabledData = getEnabledData(window.log); - if (enabledData && enabledData) { + if (enabledData) { let wasEnabledLastCycle: boolean = false; for (let i = 0; i < enabledData.timestamps.length; i++) { if (wasEnabledLastCycle && !enabledData.values[i]) {