-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Optimize editor performance for large videos #1417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize editor performance for large videos #1417
Conversation
Co-authored-by: richiemcilroy1 <richiemcilroy1@gmail.com>
|
Cursor Agent can help with this pull request. Just |
|
Caution Review failedThe pull request is closed. WalkthroughThe PR refactors frame rendering and timeline segment visibility to reduce redundant renders, adds async audio frame prefetching with parallel decoding, and increases the frame cache size. Changes span editor frame throttling, timeline segment filtering, and playback architecture improvements. Changes
Sequence Diagram(s)sequenceDiagram
participant Playback as Playback Loop
participant Prefetch as Prefetch Task
participant Decode as Decoder
participant Channel as Prefetch Channel
participant Cache as Prefetch Cache
Playback->>Prefetch: spawn prefetch task
Prefetch->>Prefetch: compute next frames to prefetch
Prefetch->>Decode: request parallel decode (up to PARALLEL_DECODE_TASKS)
activate Decode
Decode->>Decode: decode frame async
Decode->>Channel: send PrefetchedFrame
deactivate Decode
Channel->>Cache: buffer frame (bounded by PREFETCH_BUFFER_SIZE)
Playback->>Cache: check for prefetched frame
alt Frame in cache
Cache-->>Playback: return prefetched frame
else Cache miss
Playback->>Decode: request active decode
Decode-->>Playback: return frame
end
Playback->>Playback: advance playhead, apply frame-skip logic (max 3)
Playback->>Cache: trim buffer if catching up
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50–70 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (7)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-authored-by: richiemcilroy1 <richiemcilroy1@gmail.com>
Co-authored-by: richiemcilroy1 <richiemcilroy1@gmail.com>
commit bdf23c8 Merge: 87ffbc2 d654add Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Sun Nov 30 21:38:31 2025 +0800 Merge pull request CapSoftware#1417 from CapSoftware/cursor/optimize-editor-performance-for-large-videos-claude-4.5-opus-high-thinking-fb23 Optimize editor performance for large videos commit d654add Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Sun Nov 30 21:35:01 2025 +0800 fmt commit 3213283 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Sun Nov 30 21:27:29 2025 +0800 clippy commit 35f9380 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Sun Nov 30 21:13:41 2025 +0800 fmt commit d1e708a Author: Cursor Agent <cursoragent@cursor.com> Date: Sun Nov 30 10:47:39 2025 +0000 Refactor playback prefetching to use tokio mpsc and futures Co-authored-by: richiemcilroy1 <richiemcilroy1@gmail.com> commit 23f8516 Author: Cursor Agent <cursoragent@cursor.com> Date: Sun Nov 30 10:45:29 2025 +0000 Checkpoint before follow-up message Co-authored-by: richiemcilroy1 <richiemcilroy1@gmail.com> commit 9bb14bb Author: Cursor Agent <cursoragent@cursor.com> Date: Sun Nov 30 10:23:27 2025 +0000 Refactor: Improve editor performance and UI responsiveness Co-authored-by: richiemcilroy1 <richiemcilroy1@gmail.com> commit 87ffbc2 Merge: 3cb22ad 0e16f7c Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Sat Nov 29 16:30:29 2025 +0530 Merge pull request CapSoftware#1410 from p-delorme/fix-camera-init Handles legacy camera size (strings) commit 0e16f7c Merge: 21f197e 3cb22ad Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Sat Nov 29 18:48:41 2025 +0800 Merge branch 'main' into pr/1410 commit 3cb22ad Merge: 2330c53 48f7aeb Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Sat Nov 29 10:00:30 2025 +0530 Merge pull request CapSoftware#1395 from CapSoftware/screenshots commit 48f7aeb Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Sat Nov 29 12:02:29 2025 +0800 fmt commit 126421d Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Sat Nov 29 11:59:07 2025 +0800 types/clippy bits commit cdc91c0 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Sat Nov 29 11:47:16 2025 +0800 Throw SilentError on export cancellation commit 980720e Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Sat Nov 29 11:47:06 2025 +0800 Add image dimension and data validation to editor commit 860ccd7 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Sat Nov 29 11:46:57 2025 +0800 Add camera_cleanup_done flag to prevent redundant cleanup commit 38cc696 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Sat Nov 29 00:02:07 2025 +0800 claude settings commit e2545ee Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri Nov 28 23:58:31 2025 +0800 Improve screenshot capture reliability and performance commit ba9ba53 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri Nov 28 23:58:17 2025 +0800 Add validation for annotation and camera config commit 641a99a Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri Nov 28 23:58:03 2025 +0800 Show toast on screenshot failure in overlay commit ba901dd Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri Nov 28 22:48:55 2025 +0800 Add keyboard shortcuts for export actions in Header commit c73f735 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri Nov 28 21:47:48 2025 +0800 Add stride check in FFmpeg frame conversion commit 6825eb3 Merge: 4d73f14 2330c53 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri Nov 28 21:23:41 2025 +0800 Merge branch 'main' into screenshots commit 2330c53 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri Nov 28 20:22:42 2025 +0800 fix: margin on mobile nav commit 0765fee Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri Nov 28 20:16:06 2025 +0800 feat: Cap Friday commit 4d73f14 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri Nov 28 04:55:51 2025 +0530 Add fast screenshot capture and shared GPU context commit f8f1d01 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri Nov 28 04:54:15 2025 +0530 Add toast notifications for screenshot actions commit bb0310d Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri Nov 28 01:16:47 2025 +0530 misc bits commit ed64349 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri Nov 28 01:16:42 2025 +0530 Refactor camera window cleanup logic commit 2b1eb9e Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri Nov 28 01:16:25 2025 +0530 Handle errors during titlebar initialization commit eafc7d9 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri Nov 28 01:16:12 2025 +0530 Refactor import and error handling in screenshot_editor.rs commit d776857 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri Nov 28 01:15:59 2025 +0530 Optimize PNG screenshot encoding settings commit 737b89a Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri Nov 28 01:15:42 2025 +0530 Remove unused mutable binding in camera_legacy.rs commit 37456d3 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri Nov 28 00:39:08 2025 +0530 Disable cursor capture in screenshot functionality commit 694de05 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri Nov 28 00:24:07 2025 +0530 Refactor camera preview to use broadcast channel commit 7c68831 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri Nov 28 00:23:58 2025 +0530 Switch frame channel from flume to tokio broadcast commit 3a39c9c Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri Nov 28 00:23:25 2025 +0530 Refactor WebSocket frame handling to use broadcast channel commit f12c13e Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri Nov 28 00:23:14 2025 +0530 Refactor render shutdown handling in screenshot editor commit 3c4a124 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri Nov 28 00:23:05 2025 +0530 Remove timestamp from screenshot src commit 032b819 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri Nov 28 00:21:25 2025 +0530 Handle shutdown in screenshot editor render loop commit 7dd146a Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Fri Nov 28 00:15:59 2025 +0530 Handle missing ScreenshotEditor instance gracefully commit 21f197e Author: Patrick Delorme <pdelorme@agence104.com> Date: Wed Nov 26 22:18:33 2025 -0500 Handles legacy camera size strings commit 9d22e01 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Sat Nov 22 09:24:47 2025 +0000 0.4.0 commit af1cc60 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Sat Nov 22 10:45:45 2025 +0530 feat: Screenshots V1 - Enhance screenshot editor with mask tool and export cancel commit 61982eb Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Thu Nov 20 16:03:26 2025 +0000 Add screenshot export improvements and new icon commit 1996ab6 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Thu Nov 20 15:28:16 2025 +0000 Implement Windows screenshot capture support commit 7bd9644 Merge: 6dcb6f2 f272bbf Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Thu Nov 20 15:22:15 2025 +0000 Merge branch 'main' into screenshots commit a292974 Merge: f272bbf 4a41f99 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Thu Nov 20 15:21:54 2025 +0000 Merge pull request CapSoftware#1381 from phuocithcmus/fix/window-memory-leak-processout fix: window memory leak - memory increase while recording commit 6dcb6f2 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Thu Nov 20 15:03:01 2025 +0000 Refactor mask blur logic for screenshot editor commit b4c8a17 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Thu Nov 20 12:51:21 2025 +0000 feat: Screenshot editor styling/layout + Mask annotation commit f272bbf Merge: 563e238 bab0348 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Wed Nov 19 19:01:40 2025 +0000 Merge pull request CapSoftware#1396 from ItsEeleeya/new-theme-previews New theme preview icons commit bab0348 Author: Ilya <47112191+ItsEeleeya@users.noreply.github.com> Date: Wed Nov 19 21:54:35 2025 +0330 Remove unused commit ef4a54f Author: Ilya <47112191+ItsEeleeya@users.noreply.github.com> Date: Wed Nov 19 21:45:33 2025 +0330 New theme preview icons commit f92090a Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Wed Nov 19 17:57:11 2025 +0000 Add screenshot support to target selection UI commit 849b702 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Wed Nov 19 17:20:53 2025 +0000 Replace Button with native button in TargetMenuPanel commit f28cffd Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Wed Nov 19 17:15:52 2025 +0000 Add recordings grid and menu to main window commit 84d1baa Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Wed Nov 19 16:55:52 2025 +0000 Refactor screenshot saving and editor window management commit f9450c8 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Wed Nov 19 16:55:35 2025 +0000 Add screenshot mode and image icon support commit 11007c2 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Wed Nov 19 16:55:23 2025 +0000 Refactor screenshot editor and add screenshots tab commit 77cac64 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Wed Nov 19 02:45:50 2025 +0000 Integrate live preview for screenshot editor commit c982991 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Wed Nov 19 02:45:40 2025 +0000 Add screenshot editor integration and DecodedFrame constructor commit 50ca057 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Wed Nov 19 02:45:24 2025 +0000 Add screenshot editor backend implementation commit 4c3b942 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Wed Nov 19 02:31:13 2025 +0000 Allow Slider to accept custom history prop commit f7047a0 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Wed Nov 19 02:29:18 2025 +0000 feat: v1 of screenshots commit 563e238 Merge: 9edf1ce 2f75043 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Wed Nov 19 00:33:18 2025 +0000 Merge pull request CapSoftware#1390 from CapSoftware/editor-perf feat: Various features + performance bits commit 2f75043 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Wed Nov 19 00:30:49 2025 +0000 clippy bits commit ef920b2 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Wed Nov 19 00:20:04 2025 +0000 gen'd files commit 695bb66 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Wed Nov 19 00:19:52 2025 +0000 Fix requestAnimationFrame cleanup in overlay commit 0510be8 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Wed Nov 19 00:19:44 2025 +0000 Add __CAP__ property to Window interface commit 756d296 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Wed Nov 19 00:19:29 2025 +0000 Improve camera window resizing and positioning logic commit ff78eba Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Wed Nov 19 00:19:09 2025 +0000 Clarify and emphasize no code comments policy commit 6db1d2d Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue Nov 18 23:41:03 2025 +0000 Remove unused setCamera mutation in camera page commit 51e2f6e Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue Nov 18 23:38:43 2025 +0000 misc packages commit a0aeffa Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue Nov 18 23:38:32 2025 +0000 Refactor duration calculation for readability commit fd30b14 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue Nov 18 21:52:38 2025 +0000 Add checked_duration_since for timestamp types commit 05f39bb Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue Nov 18 21:46:20 2025 +0000 Improve countdown animation and fix recording logic commit dec0d8e Merge: 0066eb1 5de394f Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue Nov 18 21:44:52 2025 +0000 Merge branch 'editor-perf' of https://github.com/CapSoftware/Cap into editor-perf commit 0066eb1 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue Nov 18 21:36:48 2025 +0000 Add camera overlay bounds update and revert logic commit 5de394f Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue Nov 18 20:51:15 2025 +0000 Update apps/desktop/src-tauri/src/camera.rs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> commit e6e9320 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue Nov 18 18:26:21 2025 +0000 Improve logging and error context in recording pipeline commit d24e92c Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue Nov 18 17:10:19 2025 +0000 Add code formatting guidelines to documentation commit 2b504dd Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue Nov 18 16:54:29 2025 +0000 Update camera.tsx commit 891b122 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue Nov 18 16:54:02 2025 +0000 Improve camera feed sender handling and logging commit 831fb76 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue Nov 18 16:53:42 2025 +0000 Fix import order in experimental settings route commit dd39425 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue Nov 18 16:41:22 2025 +0000 Set Mellow as default for CursorAnimationStyle commit ce63e02 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue Nov 18 16:41:11 2025 +0000 Add resizing to camera window commit 6dd3ff1 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue Nov 18 16:40:46 2025 +0000 Hide native camera preview toggle on Windows commit 44a5348 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue Nov 18 15:14:03 2025 +0000 Refactor type casting for currentRecording data commit 41fbc5c Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue Nov 18 14:51:41 2025 +0000 Improve camera initialization and recording state handling commit 6aca28e Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue Nov 18 14:51:33 2025 +0000 Add initializing state to recording flow commit d2b8fd4 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue Nov 18 14:50:45 2025 +0000 Update close button to use window close action commit fee3391 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue Nov 18 12:00:28 2025 +0000 Reset camera and mic state on window close and recording end commit 184ad59 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue Nov 18 10:49:45 2025 +0000 lost a days work (I F'D UP) commit 8b403a8 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Tue Nov 18 10:40:07 2025 +0000 Update recording UI container styles commit 37eb7c8 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Mon Nov 17 20:52:24 2025 +0000 Update settings.local.json commit cced653 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Mon Nov 17 20:52:18 2025 +0000 Improve camera frame forwarding and logging commit dbe8ae1 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Mon Nov 17 20:50:12 2025 +0000 Refactor waveform rendering in ClipTrack commit 5d95f24 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Mon Nov 17 20:15:25 2025 +0000 Handle excluded windows in macOS screen capture commit b61958c Merge: bd1fc73 9edf1ce Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Mon Nov 17 17:12:38 2025 +0000 Merge branch 'main' into editor-perf commit bd1fc73 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Mon Nov 17 13:07:30 2025 +0000 fmt commit 0a5fea6 Author: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Mon Nov 17 13:07:10 2025 +0000 Refactor project config save with custom debounce commit 4a41f99 Author: phuocnd <ducphuoc.t9@gmail.com> Date: Wed Nov 12 16:15:42 2025 +0700 fix: window memory leak - memory increase while streaming
Implement virtualization and rendering optimizations to improve editor performance for long videos.
The editor was experiencing significant lag with videos 10 minutes or longer due to rendering all timeline elements and frames regardless of visibility. This PR introduces virtualization for timeline segments (clips and zoom) to only render what's currently in the viewport. Additionally, frame rendering is optimized with a reduced throttle rate,
requestAnimationFramebatching, and debounced project updates. The video decoder cache size has also been increased to reduce expensive seeking operations during scrubbing. These changes ensure that the computational cost remains constant, providing a smooth experience irrespective of video length.Note
Virtualizes timeline clip/zoom tracks, batches/throttles frame rendering, and adds parallel frame prefetching with a larger decoder cache to improve responsiveness on long videos.
visibleTimeRangeandisSegmentVisibleinTimeline/context.ts; render only visible segments inClipTrack.tsxandZoomTrack.tsxusingIndexand filtered indices.Editor.tsx: throttle (~30fps), debounce project-driven updates, requestAnimationFrame batching, and proper cleanup.crates/editor/src/playback.rswith bounded in-flight decodes, frame skip capping, and coordination via channels.DecodedSegmentFrameswhen available; fall back to on-demand decode.FRAME_CACHE_SIZEto500incrates/rendering/src/decoder/mod.rs.Written by Cursor Bugbot for commit d654add. This will update automatically on new commits. Configure here.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.