Skip to content

Create polished demo videos without editing skills. Mac/Windows/Linux

chore: Finalize PR #116 stability and privacy improvements

Mahdy Arief933d8041180a
diff --cc .gitignore
index d3a2eb14,bc75a52a..a817d16a
--- a/.gitignore
+++ b/.gitignore
@@@ -1,42 -1,41 +1,47 @@@
- # Logs
- logs
- *.log
- npm-debug.log*
- yarn-debug.log*
- yarn-error.log*
- pnpm-debug.log*
- lerna-debug.log*
-
- node_modules
- dist
- dist-electron
- dist-ssr
- *.local
-
- # Editor directories and files
- .vscode/*
- !.vscode/extensions.json
- .idea
- .DS_Store
- *.suo
- *.ntvs*
- *.njsproj
- *.sln
- *.sw?
- release/**
- *.kiro/
- # npx electron-builder --mac --win
- .tmp/
- .history/
- *.tsbuildinfo
- vite.config.js
- vite.config.d.ts
-
- # Native capture build artifacts
- electron/native/wgc-capture/build/
- electron/native/cursor-monitor/build/
-
- # Local build tools and caches
- .cache/
- .cmake_ext/
- ebcache/
+ # Logs
+ logs
+ *.log
+ npm-debug.log*
+ yarn-debug.log*
-yarn-error.log*
-pnpm-debug.log*
-lerna-debug.log*
-
-node_modules
-dist
-dist-electron
-dist-ssr
-*.local
-
-# Editor directories and files
-.vscode/*
-!.vscode/extensions.json
-.idea
-.DS_Store
-*.suo
-*.ntvs*
-*.njsproj
-*.sln
-*.sw?
-release/**
-*.kiro/
-# npx electron-builder --mac --win
-.tmp/
-.history/
-*.tsbuildinfo
++yarn-error.log*
++pnpm-debug.log*
++lerna-debug.log*
++
++node_modules
++dist
++dist-electron
++dist-ssr
++*.local
++
++# Editor directories and files
++.vscode/*
++!.vscode/extensions.json
++.idea
++.DS_Store
++*.suo
++*.ntvs*
++*.njsproj
++*.sln
++*.sw?
++release/**
++*.kiro/
++# npx electron-builder --mac --win
++.tmp/
++.history/
++*.tsbuildinfo
+ vite.config.js
+ vite.config.d.ts
+
+ # Native capture build artifacts
+ electron/native/wgc-capture/build/
+ electron/native/cursor-monitor/build/
+
++# Local build tools and caches
++.cache/
++.cmake_ext/
++ebcache/
++docs/
++
+ # Local debug helpers
+ tmp-*.ps1
+ .tmp-*.ps1
diff --cc electron-builder.json5
index 138f2183,0fd0b26e..677d0a38
--- a/electron-builder.json5
+++ b/electron-builder.json5
@@@ -63,9 -62,9 +63,8 @@@
"target": [
"nsis"
],
- "icon": "icons/icons/win/icon.ico"
- ,
- "artifactName": "Recordly.exe"
+ "icon": "icons/icons/win/icon.ico",
+ "executableName": "Recordly",
- "artifactName": "${productName}-Setup-${version}.${ext}"
++ "artifactName": "Recordly.${ext}"
}
--}
--
++}
diff --cc electron/ipc/handlers.ts
index f159ccad,4aea0572..f871ddfd
--- a/electron/ipc/handlers.ts
+++ b/electron/ipc/handlers.ts
@@@ -85,11 -46,17 +85,15 @@@ function getScreen()
return nodeRequire('electron').screen as typeof import('electron').screen
}
+ function normalizeRecordingTimeOffsetMs(value: unknown): number {
+ return typeof value === 'number' && Number.isFinite(value)
+ ? Math.round(value)
+ : 0
+ }
+
function broadcastSelectedSourceChange() {
for (const window of BrowserWindow.getAllWindows()) {
-- if (!window.isDestroyed()) {
-- window.webContents.send('selected-source-changed', selectedSource)
-- }
++ safeSend(window.webContents, 'selected-source-changed', selectedSource)
}
}
@@@ -999,72 -952,28 +989,80 @@@ function getFfmpegBinaryPath()
return ffmpegStatic
}
-function sendWhisperModelDownloadProgress(
- webContents: Electron.WebContents,
- payload: { status: 'idle' | 'downloading' | 'downloaded' | 'error'; progress: number; path?: string | null; error?: string },
-) {
- webContents.send('whisper-small-model-download-progress', payload)
+function runWhisperWithProgress(
+ executablePath: string,
+ args: string[],
+ onProgress: (progress: number) => void,
+): Promise<void> {
+ return new Promise((resolve, reject) => {
+ const proc = spawn(executablePath, args);
+ let output = "";
+
+ proc.stdout?.on("data", (data) => {
+ output += data.toString();
+ });
+
+ proc.stderr?.on("data", (data) => {
+ const text = data.toString();
+ output += text;
+ // whisper.cpp variants use this pattern on stderr
+ const match = text.match(/progress\s*=\s*(\d+)%/i);
+ if (match) {
+ onProgress(parseInt(match[1], 10));
+ }
+ });
+
+ proc.on("close", (code) => {
+ if (code === 0) {
+ resolve();
+ } else {
+ reject(new Error(output.trim() || `Whisper exited with code ${code}`));
+ }
+ });
+
+ proc.on("error", (err) => {
+ reject(err);
+ });
+ });
+}
+
++function safeSend(webContents: Electron.WebContents | undefined, channel: string, ...args: any[]) {
++ if (webContents && !webContents.isDestroyed()) {
++ webContents.send(channel, ...args)
++ }
+ }
+
-async function getWhisperSmallModelStatus() {
- try {
- await fs.access(WHISPER_SMALL_MODEL_PATH, fsConstants.R_OK)
- return {
- success: true,
- exists: true,
- path: WHISPER_SMALL_MODEL_PATH,
- }
- } catch {
- return {
- success: true,
- exists: false,
- path: null,
- }
- }
++type WhisperModelDownloadStatus = {
++ status: "idle" | "downloading" | "downloaded" | "error";
++ progress: number;
++ model: string;
++ path?: string | null;
++ error?: string;
++}
++
+function sendWhisperModelDownloadProgress(
- webContents: Electron.WebContents,
- payload: {
- status: "idle" | "downloading" | "downloaded" | "error";
- progress: number;
- model: string;
- path?: string | null;
- error?: string;
- },
++ webContents: Electron.WebContents | undefined,
++ progress: WhisperModelDownloadStatus,
+) {
- webContents.send("whisper-model-download-progress", payload);
++ safeSend(webContents, 'whisper-model-download-progress', progress)
+}
+
+async function getWhisperModelStatus(_event: any, modelName: string) {
+ try {
+ const modelPath = getWhisperModelPath(modelName);
+ await fs.access(modelPath, fsConstants.R_OK);
+ return {
+ success: true,
+ exists: true,
+ path: modelPath,
+ };
+ } catch {
+ return {
+ success: true,
+ exists: false,
+ path: null,
+ };
+ }
}
function downloadFileWithProgress(
@@@ -1116,7 -1025,7 +1114,9 @@@
reject(error)
})
-- fileStream.on('finish', () => {
++ // On Windows, the 'finish' event might fire before the OS has fully released the file handle.
++ // We listen for 'close' to be absolutely sure the file descriptor is closed.
++ fileStream.on('close', () => {
onProgress(100)
resolve()
})
@@@ -1131,60 -1040,46 +1131,75 @@@
return request(url)
}
-async function downloadWhisperSmallModel(webContents: Electron.WebContents) {
- await fs.mkdir(WHISPER_MODEL_DIR, { recursive: true })
- const tempPath = `${WHISPER_SMALL_MODEL_PATH}.download`
-
- sendWhisperModelDownloadProgress(webContents, {
- status: 'downloading',
- progress: 0,
- path: null,
- })
+async function downloadWhisperModel(
+ webContents: Electron.WebContents,
+ modelName: string,
+) {
+ const model = WHISPER_MODELS[modelName as keyof typeof WHISPER_MODELS];
+ if (!model) {
+ throw new Error(`Unsupported Whisper model: ${modelName}`);
+ }
+
+ await fs.mkdir(WHISPER_MODEL_DIR, { recursive: true });
+ const modelPath = getWhisperModelPath(modelName);
+ const tempPath = `${modelPath}.download`;
+
+ sendWhisperModelDownloadProgress(webContents, {
+ status: "downloading",
+ progress: 0,
+ model: modelName,
+ path: null,
+ });
- try {
- await fs.rm(tempPath, { force: true });
- await downloadFileWithProgress(model.url, tempPath, (progress) => {
- sendWhisperModelDownloadProgress(webContents, {
- status: "downloading",
- progress,
- model: modelName,
- path: null,
- });
- });
- await fs.rename(tempPath, modelPath);
- sendWhisperModelDownloadProgress(webContents, {
- status: "downloaded",
- progress: 100,
- model: modelName,
- path: modelPath,
- });
- return modelPath;
- } catch (error) {
- await fs.rm(tempPath, { force: true }).catch(() => undefined);
- sendWhisperModelDownloadProgress(webContents, {
- status: "error",
- progress: 0,
- model: modelName,
- path: null,
- error: String(error),
- });
- throw error;
- }
+ try {
- await fs.rm(tempPath, { force: true })
- await downloadFileWithProgress(WHISPER_MODEL_DOWNLOAD_URL, tempPath, (progress) => {
++ await fs.rm(tempPath, { force: true }).catch(() => undefined)
++ await downloadFileWithProgress(model.url, tempPath, (progress) => {
+ sendWhisperModelDownloadProgress(webContents, {
+ status: 'downloading',
+ progress,
++ model: modelName,
+ path: null,
+ })
+ })
- await fs.rename(tempPath, WHISPER_SMALL_MODEL_PATH)
++
++ // Robust rename logic for Windows to avoid EPERM/EBUSY
++ let renameRetries = 0
++ const maxRetries = 5
++ while (renameRetries < maxRetries) {
++ try {
++ await fs.rename(tempPath, modelPath)
++ break
++ } catch (err) {
++ renameRetries++
++ if (renameRetries >= maxRetries) throw err
++ // Wait briefly between retries to allow OS to release file handles
++ await new Promise((resolve) => setTimeout(resolve, 100 * renameRetries))
++ }
++ }
++
+ sendWhisperModelDownloadProgress(webContents, {
+ status: 'downloaded',
+ progress: 100,
- path: WHISPER_SMALL_MODEL_PATH,
++ model: modelName,
++ path: modelPath,
+ })
- return WHISPER_SMALL_MODEL_PATH
++ return modelPath
+ } catch (error) {
+ await fs.rm(tempPath, { force: true }).catch(() => undefined)
+ sendWhisperModelDownloadProgress(webContents, {
+ status: 'error',
+ progress: 0,
++ model: modelName,
+ path: null,
+ error: String(error),
+ })
+ throw error
+ }
}
-async function deleteWhisperSmallModel() {
- await fs.rm(WHISPER_SMALL_MODEL_PATH, { force: true })
+async function deleteWhisperModel(_event: any, modelName: string) {
+ const modelPath = getWhisperModelPath(modelName);
+ await fs.rm(modelPath, { force: true });
}
function parseSrtTimestamp(value: string) {
@@@ -1488,23 -1381,11 +1503,23 @@@ async function extractCaptionAudioSourc
for (const candidate of candidates) {
try {
await ensureReadableFile(candidate.path, 'video file')
- console.log('[auto-captions] Extracting audio from:', candidate.path, options.startTime ? `at ${options.startTime}s` : '')
++ console.log('[auto-captions] Extracting audio from:', path.basename(candidate.path), options.startTime ? `at ${options.startTime}s` : '')
+
+ const ffmpegArgs = ['-y'];
+ if (options.startTime !== undefined) {
+ ffmpegArgs.push('-ss', options.startTime.toString());
+ }
+ if (options.duration !== undefined) {
+ ffmpegArgs.push('-t', options.duration.toString());
+ }
+ ffmpegArgs.push('-i', candidate.path, '-map', '0:a:0', '-vn', '-ac', '1', '-ar', '16000', '-c:a', 'pcm_s16le', options.wavPath);
+
await execFileAsync(
options.ffmpegPath,
- ['-y', '-i', candidate.path, '-map', '0:a:0', '-vn', '-ac', '1', '-ar', '16000', '-c:a', 'pcm_s16le', options.wavPath],
+ ffmpegArgs,
{ timeout: 5 * 60 * 1000, maxBuffer: 20 * 1024 * 1024 },
)
- console.log('[auto-captions] Audio extracted successfully to:', options.wavPath)
++ console.log('[auto-captions] Audio extracted successfully to temporary workspace')
attemptedCandidates.push({ ...candidate, readable: true, extractedAudio: true })
return candidate
} catch (error) {
@@@ -1518,7 -1399,7 +1533,7 @@@
}
}
-- console.warn('[auto-captions] No audio source candidate could be extracted:', attemptedCandidates)
++ console.warn('[auto-captions] No audio source candidate could be extracted')
throw new Error('No audio was found to transcribe in the saved recording file. Captions need an audio track. If this recording should have contained sound, the recording was saved without an audio stream.')
}
@@@ -1545,130 -1421,68 +1560,122 @@@ async function generateAutoCaptionsFrom
await ensureReadableFile(whisperExecutablePath, 'whisper executable')
await ensureReadableFile(whisperModelPath, 'whisper model')
- const tempBase = path.join(app.getPath('temp'), `recordly-captions-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`)
- const wavPath = `${tempBase}.wav`
- const outputBase = `${tempBase}-whisper`
- const srtPath = `${outputBase}.srt`
- const jsonPath = `${outputBase}.json`
+ // Constants for segmentation
+ const CHUNK_SIZE_MS = 5 * 60 * 1000; // 5 minutes
+ const OVERLAP_MS = 10 * 1000; // 10 seconds overlap for word boundaries
+
+ const startTimeMs = options.startTimeMs || 0;
+ const totalDurationMs = options.durationMs || 0;
+ const endTimeMs = totalDurationMs > 0 ? startTimeMs + totalDurationMs : Infinity;
+
+ console.log('[auto-captions] Starting segmented caption generation sequence')
- console.log('[auto-captions] Video:', normalizedVideoPath)
++ console.log('[auto-captions] Video:', path.basename(normalizedVideoPath))
+ console.log('[auto-captions] Range:', `${(startTimeMs/1000).toFixed(2)}s - ${totalDurationMs ? `${((startTimeMs + totalDurationMs)/1000).toFixed(2)}s` : 'End'}`)
+
+ const allCues: any[] = [];
- let chunkCount = 1;
- if (totalDurationMs > 0) {
- chunkCount = Math.ceil(totalDurationMs / CHUNK_SIZE_MS);
- }
-
+ let audioSourceLabel = 'Unknown';
+
+ for (let offsetMs = startTimeMs; offsetMs < endTimeMs; offsetMs += CHUNK_SIZE_MS) {
+ const chunkIndex = Math.floor((offsetMs - startTimeMs) / CHUNK_SIZE_MS);
+ const tempBase = path.join(app.getPath('temp'), `recordly-captions-chunk-${chunkIndex}-${Date.now()}`)
+ const wavPath = `${tempBase}.wav`
+ const outputBase = `${tempBase}-whisper`
+ const srtPath = `${outputBase}.srt`
+ const jsonPath = `${outputBase}.json`
- try {
- const audioSource = await extractCaptionAudioSource({
- videoPath: normalizedVideoPath,
- ffmpegPath,
- wavPath,
- })
-
- const language = options.language && options.language.trim() ? options.language.trim() : 'auto'
- const whisperBaseArgs = [
- '-m', whisperModelPath,
- '-f', wavPath,
- '-osrt',
- '-of', outputBase,
- '-l', language,
- '-np',
- ]
-
- let jsonEnabled = true
try {
- console.log(`[auto-captions] Processing chunk ${chunkIndex + 1}/${chunkCount || '?'} at offset ${offsetMs / 1000}s`)
- await execFileAsync(whisperExecutablePath, [...whisperBaseArgs, '-ojf'], {
- timeout: 30 * 60 * 1000,
- maxBuffer: 20 * 1024 * 1024,
+
+ const audioSource = await extractCaptionAudioSource({
+ videoPath: normalizedVideoPath,
+ ffmpegPath,
+ wavPath,
+ startTime: offsetMs / 1000,
+ duration: (CHUNK_SIZE_MS + OVERLAP_MS) / 1000
})
- } catch (error) {
- if (!shouldRetryWhisperWithoutJson(error)) {
- throw error
+ audioSourceLabel = audioSource.label;
+
+ const language = options.language && options.language.trim() ? options.language.trim() : 'auto'
+ const whisperBaseArgs = [
+ '-m', whisperModelPath,
+ '-f', wavPath,
+ '-osrt',
+ '-of', outputBase,
+ '-l', language,
+ '-np',
+ ]
+
+ let jsonEnabled = true
+ const updateChunkProgress = (progress: number) => {
+ if (totalDurationMs > 0) {
+ const totalProgress = (offsetMs / totalDurationMs * 100) + (progress / (totalDurationMs / CHUNK_SIZE_MS));
- webContents.send('auto-caption-progress', { progress: Math.min(99, totalProgress) })
++ safeSend(webContents, 'auto-caption-progress', { progress: Math.min(99, totalProgress) })
+ } else {
- webContents.send('auto-caption-progress', { progress })
++ safeSend(webContents, 'auto-caption-progress', { progress })
+ }
+ };
+
+ try {
+ await runWhisperWithProgress(whisperExecutablePath, [...whisperBaseArgs, '-ojf'], updateChunkProgress)
+ } catch (error) {
+ if (!shouldRetryWhisperWithoutJson(error)) throw error
+ jsonEnabled = false
+ console.warn(`[auto-captions] Whisper runtime error, retrying with SRT: ${error}`)
+ await runWhisperWithProgress(whisperExecutablePath, whisperBaseArgs, updateChunkProgress)
}
- jsonEnabled = false
- console.warn('[auto-captions] Whisper runtime does not support JSON full output, retrying with SRT only:', error)
- await execFileAsync(whisperExecutablePath, whisperBaseArgs, {
- timeout: 30 * 60 * 1000,
- maxBuffer: 20 * 1024 * 1024,
- })
- }
+ let cues = jsonEnabled
+ ? parseWhisperJsonCues(await fs.readFile(jsonPath, 'utf-8'))
+ : parseSrtCues(await fs.readFile(srtPath, 'utf-8'))
+
+ if (cues.length === 0 && !jsonEnabled) {
+ // If JSON failed, SRT might be empty or not yet read?
+ try { cues = parseSrtCues(await fs.readFile(srtPath, 'utf-8')); } catch { /* ignore */ }
+ }
- const timedCues = jsonEnabled
- ? parseWhisperJsonCues(await fs.readFile(jsonPath, 'utf-8'))
- : []
- const cues = timedCues.length > 0
- ? timedCues
- : parseSrtCues(await fs.readFile(srtPath, 'utf-8'))
- if (cues.length === 0) {
- throw new Error('Whisper completed, but no caption cues were produced.')
+ // Adjust timings and deduplicate
+ const adjustedCues = cues
+ .map(cue => ({
+ ...cue,
+ startMs: cue.startMs + offsetMs,
+ endMs: cue.endMs + offsetMs
+ }))
+ // Only keep cues that START within this chunk's main window (prevent overlap duplicates)
+ // Except for the very last chunk where we take everything
+ .filter(cue => {
+ const isLastChunk = totalDurationMs > 0 && (offsetMs + CHUNK_SIZE_MS >= totalDurationMs);
+ if (isLastChunk) return true;
+ return cue.startMs < offsetMs + CHUNK_SIZE_MS;
+ });
+
+ if (adjustedCues.length > 0) {
- console.log(`[auto-captions] Chunk ${chunkIndex + 1} produced ${adjustedCues.length} adjusted cues.`)
+ allCues.push(...adjustedCues);
- webContents.send('auto-caption-chunk', { cues: adjustedCues });
++ safeSend(webContents, 'auto-caption-chunk', { cues: adjustedCues });
+ }
+
+ // If we don't know duration and this was a short chunk, we might be at the end
+ // Actually, FFmpeg will just produce a short file if duration is past EOS.
+ const stats = await fs.stat(wavPath).catch(() => null);
+ if (stats && stats.size < 1000) { // Tiny audio file means we hit the end
+ break;
+ }
+
+ if (totalDurationMs > 0 && offsetMs + CHUNK_SIZE_MS >= totalDurationMs) {
+ break;
+ }
+
+ } finally {
+ await Promise.allSettled([
+ fs.rm(wavPath, { force: true }),
+ fs.rm(srtPath, { force: true }),
+ fs.rm(jsonPath, { force: true }),
+ ])
}
+ }
- console.log(`[auto-captions] Generation complete. Total cues: ${allCues.length}`)
- webContents.send('auto-caption-progress', { progress: 100 })
- return {
- cues,
- audioSourceLabel: audioSource.label,
- }
- } finally {
- await Promise.allSettled([
- fs.rm(wavPath, { force: true }),
- fs.rm(srtPath, { force: true }),
- fs.rm(jsonPath, { force: true }),
- ])
++ safeSend(webContents, 'auto-caption-progress', { progress: 100 })
+ return {
+ cues: allCues,
+ audioSourceLabel,
}
}
@@@ -1954,7 -1772,7 +1965,7 @@@ function attachWindowsCaptureLifecycle(
const sourceName = selectedSource?.name ?? 'Screen'
BrowserWindow.getAllWindows().forEach((window) => {
if (!window.isDestroyed()) {
-- window.webContents.send('recording-state-changed', {
++ safeSend(window.webContents, 'recording-state-changed', {
recording: false,
sourceName,
})
@@@ -2228,7 -2009,7 +2202,7 @@@ async function muxNativeMacRecordingWit
function emitRecordingInterrupted(reason: string, message: string) {
BrowserWindow.getAllWindows().forEach((window) => {
if (!window.isDestroyed()) {
-- window.webContents.send('recording-interrupted', { reason, message })
++ safeSend(window.webContents, 'recording-interrupted', { reason, message })
}
})
}
@@@ -2236,7 -2017,7 +2210,7 @@@
function emitCursorStateChanged(cursorType: CursorVisualType) {
BrowserWindow.getAllWindows().forEach((window) => {
if (!window.isDestroyed()) {
-- window.webContents.send('cursor-state-changed', { cursorType })
++ safeSend(window.webContents, 'cursor-state-changed', { cursorType })
}
})
}
@@@ -2272,7 -2053,7 +2246,7 @@@ function attachNativeCaptureLifecycle(p
const sourceName = selectedSource?.name ?? 'Screen'
BrowserWindow.getAllWindows().forEach((window) => {
if (!window.isDestroyed()) {
-- window.webContents.send('recording-state-changed', {
++ safeSend(window.webContents, 'recording-state-changed', {
recording: false,
sourceName,
})
@@@ -3823,7 -3589,7 +3794,7 @@@ body{background:transparent;overflow:hi
const source = selectedSource || { name: 'Screen' }
BrowserWindow.getAllWindows().forEach((window) => {
if (!window.isDestroyed()) {
-- window.webContents.send('recording-state-changed', {
++ safeSend(window.webContents, 'recording-state-changed', {
recording,
sourceName: source.name,
})
@@@ -4635,7 -4404,7 +4611,7 @@@
let remaining = seconds
countdownRemaining = remaining
-- countdownWin.webContents.send('countdown-tick', remaining)
++ safeSend(countdownWin.webContents, 'countdown-tick', remaining)
countdownTimer = setInterval(() => {
if (countdownCancelled) {
@@@ -4664,9 -4433,9 +4640,11 @@@
resolve({ success: true })
} else {
const win = getCountdownWindow()
-- if (win && !win.isDestroyed()) {
-- win.webContents.send('countdown-tick', remaining)
-- }
++ try {
++ if (win && !win.isDestroyed()) {
++ safeSend(win.webContents, 'countdown-tick', remaining)
++ }
++ } catch {}
}
}, 1000)
})
diff --cc electron/windows.ts
index cb265237,cb265237..a9904667
--- a/electron/windows.ts
+++ b/electron/windows.ts
@@@ -246,7 -246,7 +246,9 @@@ export function createHudOverlayWindow(
}
win.webContents.on("did-finish-load", () => {
-- win?.webContents.send("main-process-message", new Date().toLocaleString());
++ if (!win.isDestroyed()) {
++ win.webContents.send("main-process-message", new Date().toLocaleString());
++ }
setTimeout(() => {
if (!win.isDestroyed()) {
win.show();
@@@ -310,7 -310,7 +312,9 @@@ export function createEditorWindow(): B
});
win.webContents.on("did-finish-load", () => {
-- win?.webContents.send("main-process-message", new Date().toLocaleString());
++ if (!win.isDestroyed()) {
++ win.webContents.send("main-process-message", new Date().toLocaleString());
++ }
});
if (VITE_DEV_SERVER_URL) {
diff --cc scripts/build-cursor-monitor.mjs
index 03b0c9d6,5b7409f1..df973241
--- a/scripts/build-cursor-monitor.mjs
+++ b/scripts/build-cursor-monitor.mjs
@@@ -25,35 -25,46 +25,53 @@@ function findCmake()
// not on PATH
}
+ // Local .cmake_ext path
+ const localCmake = path.join(projectRoot, ".cmake_ext", "cmake-4.3.0-windows-x86_64", "bin", "cmake.exe");
+ if (existsSync(localCmake)) {
+ return `"${localCmake}"`;
+ }
+
- // VS 2022 bundled CMake
- const vsEditions = ["Community", "Professional", "Enterprise", "BuildTools"];
- for (const edition of vsEditions) {
- const cmakePath = path.join(
- "C:",
- "Program Files",
- "Microsoft Visual Studio",
- "2022",
- edition,
- "Common7",
- "IDE",
- "CommonExtensions",
- "Microsoft",
- "CMake",
- "CMake",
- "bin",
- "cmake.exe",
- );
++ // Standalone CMake paths
+ const standaloneCmakePaths = [
+ path.join("C:", "Program Files", "CMake", "bin", "cmake.exe"),
+ path.join("C:", "Program Files (x86)", "CMake", "bin", "cmake.exe"),
+ ];
+ for (const cmakePath of standaloneCmakePaths) {
if (existsSync(cmakePath)) {
return `"${cmakePath}"`;
}
}
- // VS 2022 bundled CMake
++ // VS 2022/2019 bundled CMake
+ const vsRoots = [
+ path.join("C:", "Program Files", "Microsoft Visual Studio"),
+ path.join("C:", "Program Files (x86)", "Microsoft Visual Studio"),
+ ];
+ const vsEditions = ["Community", "Professional", "Enterprise", "BuildTools"];
+ const vsVersions = ["2022", "2019"];
+ for (const root of vsRoots) {
+ for (const version of vsVersions) {
+ for (const edition of vsEditions) {
+ const cmakePath = path.join(
+ root,
+ version,
+ edition,
+ "Common7",
+ "IDE",
+ "CommonExtensions",
+ "Microsoft",
+ "CMake",
+ "CMake",
+ "bin",
+ "cmake.exe",
+ );
+ if (existsSync(cmakePath)) {
+ return `"${cmakePath}"`;
+ }
+ }
+ }
+ }
+
return null;
}
diff --cc scripts/build-windows-capture.mjs
index 32ee91b2,3cc3dcfc..8df2c6e3
--- a/scripts/build-windows-capture.mjs
+++ b/scripts/build-windows-capture.mjs
@@@ -1,96 -1,127 +1,136 @@@
--import { execSync } from 'node:child_process';
- import { mkdirSync, existsSync } from 'node:fs';
-import { mkdirSync, existsSync, rmSync } from 'node:fs';
--import path from 'node:path';
++import { execSync } from "node:child_process";
++import { mkdirSync, existsSync, rmSync } from "node:fs";
++import path from "node:path";
const projectRoot = process.cwd();
--const sourceDir = path.join(projectRoot, 'electron', 'native', 'wgc-capture');
--const buildDir = path.join(sourceDir, 'build');
++const sourceDir = path.join(projectRoot, "electron", "native", "wgc-capture");
++const buildDir = path.join(sourceDir, "build");
--if (process.platform !== 'win32') {
-- console.log('[build-windows-capture] Skipping native Windows capture build: host platform is not Windows.');
-- process.exit(0);
++if (process.platform !== "win32") {
++ console.log("[build-windows-capture] Skipping native Windows capture build: host platform is not Windows.");
++ process.exit(0);
}
--if (!existsSync(path.join(sourceDir, 'CMakeLists.txt'))) {
-- console.error('[build-windows-capture] CMakeLists.txt not found at', sourceDir);
-- process.exit(1);
++if (!existsSync(path.join(sourceDir, "CMakeLists.txt"))) {
++ console.error("[build-windows-capture] CMakeLists.txt not found at", sourceDir);
++ process.exit(1);
}
function findCmake() {
-- // Check PATH first
-- try {
-- execSync('cmake --version', { stdio: 'pipe' });
-- return 'cmake';
-- } catch {
-- // not on PATH
-- }
++ // Check PATH first
++ try {
++ execSync("cmake --version", { stdio: "pipe" });
++ return "cmake";
++ } catch {
++ // not on PATH
++ }
- // Local .cmake_ext path
- const localCmake = path.join(projectRoot, '.cmake_ext', 'cmake-4.3.0-windows-x86_64', 'bin', 'cmake.exe');
- if (existsSync(localCmake)) {
- return `"${localCmake}"`;
- const standaloneCmakePaths = [
- path.join('C:', 'Program Files', 'CMake', 'bin', 'cmake.exe'),
- path.join('C:', 'Program Files (x86)', 'CMake', 'bin', 'cmake.exe'),
- ];
- for (const cmakePath of standaloneCmakePaths) {
- if (existsSync(cmakePath)) {
- return `"${cmakePath}"`;
- }
-- }
++ // Local .cmake_ext path
++ const localCmake = path.join(projectRoot, ".cmake_ext", "cmake-4.3.0-windows-x86_64", "bin", "cmake.exe");
++ if (existsSync(localCmake)) {
++ return `"${localCmake}"`;
++ }
-- // VS 2022 bundled CMake
- const vsRoots = [
- path.join('C:', 'Program Files', 'Microsoft Visual Studio'),
- path.join('C:', 'Program Files (x86)', 'Microsoft Visual Studio'),
- ];
-- const vsEditions = ['Community', 'Professional', 'Enterprise', 'BuildTools'];
- for (const edition of vsEditions) {
- const cmakePath = path.join(
- 'C:', 'Program Files', 'Microsoft Visual Studio', '2022', edition,
- 'Common7', 'IDE', 'CommonExtensions', 'Microsoft', 'CMake', 'CMake', 'bin', 'cmake.exe'
- );
- if (existsSync(cmakePath)) {
- return `"${cmakePath}"`;
- const vsVersions = ['2022', '2019'];
- for (const root of vsRoots) {
- for (const version of vsVersions) {
- for (const edition of vsEditions) {
- const cmakePath = path.join(
- root,
- version,
- edition,
- 'Common7',
- 'IDE',
- 'CommonExtensions',
- 'Microsoft',
- 'CMake',
- 'CMake',
- 'bin',
- 'cmake.exe'
- );
- if (existsSync(cmakePath)) {
- return `"${cmakePath}"`;
- }
- }
-- }
-- }
++ // Standalone CMake paths
++ const standaloneCmakePaths = [
++ path.join("C:", "Program Files", "CMake", "bin", "cmake.exe"),
++ path.join("C:", "Program Files (x86)", "CMake", "bin", "cmake.exe"),
++ ];
++ for (const cmakePath of standaloneCmakePaths) {
++ if (existsSync(cmakePath)) {
++ return `"${cmakePath}"`;
++ }
++ }
-- return null;
++ // VS 2022/2019 bundled CMake
++ const vsRoots = [
++ path.join("C:", "Program Files", "Microsoft Visual Studio"),
++ path.join("C:", "Program Files (x86)", "Microsoft Visual Studio"),
++ ];
++ const vsEditions = ["Community", "Professional", "Enterprise", "BuildTools"];
++ const vsVersions = ["2022", "2019"];
++ for (const root of vsRoots) {
++ for (const version of vsVersions) {
++ for (const edition of vsEditions) {
++ const cmakePath = path.join(
++ root,
++ version,
++ edition,
++ "Common7",
++ "IDE",
++ "CommonExtensions",
++ "Microsoft",
++ "CMake",
++ "CMake",
++ "bin",
++ "cmake.exe",
++ );
++ if (existsSync(cmakePath)) {
++ return `"${cmakePath}"`;
++ }
++ }
++ }
++ }
++
++ return null;
}
const cmake = findCmake();
if (!cmake) {
-- console.error('[build-windows-capture] CMake not found. Install Visual Studio with C++ CMake tools or standalone CMake.');
-- process.exit(1);
++ console.error(
++ "[build-windows-capture] CMake not found. Install Visual Studio with C++ CMake tools or standalone CMake.",
++ );
++ process.exit(1);
}
mkdirSync(buildDir, { recursive: true });
-const cacheFile = path.join(buildDir, 'CMakeCache.txt');
-const cacheDir = path.join(buildDir, 'CMakeFiles');
++const cacheFile = path.join(buildDir, "CMakeCache.txt");
++const cacheDir = path.join(buildDir, "CMakeFiles");
+
+ function clearCmakeCache() {
- rmSync(cacheFile, { force: true });
- rmSync(cacheDir, { recursive: true, force: true });
++ rmSync(cacheFile, { force: true });
++ rmSync(cacheDir, { recursive: true, force: true });
+ }
--console.log('[build-windows-capture] Configuring CMake...');
++console.log("[build-windows-capture] Configuring CMake...");
try {
- clearCmakeCache();
-- execSync(`${cmake} .. -G "Visual Studio 17 2022" -A x64`, {
-- cwd: buildDir,
-- stdio: 'inherit',
-- timeout: 120000,
-- });
++ clearCmakeCache();
++ execSync(`${cmake} .. -G "Visual Studio 17 2022" -A x64`, {
++ cwd: buildDir,
++ stdio: "inherit",
++ timeout: 120000,
++ });
} catch {
-- console.log('[build-windows-capture] VS 2022 generator not found, trying VS 2019...');
-- try {
- clearCmakeCache();
-- execSync(`${cmake} .. -G "Visual Studio 16 2019" -A x64`, {
-- cwd: buildDir,
-- stdio: 'inherit',
-- timeout: 120000,
-- });
-- } catch (innerError) {
-- console.error('[build-windows-capture] CMake configure failed:', innerError.message);
-- process.exit(1);
-- }
++ console.log("[build-windows-capture] VS 2022 generator not found, trying VS 2019...");
++ try {
++ clearCmakeCache();
++ execSync(`${cmake} .. -G "Visual Studio 16 2019" -A x64`, {
++ cwd: buildDir,
++ stdio: "inherit",
++ timeout: 120000,
++ });
++ } catch (innerError) {
++ console.error("[build-windows-capture] CMake configure failed:", innerError.message);
++ process.exit(1);
++ }
}
--console.log('[build-windows-capture] Building native Windows capture helper...');
++console.log("[build-windows-capture] Building native Windows capture helper...");
try {
-- execSync(`${cmake} --build . --config Release`, {
-- cwd: buildDir,
-- stdio: 'inherit',
-- timeout: 300000,
-- });
++ execSync(`${cmake} --build . --config Release`, {
++ cwd: buildDir,
++ stdio: "inherit",
++ timeout: 300000,
++ });
} catch (error) {
-- console.error('[build-windows-capture] Build failed:', error.message);
-- process.exit(1);
++ console.error("[build-windows-capture] Build failed:", error.message);
++ process.exit(1);
}
--const exePath = path.join(buildDir, 'Release', 'wgc-capture.exe');
++const exePath = path.join(buildDir, "Release", "wgc-capture.exe");
if (existsSync(exePath)) {
-- console.log(`[build-windows-capture] Built successfully: ${exePath}`);
++ console.log(`[build-windows-capture] Built successfully: ${exePath}`);
} else {
-- console.error('[build-windows-capture] Expected exe not found at', exePath);
-- process.exit(1);
++ console.error("[build-windows-capture] Expected exe not found at", exePath);
++ process.exit(1);
}
diff --cc src/components/video-editor/VideoEditor.tsx
index 4d180abc,dc11eec5..530e5fdb
--- a/src/components/video-editor/VideoEditor.tsx
+++ b/src/components/video-editor/VideoEditor.tsx
@@@ -1023,11 -1014,10 +1023,10 @@@ export default function VideoEditor()
);
nextAudioIdRef.current = deriveNextId(
"audio",
- cloned.audioRegions.map((region) => region.id),
+ snapshot.audioRegions.map((region: AudioRegion) => region.id),
);
nextAnnotationZIndexRef.current =
- cloned.annotationRegions.reduce((max, region) => Math.max(max, region.zIndex), 0) + 1;
+ snapshot.annotationRegions.reduce((max: number, region: AnnotationRegion) => Math.max(max, region.zIndex), 0) + 1;
- applyingHistoryRef.current = false;
},
[cloneSnapshot],
);
@@@ -3454,20 -3354,10 +3448,17 @@@
onAnnotationDelete={handleAnnotationDelete}
selectedAnnotationId={selectedAnnotationId}
onSelectAnnotation={handleSelectAnnotation}
++ autoCaptions={autoCaptions}
++ onCaptionSpanChange={handleCaptionSpanChange}
++ selectedCaptionId={selectedCaptionId}
++ onSelectCaption={handleSelectCaption}
++ onClearAutoCaptions={handleClearAutoCaptions}
aspectRatio={aspectRatio}
onAspectRatioChange={setAspectRatio}
onOpenCropEditor={handleOpenCropEditor}
isCropped={isCropped}
- autoCaptions={autoCaptions}
- onCaptionSpanChange={(id, span) => {
- setAutoCaptions((prev) =>
- prev.map((r) => (r.id === id ? { ...r, startMs: span.start, endMs: span.end } : r)),
- );
- }}
- selectedCaptionId={selectedCaptionId}
- onSelectCaption={setSelectedCaptionId}
+ timeSelection={timeSelection}
+ onTimeSelectionChange={setTimeSelection}
/>
</div>
</Panel>
diff --cc src/components/video-editor/timeline/TimelineEditor.tsx
index 87088464,ee0080e0..e87272e5
--- a/src/components/video-editor/timeline/TimelineEditor.tsx
+++ b/src/components/video-editor/timeline/TimelineEditor.tsx
@@@ -75,10 -73,6 +75,11 @@@ interface TimelineEditorProps
onAudioDelete?: (id: string) => void;
selectedAudioId?: string | null;
onSelectAudio?: (id: string | null) => void;
+ autoCaptions?: CaptionCue[];
+ onCaptionSpanChange?: (id: string, span: Span) => void;
+ selectedCaptionId?: string | null;
+ onSelectCaption?: (id: string | null) => void;
++ onClearAutoCaptions?: () => void;
aspectRatio: AspectRatio;
onAspectRatioChange: (aspectRatio: AspectRatio) => void;
onOpenCropEditor?: () => void;
@@@ -812,10 -663,6 +813,11 @@@ export default function TimelineEditor(
onAudioDelete,
selectedAudioId,
onSelectAudio,
+ autoCaptions = [],
+ onCaptionSpanChange,
+ selectedCaptionId,
+ onSelectCaption,
++ onClearAutoCaptions,
aspectRatio,
onAspectRatioChange,
onOpenCropEditor,
@@@ -980,6 -822,6 +982,7 @@@
speedIds.forEach((id) => onSpeedDelete?.(id));
audioIds.forEach((id) => onAudioDelete?.(id));
++ onClearAutoCaptions?.();
clearSelectedBlocks();
setSelectedKeyframeId(null);
}, [
@@@ -988,6 -830,6 +991,7 @@@
clearSelectedBlocks,
onAnnotationDelete,
onAudioDelete,
++ onClearAutoCaptions,
onSpeedDelete,
onTrimDelete,
onZoomDelete,
@@@ -999,33 -841,27 +1003,80 @@@
const handleSelectZoom = useCallback((id: string | null) => {
setSelectAllBlocksActive(false);
onSelectZoom(id);
-- }, [onSelectZoom]);
++ if (id) {
++ onSelectTrim?.(null);
++ onSelectAnnotation?.(null);
++ onSelectSpeed?.(null);
++ onSelectAudio?.(null);
++ onSelectCaption?.(null);
++ onTimeSelectionChange?.(null);
++ }
++ }, [onSelectZoom, onSelectTrim, onSelectAnnotation, onSelectSpeed, onSelectAudio, onSelectCaption, onTimeSelectionChange]);
const handleSelectTrim = useCallback((id: string | null) => {
setSelectAllBlocksActive(false);
onSelectTrim?.(id);
-- }, [onSelectTrim]);
++ if (id) {
++ onSelectZoom(null);
++ onSelectAnnotation?.(null);
++ onSelectSpeed?.(null);
++ onSelectAudio?.(null);
++ onSelectCaption?.(null);
++ onTimeSelectionChange?.(null);
++ }
++ }, [onSelectZoom, onSelectTrim, onSelectAnnotation, onSelectSpeed, onSelectAudio, onSelectCaption, onTimeSelectionChange]);
const handleSelectAnnotation = useCallback((id: string | null) => {
setSelectAllBlocksActive(false);
onSelectAnnotation?.(id);
-- }, [onSelectAnnotation]);
++ if (id) {
++ onSelectZoom(null);
++ onSelectTrim?.(null);
++ onSelectSpeed?.(null);
++ onSelectAudio?.(null);
++ onSelectCaption?.(null);
++ onTimeSelectionChange?.(null);
++ }
++ }, [onSelectZoom, onSelectTrim, onSelectAnnotation, onSelectSpeed, onSelectAudio, onSelectCaption, onTimeSelectionChange]);
const handleSelectSpeed = useCallback((id: string | null) => {
setSelectAllBlocksActive(false);
onSelectSpeed?.(id);
-- }, [onSelectSpeed]);
++ if (id) {
++ onSelectZoom(null);
++ onSelectTrim?.(null);
++ onSelectAnnotation?.(null);
++ onSelectAudio?.(null);
++ onSelectCaption?.(null);
++ onTimeSelectionChange?.(null);
++ }
++ }, [onSelectZoom, onSelectTrim, onSelectAnnotation, onSelectSpeed, onSelectAudio, onSelectCaption, onTimeSelectionChange]);
const handleSelectAudio = useCallback((id: string | null) => {
setSelectAllBlocksActive(false);
onSelectAudio?.(id);
-- }, [onSelectAudio]);
-
++ if (id) {
++ onSelectZoom(null);
++ onSelectTrim?.(null);
++ onSelectAnnotation?.(null);
++ onSelectSpeed?.(null);
++ onSelectCaption?.(null);
++ onTimeSelectionChange?.(null);
++ }
++ }, [onSelectZoom, onSelectTrim, onSelectAnnotation, onSelectSpeed, onSelectAudio, onSelectCaption, onTimeSelectionChange]);
+
+ const handleSelectCaption = useCallback((id: string | null) => {
+ setSelectAllBlocksActive(false);
+ onSelectCaption?.(id);
- }, [onSelectCaption]);
++ if (id) {
++ onSelectZoom(null);
++ onSelectTrim?.(null);
++ onSelectAnnotation?.(null);
++ onSelectSpeed?.(null);
++ onSelectAudio?.(null);
++ onTimeSelectionChange?.(null);
++ }
++ }, [onSelectZoom, onSelectTrim, onSelectAnnotation, onSelectSpeed, onSelectAudio, onSelectCaption, onTimeSelectionChange]);
useEffect(() => {
setRange(createInitialRange(totalMs));
diff --cc src/components/video-editor/types.ts
index 68b7d310,5406210c..ae4ca1d4
--- a/src/components/video-editor/types.ts
+++ b/src/components/video-editor/types.ts
@@@ -124,27 -122,27 +122,27 @@@ export const DEFAULT_WEBCAM_OVERLAY: We
};
export interface TrimRegion {
- id: string;
- startMs: number;
- endMs: number;
+ id: string;
+ startMs: number;
+ endMs: number;
}
-export type AnnotationType = "text" | "image" | "figure";
+export type AnnotationType = "text" | "image" | "figure" | "blur";
export type ArrowDirection =
- | "up"
- | "down"
- | "left"
- | "right"
- | "up-right"
- | "up-left"
- | "down-right"
- | "down-left";
+ | "up"
+ | "down"
+ | "left"
+ | "right"
+ | "up-right"
+ | "up-left"
+ | "down-right"
+ | "down-left";
export interface FigureData {
- arrowDirection: ArrowDirection;
- color: string;
- strokeWidth: number;
+ arrowDirection: ArrowDirection;
+ color: string;
+ strokeWidth: number;
}
export interface AnnotationPosition {
@@@ -185,26 -183,23 +183,26 @@@ export function getDefaultCaptionFontFa
}
export interface AnnotationRegion {
- id: string;
- startMs: number;
- endMs: number;
- type: AnnotationType;
- content: string; // Legacy - still used for current type
- textContent?: string; // Separate storage for text
- imageContent?: string; // Separate storage for image data URL
- position: AnnotationPosition;
- size: AnnotationSize;
- style: AnnotationTextStyle;
- zIndex: number;
- figureData?: FigureData;
- blurIntensity?: number;
+ id: string;
+ startMs: number;
+ endMs: number;
+ type: AnnotationType;
+ content: string; // Legacy - still used for current type
+ textContent?: string; // Separate storage for text
+ imageContent?: string; // Separate storage for image data URL
+ position: AnnotationPosition;
+ size: AnnotationSize;
+ style: AnnotationTextStyle;
+ zIndex: number;
+ figureData?: FigureData;
++ blurIntensity?: number;
}
+export const DEFAULT_BLUR_INTENSITY = 12;
+
export const DEFAULT_ANNOTATION_POSITION: AnnotationPosition = {
- x: 50,
- y: 50,
+ x: 50,
+ y: 50,
};
export const DEFAULT_ANNOTATION_SIZE: AnnotationSize = {
@@@ -244,25 -239,19 +242,25 @@@ export const DEFAULT_CROP_REGION: CropR
};
export interface AudioRegion {
- id: string;
- startMs: number;
- endMs: number;
- audioPath: string;
- volume: number;
+ id: string;
+ startMs: number;
+ endMs: number;
+ audioPath: string;
+ volume: number;
}
+
+export interface TimeSelection {
+ startMs: number;
+ endMs: number;
+}
+
export interface CaptionCue {
- id: string;
- startMs: number;
- endMs: number;
- text: string;
- words?: CaptionCueWord[];
+ id: string;
+ startMs: number;
+ endMs: number;
+ text: string;
+ words?: CaptionCueWord[];
}
export interface CaptionCueWord {
@@@ -273,40 -262,35 +271,40 @@@
}
export type AutoCaptionAnimation = "none" | "fade" | "rise" | "pop";
+export type WhisperModel = "tiny" | "base" | "small" | "medium" | "large" | "custom";
export interface AutoCaptionSettings {
- enabled: boolean;
- language: string;
- selectedModel: WhisperModel;
- fontFamily: string;
- fontSize: number;
- bottomOffset: number;
- maxWidth: number;
- maxRows: number;
- animationStyle: AutoCaptionAnimation;
- boxRadius: number;
- textColor: string;
- inactiveTextColor: string;
- backgroundOpacity: number;
- generationRange: "full" | "selected";
+ enabled: boolean;
+ language: string;
++ selectedModel: WhisperModel;
+ fontFamily: string;
+ fontSize: number;
+ bottomOffset: number;
+ maxWidth: number;
+ maxRows: number;
+ animationStyle: AutoCaptionAnimation;
+ boxRadius: number;
+ textColor: string;
+ inactiveTextColor: string;
+ backgroundOpacity: number;
++ generationRange: "full" | "selected";
}
export const DEFAULT_AUTO_CAPTION_SETTINGS: AutoCaptionSettings = {
- enabled: false,
- language: "auto",
- selectedModel: "small",
- fontFamily: getDefaultCaptionFontFamily(),
- fontSize: 30,
- bottomOffset: 3,
- maxWidth: 62,
- maxRows: 1,
- animationStyle: "fade",
- boxRadius: 17.5,
- textColor: "#FFFFFF",
- inactiveTextColor: "#A3A3A3",
- backgroundOpacity: 0.1,
- generationRange: "full",
+ enabled: false,
+ language: "auto",
++ selectedModel: "small",
+ fontFamily: getDefaultCaptionFontFamily(),
+ fontSize: 30,
+ bottomOffset: 3,
+ maxWidth: 62,
+ maxRows: 1,
+ animationStyle: "fade",
+ boxRadius: 17.5,
+ textColor: "#FFFFFF",
+ inactiveTextColor: "#A3A3A3",
- backgroundOpacity: 0.9,
++ backgroundOpacity: 0.1,
++ generationRange: "full",
};
export type PlaybackSpeed = 0.25 | 0.5 | 0.75 | 1.25 | 1.5 | 1.75 | 2;