Commit Graph
120 Commits
Author SHA1 Message Date
大彪 9ac4dbd2e8 fix(export): stream MP4 output to disk to unblock >2 GiB exports
Long recordings (35-minute screencaps were the motivating case) fail at
the 99% "Finalizing" step with a RangeError once the muxed MP4 would
exceed V8's ~2 GiB per-ArrayBuffer limit. Both export paths accumulate
the whole file in renderer memory and round-trip it through IPC, so no
output size past that point can complete:

- Legacy: src/lib/exporter/muxer.ts uses mediabunny's BufferTarget,
  which holds the entire MP4 in a single ArrayBuffer. finalize() → Blob
  → blob.arrayBuffer() → ipcRenderer.invoke('write-exported-video-to-
  path', arrayBuffer, path) — every step wants a ≥2 GiB contiguous
  allocation.
- Lightning: native-video-export-finish did fs.readFile(finalizedPath)
  and shipped the bytes back to the renderer, which re-serialized them
  again. Same ceiling.

This change moves the finished MP4 across the renderer↔main boundary
via a temp file instead of an ArrayBuffer:

- New electron/ipc/export/exportStream.ts manages streaming temp files
  via fh.write(buf, 0, len, position) so out-of-order writes (moov box
  rewrites, etc.) stay safe. Each session lives in a 0700 mkdtemp()
  directory opened with O_CREAT | O_EXCL so a hostile local user on a
  shared tempdir cannot pre-plant a symlink at the predicted path.
- New renderer-facing IPCs: export-stream-open/write/close,
  finalize-exported-video (renames temp to final path, copy+unlink
  fallback on EXDEV/EPERM/ENOTEMPTY with console.warn on leaked bytes),
  mux-exported-video-audio-from-path (FFmpeg audio fallback that takes
  a path instead of an ArrayBuffer), and discard-exported-temp. Every
  handler validates the caller-supplied path against an owned-export-
  paths registry before touching disk, so a compromised renderer cannot
  route arbitrary filesystem paths into main-process deletes/moves.
- The muxer now picks mediabunny's StreamTarget automatically when the
  Electron bridge is available (BufferTarget stays for tests and any
  non-Electron callers). finalize() returns { mode, tempFilePath,
  bytesWritten } or { mode, blob } so the exporter can branch.
- Exporters forward tempFilePath through ExportResult. Lightning's
  finish returns the ffmpeg temp path directly; the FFmpeg audio
  fallback forks on the muxer result type. modernVideoExporter's
  Lightning success branch now accepts tempFilePath (previously it
  checked blob only, which regressed every native export).
- VideoEditor.tsx dispatches on tempFilePath: finalize via the new IPC,
  keep the temp in place when the save dialog is canceled so "Save
  Again" still works without re-rendering, keep the pending-save entry
  alive on non-canceled save failures, and discard the temp on unmount
  or explicit clear. GIF and smoke-test code paths still use the
  legacy Blob path unchanged.
- app.on('before-quit') also reaps any open streaming sessions via
  cleanupAllExportStreams().

Chunk size is 16 MiB — well under Electron/Mojo IPC message limits
while keeping total writes low (~160 for a 2.5 GB export).

Tested locally: exported a 35:13 source (~2.7 GiB H.264 input) at
Original 1920×1080 + Balanced. Previously failed on finalize with a
RangeError; with this patch the Legacy pipeline produced a valid 3.7
GiB MP4 whose ffmpeg -i duration/streams match the source.

Addresses #194.
2026-04-24 16:02:37 +08:00
webadderall 05a6d3f1b6 Fix embedded audio fallback handling and audio diagnostics (#309)
* Fix embedded audio fallback handling and audio diagnostics

* Add recording fallback diagnostics toasts

* Fix Windows audio fallback cleanup and path matching

* Format rebased recording fallback changes

* Fix embedded audio preview and export fallback handling
2026-04-24 11:30:10 +10:00
webadderall 673dfdadd3 refactor: extract registerIpcHandlers into 8 focused register/ modules
handlers.ts reduced from 2930 → 65 lines (pure delegation).

New files under electron/ipc/register/:
- sources.ts    — get-sources, select-source, show-source-highlight, open-source-selector
- recording.ts  — start/stop/pause native + ffmpeg, mux, store, set-recording-state, get-cursor-telemetry
- permissions.ts — accessibility/screen permissions, open-external-url
- assets.ts     — wallpaper thumbnails, asset-base-path, list-asset-dir, read-local-file
- export.ts     — native-video-export-*, save-exported-video
- captions.ts   — whisper model, file pickers, generate-auto-captions
- project.ts    — project files, recordings dir, video/session state, delete-recording
- settings.ts   — shortcuts, recording prefs, countdown, platform info

Also moved shared helpers:
- getMacPrivacySettingsUrl, approveUserPath → utils.ts
- isTrustedProjectPath → project/manager.ts
2026-04-17 20:13:47 +10:00
webadderall 099ce2bbb5 refactor: split handlers.ts into focused sub-modules
handlers.ts was ~5967 lines. Extracted into 22 focused modules:

- ipc/types.ts — shared TypeScript interfaces and types
- ipc/constants.ts — module-level constants
- ipc/state.ts — all mutable state with typed setters
- ipc/utils.ts — shared low-level utilities (getScreen, normalizePath, etc.)
- ipc/ffmpeg/binary.ts — ffmpeg binary resolution
- ipc/ffmpeg/filters.ts — audio sync/filter builders
- ipc/captions/parser.ts — SRT/Whisper JSON parsers
- ipc/captions/whisper.ts — Whisper model download/status
- ipc/captions/generate.ts — auto-caption generation
- ipc/paths/binaries.ts — native binary path resolution
- ipc/cursor/monitor.ts — cursor monitor process management
- ipc/cursor/telemetry.ts — cursor sampling and telemetry
- ipc/cursor/bounds.ts — window bounds capture and resolution
- ipc/cursor/interaction.ts — mouse hook and interaction capture
- ipc/recording/events.ts — recording lifecycle events
- ipc/recording/diagnostics.ts — media validation and diagnostics
- ipc/recording/prune.ts — auto-recording cleanup
- ipc/recording/ffmpeg.ts — FFmpeg screen capture
- ipc/recording/windows.ts — Windows native capture (WGC)
- ipc/recording/mac.ts — Mac ScreenCaptureKit integration
- ipc/export/native-video.ts — native video export sessions
- ipc/project/session.ts — recording session manifests
- ipc/project/manager.ts — project library and file management

handlers.ts reduced from 5967 → 2930 lines (registerIpcHandlers + helpers only)
2026-04-17 19:57:26 +10:00
webadderall 8d925281fc Merge remote-tracking branch 'origin/main' into feat/export-pipeline
# Conflicts:
#	electron/electron-env.d.ts
#	electron/ipc/handlers.ts
2026-04-17 13:47:15 +10:00
webadderall 8071c6bb0e fix: address remaining ui overhaul review feedback 2026-04-16 23:39:27 +10:00
webadderall a83a58c671 fix: address ui overhaul review feedback 2026-04-16 22:36:23 +10:00
webadderall 8abceaa914 feat: add H.264 stream-copy export, overhaul exporter pipeline, rename native binaries
- IPC: new inputMode 'h264-stream' — browser VideoEncoder output stream-copied
  into MP4 via ffmpeg rather than piping raw RGBA frames, cuts memory usage
- Security: replace flat approvedLocalReadPaths with userApprovedPaths fed from
  dialog pickers and project load; isAllowedLocalReadPath uses it alongside
  dir prefix / existsSync checks
- nativeVideoExport: add buildNativeH264StreamExportArgs for stream-copy path
- frameRenderer / modernFrameRenderer: cursor-follow camera integration,
  annotation blur post-processing, shadow profile, squircle geometry
- audioEncoder / streamingDecoder / gifExporter / muxer: full pipeline
  hardening — drift correction, backpressure, proper teardown
- Rename native helpers openscreen-* → recordly-* on darwin-arm64 and
  darwin-x64; update helpers-manifest.json for win32-x64
- electron/main, windows, updater, rendererServer: startup and window
  lifecycle improvements
- preload: expose inputMode and new IPC surface to renderer
2026-04-16 17:51:41 +10:00
webadderall 38e54e2b12 fix: allow local export media files 2026-04-15 18:02:46 +10:00
webadderall 60d364a4ed fix: hotfix export regressions 2026-04-15 17:19:49 +10:00
webadderall e34881fec4 fix(export): remove output path restriction 2026-04-14 22:28:30 +10:00
Wing900 654ed79ba8 Fix silent MP4 exports with FFmpeg audio fallback 2026-04-12 20:55:34 +08:00
webadderall 6296a05115 fix(audio): add browser microphone fallback for macOS < 14
On macOS versions before Sonoma (14.0), SCStreamConfiguration does not
support the captureMicrophone/microphoneCaptureDeviceID selectors. The
native helper was throwing a fatal error, blocking recording entirely
when microphone was enabled.

Now the Swift helper logs MICROPHONE_CAPTURE_UNAVAILABLE and continues
capture without microphone. The Node handler detects this signal and
returns microphoneFallbackRequired to the renderer, which starts a
browser-side MediaRecorder capturing the mic via getUserMedia. On stop,
the audio blob is saved as a .mic.webm sidecar alongside the native
recording, where the existing companion audio detection picks it up.

Fixes: 'Native microphone capture is unavailable on this macOS/Xcode
runtime' error on older macOS versions.
2026-04-12 16:59:06 +10:00
webadderall d6f1225e45 feat(extensions): marketplace integration, wallpaper thumbnails, cursor packs, and bug fixes
- Extension marketplace UI with browsing, installing, screenshot gallery
- Wallpaper & cursor style registration API for extensions
- Wallpaper thumbnail system (nativeImage resize + disk cache, OOM-safe)
- Fix HUD crash: check configurable before redefining electronAPI
- Fix zip-slip false positive on macOS (fs.realpath for symlinks)
- Extension icon sizing and description truncation improvements
- Eager extension activation in SettingsPanel
2026-04-12 01:38:36 +10:00
webadderall d3fab9d83e security: restrict read-local-file and open-external-url IPC handlers
- read-local-file: whitelist to RECORDINGS_DIR, USER_DATA_PATH, asset root, and temp only
- open-external-url: reject non-http/https protocols (blocks file://, javascript:, etc.)

Prevents malicious renderer code from reading arbitrary files (SSH keys,
credentials) or opening dangerous URLs via shell.openExternal.
2026-04-12 01:37:28 +10:00
webadderall 3150ed41f2 chore(audio): clean up probeMediaDurationSeconds after #216
- Remove dead time= progress matching (no decode pass = no progress output)
- Remove stale comments about ffmpeg success/fallback behavior
- Lower timeout from 30s to 5s (header read is near-instant)
- Drop maxBuffer override (minimal stderr output now)
- Add -hide_banner to reduce stderr noise
2026-04-11 16:20:12 +10:00
Mohamed 0054bebef6 fix(audio): drop null muxer from probe to restore duration parsing
- Remove -f null - from probeMediaDurationSeconds() ffmpeg args
  so the command always exits non-zero (no output file specified)
- Without -f null -, ffmpeg exits code 1 and stderr lands in the
  catch block where Duration is parsed, fixing the bug where
  duration returned 0 on valid recordings
- probeMediaDurationSeconds returning 0 caused the
  videoDuration > 0 gate to skip all audio sync correction,
  leaving system audio misaligned in the final recording
2026-04-10 19:33:26 +02:00
webadderall d8e57f7600 fix(whisper): reset download state on model deletion failure
When deleting the Whisper model failed, the frontend kept stale state
(whisperModelDownloadStatus stayed as 'downloaded'), which blocked
re-downloading because the download handler saw the model as already
present. On the backend, no progress event was sent on failure, leaving
the renderer out of sync.

Frontend: reset whisperModelDownloadStatus and progress to idle on
delete failure so re-download is unblocked.
Backend: verify whether the file was actually removed despite the error
and send appropriate progress events in either case.

Closes #152
2026-04-09 23:27:14 +10:00
webadderall 7d80678b38 fix(windows): use per-display scale factor for window cursor position
When recording a window on a secondary monitor with a different DPI,
getNormalizedCursorPoint() used the primary display's scale factor for
both cursor and window-bounds conversion. This produced incorrect
normalised coordinates. Now resolves the display that contains the
target window and uses that display's scale factor instead.

Fixes #204
2026-04-09 21:23:48 +10:00
webadderall ad426453c7 fix: harden cursor-monitor spawn against ENOENT on Windows
Use F_OK instead of X_OK for Windows fs.access check (X_OK is meaningless
on Windows). Wrap spawn() in try/catch to prevent uncaught exception if the
binary is missing or blocked by antivirus.
2026-04-09 16:07:57 +10:00
webadderall 646dcf92f0 fix: cursor DPI normalization for Windows/Linux scaled displays
On non-macOS platforms, platform APIs (iohook, GetWindowRect, xwininfo)
return physical pixel coordinates while Electron returns DIP coordinates.
Apply scaleFactor correction so cursor normalization uses a consistent
coordinate space. Fixes ~30-40px cursor offset on Windows 11 and Linux
Mint when display scaling is >100%.

Also fixes winget-releaser workflow (use v2 tag instead of invalid @latest).
2026-04-09 15:58:17 +10:00
webadderall 1e56c2d139 revert(recording): remove editor finalization phase 2026-04-04 22:26:25 +11:00
webadderall 5fd49fbf0f fix(audio): reduce recording and export drift 2026-04-04 21:53:25 +11:00
webadderall acf359d3cc add native export ipc handlers 2026-04-04 13:07:49 +11:00
webadderall 098abda72d fix(recording): improve webcam audio sync and delay compensation 2026-04-02 16:29:43 +11:00
webadderall db8718cf66 Add sidecar audio fallback for silent recordings 2026-04-01 15:40:40 +11:00
webadderall 1f1e445eb8 Fix macOS recording audio playback 2026-04-01 15:01:51 +11:00
webadderall 545019ff7d fix(recording): align auto-zoom cursor data for windows capture 2026-03-31 00:06:53 +11:00
webadderall 91a51951fa fix(recording): trim paused audio from native windows captures 2026-03-31 00:04:00 +11:00
webadderall f61a5982e3 fix(recording): persist microphone and system-audio preferences 2026-03-30 23:49:56 +11:00
webadderall dab9950a54 fix(recording): wrap recovery mux in try/catch to prevent video loss on audio failure 2026-03-30 22:55:53 +11:00
Azeem Tariq 3a0b3fca9e fix(recording): preserve mic audio when recovering mac capture 2026-03-30 15:47:13 +05:00
webadderall 6f8891529a fix: use CGWindowID bounds for highlight animation instead of AppleScript
- Remove AppleScript 'front window' bounds query which returned wrong window
  for multi-window apps (e.g. Arc highlighting invisible auxiliary window)
- Use resolveMacWindowBounds() which queries by exact CGWindowID
- Keep AppleScript 'activate' call for bringing the app to front
2026-03-30 15:16:35 +11:00
webadderall 27a2be2d3b fix: filter auxiliary windows and remove thumbnail requirement from source list
- Swift helper: filter out untitled auxiliary windows from multi-window apps (e.g. Arc sidebar/tab-bar chrome)
- Swift helper: increase minimum window size from 1x1 to 50x50
- Remove .filter(source => Boolean(source.thumbnail)) that hid valid sources
- Remove hasUsableSourceThumbnail filter in fallback path
- Recompile prebundled openscreen-window-list binary
2026-03-30 15:16:28 +11:00
webadderall 3ff71f6a0b fix(sources): gracefully handle desktopCapturer.getSources failure
Catch errors from desktopCapturer.getSources() in the get-sources IPC
handler and return an empty array instead of crashing the handler.
Prevents repeated 'Failed to get sources' errors when screen recording
permission is not granted (common in dev mode on macOS 26).
2026-03-30 13:33:49 +11:00
webadderall ee29ca0947 fix(recording): make video validation non-blocking and use single timestamp
- finalizeStoredVideo now catches validateRecordedVideo errors instead of
  propagating them, so the editor opens even if ffmpeg validation fails
  (restores v1.1.3/v1.1.5 resilient behavior)
- Use a single Date.now() call for all native capture filenames on macOS
  to prevent timestamp drift between video/audio files
2026-03-30 13:32:16 +11:00
webadderall ac14768a62 fix: TCC permission handling for native helpers on macOS 26
- Add CGPreflightScreenCaptureAccess pre-check in Swift helper
- Add microphone TCC pre-flight when mic capture is requested
- Warm up TCC via desktopCapturer.getSources before spawning helper
- Request mic access from Electron before helper spawn
- Remove unreliable systemPreferences.getMediaAccessStatus pre-checks
- Add camera entitlements to plist files for webcam support
- Guard getScreen() calls behind app.isReady()
- Make tray icons lazy to avoid early screen access
- Suppress duplicate permission error alerts in renderer
2026-03-29 19:15:18 +11:00
webadderall cbde700ab7 fix video editor not opening sometimes in prod 2026-03-29 13:13:15 +11:00
webadderall ba5fac0f06 fixed webcam disappearing 2026-03-29 10:31:50 +11:00
webadderall caf65cb59c fix(dev): isolate app data paths from production 2026-03-28 22:00:15 +11:00
webadderall aec45368c6 test(windows): cover WGC display selection 2026-03-28 16:15:27 +11:00
webadderall 6fb7444c03 fix(recording): validate video outputs before open 2026-03-28 16:10:49 +11:00
webadderall 045850417f feat(debug): add native capture diagnostics 2026-03-28 16:08:43 +11:00
webadderall ca29abd89c fix(windows): restore WGC monitor fallback 2026-03-28 15:18:56 +11:00
webadderall 8de1d9a498 fix(windows): bundle native capture helpers 2026-03-28 14:56:16 +11:00
webadderall 719fa78e9f Revert "feat: Advanced Video Editor Implementation, Native WGC Integration, and AI Auto-Captions" 2026-03-28 14:12:25 +11:00
Mahdy Arief d5ab86ea44 fix(export, native, ui): resolve critical data integrity and resource management bugs in PR #122
- Implement comprehensive solo/mute export pipeline in audioEncoder.ts
- Fix duplicate caption IDs by adding chunk-specific indices in handlers.ts
- Prioritize native monitor selection by bounds in monitor_utils.cpp
- Fix alignment for blur annotations extending beyond canvas boundaries
- Resolve timeline selection desync and sidebar visibility for blur annotations
- Fix memory leaks in audio waveform generation with AudioContext cleanup
2026-03-28 06:09:50 +07:00
Mahdy Arief 281a73b51a chore: Finalize PR #116 stability and privacy improvements
- Hardened IPC with safety guards for all webContents.send calls
- Scrubbed sensitive absolute paths from caption logs
- Realigned Windows artifact naming logic
2026-03-27 23:14:12 +07:00
Mahdy Arief 01350ad8df feat: improve timeline selection interaction with Shift+drag and closure fixes 2026-03-27 21:59:03 +07:00
webadderall 658b15d3ca fix(stability): restore export and recording session compatibility 2026-03-27 23:58:08 +11:00